diff --git a/src/components/Timeline/Default.tsx b/src/components/Timeline/Default.tsx index c8a1d218..b1b2157d 100644 --- a/src/components/Timeline/Default.tsx +++ b/src/components/Timeline/Default.tsx @@ -196,37 +196,19 @@ const TimelineDefault: React.FC = ({ - {mShare.map((mGroup, index) => ( - - {mGroup.map(menu => ( - - - - + {[mShare, mStatus, mInstance].map(type => ( + <> + {type.map((mGroup, index) => ( + + {mGroup.map(menu => ( + + + + + ))} + ))} - - ))} - - {mStatus.map((mGroup, index) => ( - - {mGroup.map(menu => ( - - - - - ))} - - ))} - - {mInstance.map((mGroup, index) => ( - - {mGroup.map(menu => ( - - - - - ))} - + ))} diff --git a/src/components/Timeline/Notifications.tsx b/src/components/Timeline/Notifications.tsx index a947e0f0..1e2b9bf7 100644 --- a/src/components/Timeline/Notifications.tsx +++ b/src/components/Timeline/Notifications.tsx @@ -164,37 +164,19 @@ const TimelineNotifications: React.FC = ({ notification, queryKey }) => { - {mShare.map((mGroup, index) => ( - - {mGroup.map(menu => ( - - - - + {[mShare, mStatus, mInstance].map(type => ( + <> + {type.map((mGroup, index) => ( + + {mGroup.map(menu => ( + + + + + ))} + ))} - - ))} - - {mStatus.map((mGroup, index) => ( - - {mGroup.map(menu => ( - - - - - ))} - - ))} - - {mInstance.map((mGroup, index) => ( - - {mGroup.map(menu => ( - - - - - ))} - + ))} diff --git a/src/components/Timeline/Shared/HeaderAndroid.tsx b/src/components/Timeline/Shared/HeaderAndroid.tsx index 31836e4c..51306535 100644 --- a/src/components/Timeline/Shared/HeaderAndroid.tsx +++ b/src/components/Timeline/Shared/HeaderAndroid.tsx @@ -53,34 +53,19 @@ const TimelineHeaderAndroid: React.FC = () => { - {mShare.map((mGroup, index) => ( - - {mGroup.map(menu => ( - - - + {[mShare, mAccount, mStatus].map(type => ( + <> + {type.map((mGroup, index) => ( + + {mGroup.map(menu => ( + + + + + ))} + ))} - - ))} - - {mAccount.map((mGroup, index) => ( - - {mGroup.map(menu => ( - - - - ))} - - ))} - - {mStatus.map((mGroup, index) => ( - - {mGroup.map(menu => ( - - - - ))} - + ))} diff --git a/src/components/Timeline/Shared/HeaderDefault.tsx b/src/components/Timeline/Shared/HeaderDefault.tsx index 1a5f4d98..a7b7e290 100644 --- a/src/components/Timeline/Shared/HeaderDefault.tsx +++ b/src/components/Timeline/Shared/HeaderDefault.tsx @@ -83,37 +83,19 @@ const TimelineHeaderDefault: React.FC = () => { - {mShare.map((mGroup, index) => ( - - {mGroup.map(menu => ( - - - - + {[mShare, mAccount, mStatus].map(type => ( + <> + {type.map((mGroup, index) => ( + + {mGroup.map(menu => ( + + + + + ))} + ))} - - ))} - - {mAccount.map((mGroup, index) => ( - - {mGroup.map(menu => ( - - - - - ))} - - ))} - - {mStatus.map((mGroup, index) => ( - - {mGroup.map(menu => ( - - - - - ))} - + ))} diff --git a/src/components/Timeline/Shared/HeaderNotification.tsx b/src/components/Timeline/Shared/HeaderNotification.tsx index 171148ff..47974d03 100644 --- a/src/components/Timeline/Shared/HeaderNotification.tsx +++ b/src/components/Timeline/Shared/HeaderNotification.tsx @@ -90,48 +90,19 @@ const TimelineHeaderNotification: React.FC = ({ notification }) => { - {mShare.map((mGroup, index) => ( - - {mGroup.map(menu => ( - - - - + {[mShare, mStatus, mAccount, mInstance].map(type => ( + <> + {type.map((mGroup, index) => ( + + {mGroup.map(menu => ( + + + + + ))} + ))} - - ))} - - {mAccount.map((mGroup, index) => ( - - {mGroup.map(menu => ( - - - - - ))} - - ))} - - {mStatus.map((mGroup, index) => ( - - {mGroup.map(menu => ( - - - - - ))} - - ))} - - {mInstance.map((mGroup, index) => ( - - {mGroup.map(menu => ( - - - - - ))} - + ))} diff --git a/src/components/contextMenu/status.ts b/src/components/contextMenu/status.ts index a6b73254..7f32143a 100644 --- a/src/components/contextMenu/status.ts +++ b/src/components/contextMenu/status.ts @@ -62,187 +62,185 @@ const menuStatus = ({ const canEditPost = useSelector(checkInstanceFeature('edit_post')) - if (ownAccount) { - menus.push([ - { - key: 'status-edit', - item: { - onSelect: async () => { - let replyToStatus: Mastodon.Status | undefined = undefined - if (status.in_reply_to_id) { - replyToStatus = await apiInstance({ - method: 'get', - url: `statuses/${status.in_reply_to_id}` - }).then(res => res.body) - } - apiInstance<{ - id: Mastodon.Status['id'] - text: NonNullable - spoiler_text: Mastodon.Status['spoiler_text'] - }>({ + menus.push([ + { + key: 'status-edit', + item: { + onSelect: async () => { + let replyToStatus: Mastodon.Status | undefined = undefined + if (status.in_reply_to_id) { + replyToStatus = await apiInstance({ method: 'get', - url: `statuses/${status.id}/source` - }).then(res => { - navigation.navigate('Screen-Compose', { - type: 'edit', - incomingStatus: { - ...status, - text: res.body.text, - spoiler_text: res.body.spoiler_text - }, - ...(replyToStatus && { replyToStatus }), - queryKey, - rootQueryKey - }) + url: `statuses/${status.in_reply_to_id}` + }).then(res => res.body) + } + apiInstance<{ + id: Mastodon.Status['id'] + text: NonNullable + spoiler_text: Mastodon.Status['spoiler_text'] + }>({ + method: 'get', + url: `statuses/${status.id}/source` + }).then(res => { + navigation.navigate('Screen-Compose', { + type: 'edit', + incomingStatus: { + ...status, + text: res.body.text, + spoiler_text: res.body.spoiler_text + }, + ...(replyToStatus && { replyToStatus }), + queryKey, + rootQueryKey }) - }, - disabled: false, - destructive: false, - hidden: !canEditPost + }) }, - title: t('componentContextMenu:status.edit.action'), - icon: 'square.and.pencil' + disabled: false, + destructive: false, + hidden: !ownAccount || !canEditPost }, - { - key: 'status-delete-edit', - item: { - onSelect: () => - 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({ - 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 - }) - }) + title: t('componentContextMenu:status.edit.action'), + icon: 'square.and.pencil' + }, + { + key: 'status-delete-edit', + item: { + onSelect: () => + 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({ + method: 'get', + url: `statuses/${status.in_reply_to_id}` + }).then(res => res.body) } - }, - { - text: t('common:buttons.cancel') - } - ] - ), - disabled: false, - destructive: true, - hidden: false - }, - title: t('componentContextMenu:status.deleteEdit.action'), - icon: 'pencil.and.outline' - }, - { - key: 'status-delete', - item: { - onSelect: () => - 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({ + mutation + .mutateAsync({ type: 'deleteItem', source: 'statuses', queryKey, - rootQueryKey, id: status.id }) - } - }, - { - text: t('common:buttons.cancel'), - style: 'default' + .then(res => { + navigation.navigate('Screen-Compose', { + type: 'deleteEdit', + incomingStatus: res.body as Mastodon.Status, + ...(replyToStatus && { replyToStatus }), + queryKey + }) + }) } - ] - ), - disabled: false, - destructive: true, - hidden: false - }, - title: t('componentContextMenu:status.delete.action'), - icon: 'trash' - } - ]) - - menus.push([ - { - key: 'status-mute', - item: { - onSelect: () => - mutation.mutate({ - type: 'updateStatusProperty', - queryKey, - rootQueryKey, - id: status.id, - payload: { - property: 'muted', - currentValue: status.muted, - propertyCount: undefined, - countValue: undefined + }, + { + text: t('common:buttons.cancel') } - }), - disabled: false, - destructive: false, - hidden: false - }, - title: t('componentContextMenu:status.mute.action', { - defaultValue: 'false', - context: (status.muted || false).toString() - }), - icon: status.muted ? 'speaker' : 'speaker.slash' + ] + ), + disabled: false, + destructive: true, + hidden: !ownAccount }, - { - key: 'status-pin', - item: { - onSelect: () => - // Also note that reblogs cannot be pinned. - mutation.mutate({ - type: 'updateStatusProperty', - queryKey, - rootQueryKey, - id: status.id, - payload: { - property: 'pinned', - currentValue: status.pinned, - propertyCount: undefined, - countValue: undefined + title: t('componentContextMenu:status.deleteEdit.action'), + icon: 'pencil.and.outline' + }, + { + key: 'status-delete', + item: { + onSelect: () => + 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' } - }), - disabled: false, - destructive: false, - hidden: status.visibility !== 'public' && status.visibility !== 'unlisted' - }, - title: t('componentContextMenu:status.pin.action', { - defaultValue: 'false', - context: (status.pinned || false).toString() - }), - icon: status.pinned ? 'pin.slash' : 'pin' - } - ]) - } + ] + ), + disabled: false, + destructive: true, + hidden: !ownAccount + }, + title: t('componentContextMenu:status.delete.action'), + icon: 'trash' + } + ]) + + menus.push([ + { + key: 'status-mute', + item: { + onSelect: () => + mutation.mutate({ + type: 'updateStatusProperty', + queryKey, + rootQueryKey, + id: status.id, + payload: { + property: 'muted', + currentValue: status.muted + } + }), + disabled: false, + destructive: false, + hidden: + !ownAccount && + !status.mentions.filter(mention => mention.id === instanceAccount.id).length + }, + title: t('componentContextMenu:status.mute.action', { + defaultValue: 'false', + context: (status.muted || false).toString() + }), + icon: status.muted ? 'speaker' : 'speaker.slash' + }, + { + key: 'status-pin', + item: { + onSelect: () => + // Also note that reblogs cannot be pinned. + mutation.mutate({ + type: 'updateStatusProperty', + queryKey, + rootQueryKey, + id: status.id, + payload: { + property: 'pinned', + currentValue: status.pinned, + propertyCount: undefined, + countValue: undefined + } + }), + disabled: false, + destructive: false, + hidden: !ownAccount || (status.visibility !== 'public' && status.visibility !== 'unlisted') + }, + title: t('componentContextMenu:status.pin.action', { + defaultValue: 'false', + context: (status.pinned || false).toString() + }), + icon: status.pinned ? 'pin.slash' : 'pin' + } + ]) return menus } diff --git a/src/screens/Tabs/Local/Root.tsx b/src/screens/Tabs/Local/Root.tsx index 8b010710..5ec43852 100644 --- a/src/screens/Tabs/Local/Root.tsx +++ b/src/screens/Tabs/Local/Root.tsx @@ -96,7 +96,7 @@ const Root: React.FC - + ( - + )) : undefined} diff --git a/src/screens/Tabs/Me/List/index.tsx b/src/screens/Tabs/Me/List/index.tsx index f71e7c3e..a3c66511 100644 --- a/src/screens/Tabs/Me/List/index.tsx +++ b/src/screens/Tabs/Me/List/index.tsx @@ -55,24 +55,14 @@ const TabMeList: React.FC> = ({ - - - - - - - - - - - - - - - - - - + {[listAccounts, listEdit, listDelete].map((menu, index) => ( + + + + + + + ))} ) diff --git a/src/screens/Tabs/Shared/Account.tsx b/src/screens/Tabs/Shared/Account.tsx index 9e85b997..3dc058fb 100644 --- a/src/screens/Tabs/Shared/Account.tsx +++ b/src/screens/Tabs/Shared/Account.tsx @@ -55,26 +55,19 @@ const TabSharedAccount: React.FC - {mShare.map((mGroup, index) => ( - - {mGroup.map(menu => ( - - - - + {[mShare, mAccount].map(type => ( + <> + {type.map((mGroup, index) => ( + + {mGroup.map(menu => ( + + + + + ))} + ))} - - ))} - - {mAccount.map((mGroup, index) => ( - - {mGroup.map(menu => ( - - - - - ))} - + ))} diff --git a/src/utils/queryHooks/timeline.ts b/src/utils/queryHooks/timeline.ts index d044905e..1dd7b395 100644 --- a/src/utils/queryHooks/timeline.ts +++ b/src/utils/queryHooks/timeline.ts @@ -273,8 +273,8 @@ export type MutationVarsTimelineUpdateStatusProperty = { | { property: 'bookmarked' | 'muted' | 'pinned' currentValue: boolean - propertyCount: undefined - countValue: undefined + propertyCount?: undefined + countValue?: undefined } | { property: 'favourited'