This commit is contained in:
Samuel Newman
2026-03-23 19:31:40 +02:00
parent b8929ac3cc
commit cc6e133690
@@ -1,8 +1,7 @@
import {useCallback} from 'react' import {useCallback} from 'react'
import {View} from 'react-native' import {View} from 'react-native'
import {type AppBskyActorDefs} from '@atproto/api' import {type AppBskyActorDefs} from '@atproto/api'
import {msg, Trans} from '@lingui/macro' import {Trans, useLingui} from '@lingui/react/macro'
import {useLingui} from '@lingui/react'
import {useQueryClient} from '@tanstack/react-query' import {useQueryClient} from '@tanstack/react-query'
import {sanitizeDisplayName} from '#/lib/strings/display-names' import {sanitizeDisplayName} from '#/lib/strings/display-names'
@@ -91,7 +90,7 @@ function ListsContent({
onRemove, onRemove,
}: Omit<UserAddRemoveListsDialogProps, 'control'>) { }: Omit<UserAddRemoveListsDialogProps, 'control'>) {
const control = Dialog.useDialogContext() const control = Dialog.useDialogContext()
const {_} = useLingui() const {t: l} = useLingui()
const { const {
data, data,
@@ -144,7 +143,7 @@ function ListsContent({
<Trans>Update {sanitizeDisplayName(displayName)} in Lists</Trans> <Trans>Update {sanitizeDisplayName(displayName)} in Lists</Trans>
</Text> </Text>
<Button <Button
label={_(msg`Close`)} label={l`Close`}
onPress={onClose} onPress={onClose}
variant="ghost" variant="ghost"
color="secondary" color="secondary"
@@ -200,7 +199,7 @@ function ListItem({
onAdd?: (listUri: string) => void onAdd?: (listUri: string) => void
onRemove?: (listUri: string) => void onRemove?: (listUri: string) => void
}) { }) {
const {_} = useLingui() const {t: l} = useLingui()
const t = useTheme() const t = useTheme()
const queryClient = useQueryClient() const queryClient = useQueryClient()
const {currentAccount} = useSession() const {currentAccount} = useSession()
@@ -212,7 +211,7 @@ function ListItem({
const {mutate: addMembership, isPending: isPendingAdd} = const {mutate: addMembership, isPending: isPendingAdd} =
useListMembershipAddMutation({ useListMembershipAddMutation({
onSuccess: data => { onSuccess: data => {
Toast.show(_(msg`Added to list`)) Toast.show(l`Added to list`)
onAdd?.(list.uri) onAdd?.(list.uri)
updateListMembershipOptimistically({ updateListMembershipOptimistically({
queryClient, queryClient,
@@ -230,14 +229,14 @@ function ListItem({
if (!isNetworkError(err)) { if (!isNetworkError(err)) {
logger.error('Failed to add to list', {safeMessage: err}) logger.error('Failed to add to list', {safeMessage: err})
} }
Toast.show(_(msg`Failed to add to list`), {type: 'error'}) Toast.show(l`Failed to add to list`, {type: 'error'})
}, },
}) })
const {mutate: removeMembership, isPending: isPendingRemove} = const {mutate: removeMembership, isPending: isPendingRemove} =
useListMembershipRemoveMutation({ useListMembershipRemoveMutation({
onSuccess: () => { onSuccess: () => {
Toast.show(_(msg`Removed from list`)) Toast.show(l`Removed from list`)
onRemove?.(list.uri) onRemove?.(list.uri)
removeListMembershipOptimistically({ removeListMembershipOptimistically({
queryClient, queryClient,
@@ -249,7 +248,7 @@ function ListItem({
if (!isNetworkError(err)) { if (!isNetworkError(err)) {
logger.error('Failed to remove from list', {safeMessage: err}) logger.error('Failed to remove from list', {safeMessage: err})
} }
Toast.show(_(msg`Failed to remove from list`), {type: 'error'}) Toast.show(l`Failed to remove from list`, {type: 'error'})
}, },
}) })
@@ -318,7 +317,7 @@ function ListItem({
</View> </View>
<Button <Button
testID={`user-${handle}-addBtn`} testID={`user-${handle}-addBtn`}
label={isMember ? _(msg`Remove`) : _(msg`Add`)} label={isMember ? l`Remove` : l`Add`}
onPress={handleToggleMembership} onPress={handleToggleMembership}
disabled={isPending} disabled={isPending}
size="tiny" size="tiny"