1
0
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:
xmflsct
2022-12-23 15:53:40 +01:00
parent b388853429
commit e32125ad17
49 changed files with 1054 additions and 896 deletions

View File

@ -7,7 +7,6 @@ import { chunk, forEach, groupBy, sortBy } from 'lodash'
import React, { createRef, PropsWithChildren, useEffect, useReducer, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { Keyboard, KeyboardAvoidingView, View } from 'react-native'
import FastImage from 'react-native-fast-image'
import { Edge, SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context'
import { useSelector } from 'react-redux'
import EmojisContext, { Emojis, emojisReducer, EmojisState } from './Emojis/helpers/EmojisContext'
@ -35,7 +34,7 @@ const ComponentEmojis: React.FC<Props & PropsWithChildren> = ({
emojisDispatch({ type: 'input', payload: inputProps })
}, [inputProps])
const { t } = useTranslation()
const { t } = useTranslation(['componentEmojis'])
const { data } = useEmojisQuery({})
const frequentEmojis = useSelector(getInstanceFrequentEmojis, () => true)
useEffect(() => {

View File

@ -25,7 +25,7 @@ import EmojisContext from './helpers/EmojisContext'
const EmojisList = () => {
const dispatch = useAppDispatch()
const { reduceMotionEnabled } = useAccessibility()
const { t } = useTranslation()
const { t } = useTranslation(['common', 'screenCompose'])
const { emojisState, emojisDispatch } = useContext(EmojisContext)
const { colors } = useTheme()

View File

@ -35,7 +35,7 @@ const ComponentInstance: React.FC<Props> = ({
disableHeaderImage,
goBack = false
}) => {
const { t } = useTranslation('componentInstance')
const { t } = useTranslation(['common', 'componentInstance'])
const { colors, mode } = useTheme()
const navigation = useNavigation<TabMeStackNavigationProp<'Tab-Me-Root' | 'Tab-Me-Switch'>>()
@ -113,16 +113,20 @@ const ComponentInstance: React.FC<Props> = ({
const processUpdate = useCallback(() => {
if (domain) {
if (instances && instances.filter(instance => instance.url === domain).length) {
Alert.alert(t('update.alert.title'), t('update.alert.message'), [
{
text: t('common:buttons.cancel'),
style: 'cancel'
},
{
text: t('common:buttons.continue'),
onPress: () => appsMutation.mutate({ domain })
}
])
Alert.alert(
t('componentInstance:update.alert.title'),
t('componentInstance:update.alert.message'),
[
{
text: t('common:buttons.cancel'),
style: 'cancel'
},
{
text: t('common:buttons.continue'),
onPress: () => appsMutation.mutate({ domain })
}
]
)
} else {
appsMutation.mutate({ domain })
}
@ -209,7 +213,7 @@ const ComponentInstance: React.FC<Props> = ({
processUpdate()
}
}}
placeholder={' ' + t('server.textInput.placeholder')}
placeholder={' ' + t('componentInstance:server.textInput.placeholder')}
placeholderTextColor={colors.secondary}
returnKeyType='go'
keyboardAppearance={mode}
@ -222,7 +226,7 @@ const ComponentInstance: React.FC<Props> = ({
/>
<Button
type='text'
content={t('server.button')}
content={t('componentInstance:server.button')}
onPress={processUpdate}
disabled={!instanceQuery.data?.uri && !whitelisted}
loading={instanceQuery.isFetching || appsMutation.isLoading}
@ -239,31 +243,31 @@ const ComponentInstance: React.FC<Props> = ({
paddingTop: StyleConstants.Spacing.XS
}}
>
{t('server.whitelisted')}
{t('componentInstance:server.whitelisted')}
</CustomText>
) : (
<Placeholder>
<InstanceInfo
header={t('server.information.name')}
header={t('componentInstance:server.information.name')}
content={instanceQuery.data?.title || undefined}
potentialWidth={2}
/>
<View style={{ flex: 1, flexDirection: 'row' }}>
<InstanceInfo
style={{ alignItems: 'flex-start' }}
header={t('server.information.accounts')}
header={t('componentInstance:server.information.accounts')}
content={instanceQuery.data?.stats?.user_count?.toString() || undefined}
potentialWidth={4}
/>
<InstanceInfo
style={{ alignItems: 'center' }}
header={t('server.information.statuses')}
header={t('componentInstance:server.information.statuses')}
content={instanceQuery.data?.stats?.status_count?.toString() || undefined}
potentialWidth={4}
/>
<InstanceInfo
style={{ alignItems: 'flex-end' }}
header={t('server.information.domains')}
header={t('componentInstance:server.information.domains')}
content={instanceQuery.data?.stats?.domain_count?.toString() || undefined}
potentialWidth={4}
/>
@ -287,7 +291,7 @@ const ComponentInstance: React.FC<Props> = ({
}}
/>
<CustomText fontStyle='S' style={{ flex: 1, color: colors.secondary }}>
{t('server.disclaimer.base')}
{t('componentInstance:server.disclaimer.base')}
</CustomText>
</View>
<View
@ -312,7 +316,8 @@ const ComponentInstance: React.FC<Props> = ({
accessibilityRole='link'
>
<Trans
i18nKey='componentInstance:server.terms.base'
ns='componentInstance'
i18nKey='server.terms.base'
components={[
<CustomText
accessible

View File

@ -16,7 +16,7 @@ export interface Props {
const RelationshipIncoming: React.FC<Props> = ({ id }) => {
const { theme } = useTheme()
const { t } = useTranslation()
const { t } = useTranslation(['common', 'componentRelationship'])
const queryKeyRelationship: QueryKeyRelationship = ['Relationship', { id }]
const queryKeyNotification: QueryKeyTimeline = ['Timeline', { page: 'Notifications' }]
@ -33,7 +33,7 @@ const RelationshipIncoming: React.FC<Props> = ({ id }) => {
type: 'error',
theme,
message: t('common:message.error.message', {
function: t(`relationship:${type}.function`)
function: t(`componentRelationship:${type}.function`)
}),
...(err.status &&
typeof err.status === 'number' &&

View File

@ -22,7 +22,7 @@ export interface Props {
const RelationshipOutgoing: React.FC<Props> = ({ id }: Props) => {
const { theme } = useTheme()
const { t } = useTranslation('componentRelationship')
const { t } = useTranslation(['common', 'componentRelationship'])
const canFollowNotify = useSelector(checkInstanceFeature('account_follow_notify'))
@ -44,7 +44,7 @@ const RelationshipOutgoing: React.FC<Props> = ({ id }: Props) => {
theme,
type: 'error',
message: t('common:message.error.message', {
function: t(`${action}.function`)
function: t(`componentRelationship:${action}.function`)
}),
...(err.status &&
typeof err.status === 'number' &&
@ -61,15 +61,15 @@ const RelationshipOutgoing: React.FC<Props> = ({ id }: Props) => {
let onPress: () => void
if (query.isError) {
content = t('button.error')
content = t('componentRelationship:button.error')
onPress = () => {}
} else {
if (query.data?.blocked_by) {
content = t('button.blocked_by')
content = t('componentRelationship:button.blocked_by')
onPress = () => {}
} else {
if (query.data?.blocking) {
content = t('button.blocking')
content = t('componentRelationship:button.blocking')
onPress = () => {
mutation.mutate({
id,
@ -82,7 +82,7 @@ const RelationshipOutgoing: React.FC<Props> = ({ id }: Props) => {
}
} else {
if (query.data?.following) {
content = t('button.following')
content = t('componentRelationship:button.following')
onPress = () => {
mutation.mutate({
id,
@ -95,7 +95,7 @@ const RelationshipOutgoing: React.FC<Props> = ({ id }: Props) => {
}
} else {
if (query.data?.requested) {
content = t('button.requested')
content = t('componentRelationship:button.requested')
onPress = () => {
mutation.mutate({
id,
@ -107,7 +107,7 @@ const RelationshipOutgoing: React.FC<Props> = ({ id }: Props) => {
})
}
} else {
content = t('button.default')
content = t('componentRelationship:button.default')
onPress = () => {
mutation.mutate({
id,

View File

@ -45,7 +45,8 @@ const TimelineFooter = React.memo(
) : (
<CustomText fontStyle='S' style={{ color: colors.secondary }}>
<Trans
i18nKey='componentTimeline:end.message'
ns='componentTimeline'
i18nKey='end.message'
components={[
<Icon name='Coffee' size={StyleConstants.Font.Size.S} color={colors.secondary} />
]}

View File

@ -28,7 +28,7 @@ const TimelineActions: React.FC = () => {
if (!queryKey || !status || disableDetails) return null
const navigation = useNavigation<StackNavigationProp<RootStackParamList>>()
const { t } = useTranslation('componentTimeline')
const { t } = useTranslation(['common', 'componentTimeline'])
const { colors, theme } = useTheme()
const iconColor = colors.secondary
@ -54,13 +54,13 @@ const TimelineActions: React.FC = () => {
queryClient.invalidateQueries(tempQueryKey)
}
},
onError: (err: any, params, oldData) => {
onError: (err: any, params) => {
const correctParam = params as MutationVarsTimelineUpdateStatusProperty
displayMessage({
theme,
type: 'error',
message: t('common:message.error.message', {
function: t(`shared.actions.${correctParam.payload.property}.function`)
function: t(`componentTimeline:shared.actions.${correctParam.payload.property}.function`)
}),
...(err.status &&
typeof err.status === 'number' &&
@ -94,10 +94,10 @@ const TimelineActions: React.FC = () => {
if (!status.reblogged) {
showActionSheetWithOptions(
{
title: t('shared.actions.reblogged.options.title'),
title: t('componentTimeline:shared.actions.reblogged.options.title'),
options: [
t('shared.actions.reblogged.options.public'),
t('shared.actions.reblogged.options.unlisted'),
t('componentTimeline:shared.actions.reblogged.options.public'),
t('componentTimeline:shared.actions.reblogged.options.unlisted'),
t('common:buttons.cancel')
],
cancelButtonIndex: 2,
@ -269,7 +269,7 @@ const TimelineActions: React.FC = () => {
<Pressable
{...(highlighted
? {
accessibilityLabel: t('shared.actions.reply.accessibilityLabel'),
accessibilityLabel: t('componentTimeline:shared.actions.reply.accessibilityLabel'),
accessibilityRole: 'button'
}
: { accessibilityLabel: '' })}
@ -281,7 +281,9 @@ const TimelineActions: React.FC = () => {
<Pressable
{...(highlighted
? {
accessibilityLabel: t('shared.actions.reblogged.accessibilityLabel'),
accessibilityLabel: t(
'componentTimeline:shared.actions.reblogged.accessibilityLabel'
),
accessibilityRole: 'button'
}
: { accessibilityLabel: '' })}
@ -296,7 +298,9 @@ const TimelineActions: React.FC = () => {
<Pressable
{...(highlighted
? {
accessibilityLabel: t('shared.actions.favourited.accessibilityLabel'),
accessibilityLabel: t(
'componentTimeline:shared.actions.favourited.accessibilityLabel'
),
accessibilityRole: 'button'
}
: { accessibilityLabel: '' })}
@ -308,7 +312,9 @@ const TimelineActions: React.FC = () => {
<Pressable
{...(highlighted
? {
accessibilityLabel: t('shared.actions.bookmarked.accessibilityLabel'),
accessibilityLabel: t(
'componentTimeline:shared.actions.bookmarked.accessibilityLabel'
),
accessibilityRole: 'button'
}
: { accessibilityLabel: '' })}

View File

@ -15,7 +15,7 @@ export interface FilteredProps {
const TimelineFiltered: React.FC<FilteredProps> = ({ filterResults }) => {
const { colors } = useTheme()
const { t } = useTranslation('componentTimeline')
const { t } = useTranslation(['common', 'componentTimeline'])
const main = () => {
if (!filterResults?.length) {
@ -23,18 +23,27 @@ const TimelineFiltered: React.FC<FilteredProps> = ({ filterResults }) => {
}
switch (typeof filterResults[0]) {
case 'string': // v1 filter
return <>{t('shared.filtered.match', { context: 'v1', phrase: filterResults[0] })}</>
return (
<>
{t('componentTimeline:shared.filtered.match', {
defaultValue: 'v1',
context: 'v1',
phrase: filterResults[0]
})}
</>
)
default:
return (
<>
{t('shared.filtered.match', {
{t('componentTimeline:shared.filtered.match', {
defaultValue: 'v2',
context: 'v2',
count: filterResults.length,
filters: filterResults.map(result => result.title).join(t('common:separator'))
})}
<CustomText
style={{ color: colors.blue }}
children={`\n${t('shared.filtered.reveal')}`}
children={`\n${t('componentTimeline:shared.filtered.reveal')}`}
/>
</>
)

View File

@ -22,7 +22,7 @@ const HeaderConversation = ({ conversation }: Props) => {
if (!queryKey) return null
const { colors, theme } = useTheme()
const { t } = useTranslation('componentTimeline')
const { t } = useTranslation(['common', 'componentTimeline'])
const queryClient = useQueryClient()
const mutation = useTimelineMutation({
@ -32,7 +32,7 @@ const HeaderConversation = ({ conversation }: Props) => {
theme,
type: 'error',
message: t('common:message.error.message', {
function: t(`shared.header.conversation.delete.function`)
function: t(`componentTimeline:shared.header.conversation.delete.function`)
}),
...(err.status &&
typeof err.status === 'number' &&
@ -53,7 +53,7 @@ const HeaderConversation = ({ conversation }: Props) => {
numberOfLines={1}
style={{ ...StyleConstants.FontStyle.M, color: colors.secondary }}
>
<CustomText>{t('shared.header.conversation.withAccounts')}</CustomText>
<CustomText>{t('componentTimeline:shared.header.conversation.withAccounts')}</CustomText>
{conversation.accounts.map((account, index) => (
<CustomText key={account.id} numberOfLines={1}>
{index !== 0 ? t('common:separator') : undefined}

View File

@ -33,7 +33,7 @@ const TimelinePoll: React.FC = () => {
const poll = status.poll
const { colors, theme } = useTheme()
const { t } = useTranslation('componentTimeline')
const { t } = useTranslation(['common', 'componentTimeline'])
const [allOptions, setAllOptions] = useState(new Array(status.poll.options.length).fill(false))
@ -58,8 +58,7 @@ const TimelinePoll: React.FC = () => {
theme,
type: 'error',
message: t('common:message.error.message', {
// @ts-ignore
function: t(`shared.poll.meta.button.${theParams.payload.type}`)
function: t(`componentTimeline:shared.poll.meta.button.${theParams.payload.type}` as any)
}),
...(err.status &&
typeof err.status === 'number' &&
@ -95,7 +94,7 @@ const TimelinePoll: React.FC = () => {
})
}
type='text'
content={t('shared.poll.meta.button.vote')}
content={t('componentTimeline:shared.poll.meta.button.vote')}
loading={mutation.isLoading}
disabled={allOptions.filter(o => o !== false).length === 0}
/>
@ -120,7 +119,7 @@ const TimelinePoll: React.FC = () => {
})
}
type='text'
content={t('shared.poll.meta.button.refresh')}
content={t('componentTimeline:shared.poll.meta.button.refresh')}
loading={mutation.isLoading}
/>
</View>
@ -233,20 +232,25 @@ const TimelinePoll: React.FC = () => {
const pollVoteCounts = () => {
if (poll.voters_count !== null) {
return t('shared.poll.meta.count.voters', { count: poll.voters_count }) + ' • '
return (
t('componentTimeline:shared.poll.meta.count.voters', { count: poll.voters_count }) + ' • '
)
} else if (poll.votes_count !== null) {
return t('shared.poll.meta.count.votes', { count: poll.votes_count }) + ' • '
return (
t('componentTimeline:shared.poll.meta.count.votes', { count: poll.votes_count }) + ' • '
)
}
}
const pollExpiration = () => {
if (poll.expired) {
return t('shared.poll.meta.expiration.expired')
return t('componentTimeline:shared.poll.meta.expiration.expired')
} else {
if (poll.expires_at) {
return (
<Trans
i18nKey='componentTimeline:shared.poll.meta.expiration.until'
ns='componentTimeline'
i18nKey='shared.poll.meta.expiration.until'
components={[<RelativeTime time={poll.expires_at} />]}
/>
)

View File

@ -16,7 +16,7 @@ const TimelineTranslate = () => {
const { status, highlighted, rawContent, detectedLanguage } = useContext(StatusContext)
if (!status || !highlighted || !rawContent?.current.length) return null
const { t } = useTranslation('componentTimeline')
const { t } = useTranslation(['componentTimeline'])
const { colors } = useTheme()
const [detected, setDetected] = useState<{
@ -101,15 +101,15 @@ const TimelineTranslate = () => {
}}
>
{isError
? t('shared.translate.failed')
? t('componentTimeline:shared.translate.failed')
: isSuccess
? typeof data?.error === 'string'
? t(`shared.translate.${data.error}`)
: t('shared.translate.succeed', {
? t(`componentTimeline:shared.translate.${data.error}` as any)
: t('componentTimeline:shared.translate.succeed', {
provider: data?.provider,
source: data?.sourceLanguage
})
: t('shared.translate.default')}
: t('componentTimeline:shared.translate.default')}
</CustomText>
{isFetching ? (
<Circle

View File

@ -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'
}
])

View File

@ -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: ''
}
])

View File

@ -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'