mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Update i18next type
This commit is contained in:
@ -39,7 +39,7 @@ const menuAccount = ({
|
||||
|
||||
const navigation =
|
||||
useNavigation<NativeStackNavigationProp<TabSharedStackParamList, any, undefined>>()
|
||||
const { t } = useTranslation('componentContextMenu')
|
||||
const { t } = useTranslation(['common', 'componentContextMenu', 'componentRelationship'])
|
||||
|
||||
const menus: ContextMenu[][] = [[]]
|
||||
|
||||
@ -62,11 +62,15 @@ const menuAccount = ({
|
||||
displayMessage({
|
||||
type: 'success',
|
||||
message: t('common:message.success.message', {
|
||||
function: t(`account.${theParams.payload.property}.action`, {
|
||||
...(theParams.payload.property !== 'reports' && {
|
||||
context: (theParams.payload.currentValue || false).toString()
|
||||
})
|
||||
})
|
||||
function: t(
|
||||
`componentContextMenu:account.${theParams.payload.property}.action`,
|
||||
theParams.payload.property !== 'reports'
|
||||
? {
|
||||
defaultValue: 'false',
|
||||
context: (theParams.payload.currentValue || false).toString()
|
||||
}
|
||||
: { defaultValue: 'false' }
|
||||
)
|
||||
})
|
||||
})
|
||||
},
|
||||
@ -75,11 +79,15 @@ const menuAccount = ({
|
||||
displayMessage({
|
||||
type: 'danger',
|
||||
message: t('common:message.error.message', {
|
||||
function: t(`account.${theParams.payload.property}.action`, {
|
||||
...(theParams.payload.property !== 'reports' && {
|
||||
context: (theParams.payload.currentValue || false).toString()
|
||||
})
|
||||
})
|
||||
function: t(
|
||||
`componentContextMenu:account.${theParams.payload.property}.action`,
|
||||
theParams.payload.property !== 'reports'
|
||||
? {
|
||||
defaultValue: 'false',
|
||||
context: (theParams.payload.currentValue || false).toString()
|
||||
}
|
||||
: { defaultValue: 'false' }
|
||||
)
|
||||
}),
|
||||
...(err.status &&
|
||||
typeof err.status === 'number' &&
|
||||
@ -109,7 +117,7 @@ const menuAccount = ({
|
||||
displayMessage({
|
||||
type: 'danger',
|
||||
message: t('common:message.error.message', {
|
||||
function: t(`${action}.function`)
|
||||
function: t(`componentContextMenu:${action}.function` as any)
|
||||
}),
|
||||
...(err.status &&
|
||||
typeof err.status === 'number' &&
|
||||
@ -138,7 +146,8 @@ const menuAccount = ({
|
||||
hidden: false
|
||||
},
|
||||
title: !data?.requested
|
||||
? t('account.following.action', {
|
||||
? t('componentContextMenu:account.following.action', {
|
||||
defaultValue: 'false',
|
||||
context: (data?.following || false).toString()
|
||||
})
|
||||
: t('componentRelationship:button.requested'),
|
||||
@ -158,7 +167,7 @@ const menuAccount = ({
|
||||
destructive: false,
|
||||
hidden: !isFetched || !data?.following
|
||||
},
|
||||
title: t('account.inLists'),
|
||||
title: t('componentContextMenu:account.inLists'),
|
||||
icon: 'checklist'
|
||||
})
|
||||
menus[0].push({
|
||||
@ -175,7 +184,8 @@ const menuAccount = ({
|
||||
destructive: false,
|
||||
hidden: false
|
||||
},
|
||||
title: t('account.mute.action', {
|
||||
title: t('componentContextMenu:account.mute.action', {
|
||||
defaultValue: 'false',
|
||||
context: (data?.muting || false).toString()
|
||||
}),
|
||||
icon: data?.muting ? 'eye' : 'eye.slash'
|
||||
@ -188,27 +198,32 @@ const menuAccount = ({
|
||||
key: 'account-block',
|
||||
item: {
|
||||
onSelect: () =>
|
||||
Alert.alert(t('account.block.alert.title', { username: account.username }), undefined, [
|
||||
{
|
||||
text: t('common:buttons.confirm'),
|
||||
style: 'destructive',
|
||||
onPress: () =>
|
||||
timelineMutation.mutate({
|
||||
type: 'updateAccountProperty',
|
||||
queryKey,
|
||||
id: account.id,
|
||||
payload: { property: 'block', currentValue: data?.blocking }
|
||||
})
|
||||
},
|
||||
{
|
||||
text: t('common:buttons.cancel')
|
||||
}
|
||||
]),
|
||||
Alert.alert(
|
||||
t('componentContextMenu:account.block.alert.title', { username: account.username }),
|
||||
undefined,
|
||||
[
|
||||
{
|
||||
text: t('common:buttons.confirm'),
|
||||
style: 'destructive',
|
||||
onPress: () =>
|
||||
timelineMutation.mutate({
|
||||
type: 'updateAccountProperty',
|
||||
queryKey,
|
||||
id: account.id,
|
||||
payload: { property: 'block', currentValue: data?.blocking }
|
||||
})
|
||||
},
|
||||
{
|
||||
text: t('common:buttons.cancel')
|
||||
}
|
||||
]
|
||||
),
|
||||
disabled: Platform.OS !== 'android' ? !data || !isFetched : false,
|
||||
destructive: !data?.blocking,
|
||||
hidden: false
|
||||
},
|
||||
title: t('account.block.action', {
|
||||
title: t('componentContextMenu:account.block.action', {
|
||||
defaultValue: 'false',
|
||||
context: (data?.blocking || false).toString()
|
||||
}),
|
||||
icon: data?.blocking ? 'checkmark.circle' : 'xmark.circle'
|
||||
@ -221,7 +236,7 @@ const menuAccount = ({
|
||||
destructive: true,
|
||||
hidden: false
|
||||
},
|
||||
title: t('account.reports.action'),
|
||||
title: t('componentContextMenu:account.reports.action'),
|
||||
icon: 'flag'
|
||||
}
|
||||
])
|
||||
|
@ -17,7 +17,7 @@ const menuInstance = ({
|
||||
}): ContextMenu[][] => {
|
||||
if (!status || !queryKey) return []
|
||||
|
||||
const { t } = useTranslation('componentContextMenu')
|
||||
const { t } = useTranslation(['common', 'componentContextMenu'])
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const mutation = useTimelineMutation({
|
||||
@ -25,7 +25,7 @@ const menuInstance = ({
|
||||
displayMessage({
|
||||
type: 'success',
|
||||
message: t('common:message.success.message', {
|
||||
function: t(`instance.block.action`, { instance })
|
||||
function: t(`componentContextMenu:instance.block.action`, { instance })
|
||||
})
|
||||
})
|
||||
queryClient.invalidateQueries(queryKey)
|
||||
@ -45,8 +45,8 @@ const menuInstance = ({
|
||||
item: {
|
||||
onSelect: () =>
|
||||
Alert.alert(
|
||||
t('instance.block.alert.title', { instance }),
|
||||
t('instance.block.alert.message'),
|
||||
t('componentContextMenu:instance.block.alert.title', { instance }),
|
||||
t('componentContextMenu:instance.block.alert.message'),
|
||||
[
|
||||
{
|
||||
text: t('common:buttons.confirm'),
|
||||
@ -68,7 +68,7 @@ const menuInstance = ({
|
||||
destructive: true,
|
||||
hidden: false
|
||||
},
|
||||
title: t('instance.block.action', { instance }),
|
||||
title: t('componentContextMenu:instance.block.action', { instance }),
|
||||
icon: ''
|
||||
}
|
||||
])
|
||||
|
@ -28,7 +28,7 @@ const menuStatus = ({
|
||||
|
||||
const navigation = useNavigation<NativeStackNavigationProp<RootStackParamList, 'Screen-Tabs'>>()
|
||||
const { theme } = useTheme()
|
||||
const { t } = useTranslation('componentContextMenu')
|
||||
const { t } = useTranslation(['common', 'componentContextMenu'])
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const mutation = useTimelineMutation({
|
||||
@ -41,7 +41,7 @@ const menuStatus = ({
|
||||
theme,
|
||||
type: 'error',
|
||||
message: t('common:message.error.message', {
|
||||
function: t(`status.${theFunction}.action`)
|
||||
function: t(`componentContextMenu:status.${theFunction}.action` as any)
|
||||
}),
|
||||
...(err?.status &&
|
||||
typeof err.status === 'number' &&
|
||||
@ -100,81 +100,89 @@ const menuStatus = ({
|
||||
destructive: false,
|
||||
hidden: !canEditPost
|
||||
},
|
||||
title: t('status.edit.action'),
|
||||
title: t('componentContextMenu:status.edit.action'),
|
||||
icon: 'square.and.pencil'
|
||||
},
|
||||
{
|
||||
key: 'status-delete-edit',
|
||||
item: {
|
||||
onSelect: () =>
|
||||
Alert.alert(t('status.deleteEdit.alert.title'), t('status.deleteEdit.alert.message'), [
|
||||
{
|
||||
text: t('common:buttons.confirm'),
|
||||
style: 'destructive',
|
||||
onPress: async () => {
|
||||
let replyToStatus: Mastodon.Status | undefined = undefined
|
||||
if (status.in_reply_to_id) {
|
||||
replyToStatus = await apiInstance<Mastodon.Status>({
|
||||
method: 'get',
|
||||
url: `statuses/${status.in_reply_to_id}`
|
||||
}).then(res => res.body)
|
||||
}
|
||||
mutation
|
||||
.mutateAsync({
|
||||
type: 'deleteItem',
|
||||
source: 'statuses',
|
||||
queryKey,
|
||||
id: status.id
|
||||
})
|
||||
.then(res => {
|
||||
navigation.navigate('Screen-Compose', {
|
||||
type: 'deleteEdit',
|
||||
incomingStatus: res.body as Mastodon.Status,
|
||||
...(replyToStatus && { replyToStatus }),
|
||||
queryKey
|
||||
Alert.alert(
|
||||
t('componentContextMenu:status.deleteEdit.alert.title'),
|
||||
t('componentContextMenu:status.deleteEdit.alert.message'),
|
||||
[
|
||||
{
|
||||
text: t('common:buttons.confirm'),
|
||||
style: 'destructive',
|
||||
onPress: async () => {
|
||||
let replyToStatus: Mastodon.Status | undefined = undefined
|
||||
if (status.in_reply_to_id) {
|
||||
replyToStatus = await apiInstance<Mastodon.Status>({
|
||||
method: 'get',
|
||||
url: `statuses/${status.in_reply_to_id}`
|
||||
}).then(res => res.body)
|
||||
}
|
||||
mutation
|
||||
.mutateAsync({
|
||||
type: 'deleteItem',
|
||||
source: 'statuses',
|
||||
queryKey,
|
||||
id: status.id
|
||||
})
|
||||
})
|
||||
.then(res => {
|
||||
navigation.navigate('Screen-Compose', {
|
||||
type: 'deleteEdit',
|
||||
incomingStatus: res.body as Mastodon.Status,
|
||||
...(replyToStatus && { replyToStatus }),
|
||||
queryKey
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
{
|
||||
text: t('common:buttons.cancel')
|
||||
}
|
||||
},
|
||||
{
|
||||
text: t('common:buttons.cancel')
|
||||
}
|
||||
]),
|
||||
]
|
||||
),
|
||||
disabled: false,
|
||||
destructive: true,
|
||||
hidden: false
|
||||
},
|
||||
title: t('status.deleteEdit.action'),
|
||||
title: t('componentContextMenu:status.deleteEdit.action'),
|
||||
icon: 'pencil.and.outline'
|
||||
},
|
||||
{
|
||||
key: 'status-delete',
|
||||
item: {
|
||||
onSelect: () =>
|
||||
Alert.alert(t('status.delete.alert.title'), t('status.delete.alert.message'), [
|
||||
{
|
||||
text: t('common:buttons.confirm'),
|
||||
style: 'destructive',
|
||||
onPress: async () => {
|
||||
mutation.mutate({
|
||||
type: 'deleteItem',
|
||||
source: 'statuses',
|
||||
queryKey,
|
||||
rootQueryKey,
|
||||
id: status.id
|
||||
})
|
||||
Alert.alert(
|
||||
t('componentContextMenu:status.delete.alert.title'),
|
||||
t('componentContextMenu:status.delete.alert.message'),
|
||||
[
|
||||
{
|
||||
text: t('common:buttons.confirm'),
|
||||
style: 'destructive',
|
||||
onPress: async () => {
|
||||
mutation.mutate({
|
||||
type: 'deleteItem',
|
||||
source: 'statuses',
|
||||
queryKey,
|
||||
rootQueryKey,
|
||||
id: status.id
|
||||
})
|
||||
}
|
||||
},
|
||||
{
|
||||
text: t('common:buttons.cancel'),
|
||||
style: 'default'
|
||||
}
|
||||
},
|
||||
{
|
||||
text: t('common:buttons.cancel'),
|
||||
style: 'default'
|
||||
}
|
||||
]),
|
||||
]
|
||||
),
|
||||
disabled: false,
|
||||
destructive: true,
|
||||
hidden: false
|
||||
},
|
||||
title: t('status.delete.action'),
|
||||
title: t('componentContextMenu:status.delete.action'),
|
||||
icon: 'trash'
|
||||
}
|
||||
])
|
||||
@ -200,7 +208,8 @@ const menuStatus = ({
|
||||
destructive: false,
|
||||
hidden: false
|
||||
},
|
||||
title: t('status.mute.action', {
|
||||
title: t('componentContextMenu:status.mute.action', {
|
||||
defaultValue: 'false',
|
||||
context: (status.muted || false).toString()
|
||||
}),
|
||||
icon: status.muted ? 'speaker' : 'speaker.slash'
|
||||
@ -226,7 +235,8 @@ const menuStatus = ({
|
||||
destructive: false,
|
||||
hidden: status.visibility !== 'public' && status.visibility !== 'unlisted'
|
||||
},
|
||||
title: t('status.pin.action', {
|
||||
title: t('componentContextMenu:status.pin.action', {
|
||||
defaultValue: 'false',
|
||||
context: (status.pinned || false).toString()
|
||||
}),
|
||||
icon: status.pinned ? 'pin.slash' : 'pin'
|
||||
|
Reference in New Issue
Block a user