diff --git a/src/@types/i18next.d.ts b/src/@types/i18next.d.ts index 0eebc410..ebce9f85 100644 --- a/src/@types/i18next.d.ts +++ b/src/@types/i18next.d.ts @@ -4,7 +4,6 @@ import common from '../i18n/en/common.json' import screens from '../i18n/en/screens.json' import screenAccountSelection from '../i18n/en/screens/accountSelection.json' -import screenActions from '../i18n/en/screens/actions.json' import screenAnnouncements from '../i18n/en/screens/announcements.json' import screenCompose from '../i18n/en/screens/compose.json' import screenImageViewer from '../i18n/en/screens/imageViewer.json' @@ -26,7 +25,6 @@ declare module 'i18next' { screens: typeof screens screenAccountSelection: typeof screenAccountSelection - screenActions: typeof screenActions screenAnnouncements: typeof screenAnnouncements screenCompose: typeof screenCompose screenImageViewer: typeof screenImageViewer diff --git a/src/@types/mastodon.d.ts b/src/@types/mastodon.d.ts index d2a83751..ca936344 100644 --- a/src/@types/mastodon.d.ts +++ b/src/@types/mastodon.d.ts @@ -552,6 +552,10 @@ declare namespace Mastodon { language?: string text?: string filtered?: FilterResult[] + + // Internal + _level?: number + _remote?: boolean } type StatusHistory = { diff --git a/src/components/Parse/HTML.tsx b/src/components/Parse/HTML.tsx index 246f839a..18bdd497 100644 --- a/src/components/Parse/HTML.tsx +++ b/src/components/Parse/HTML.tsx @@ -168,7 +168,10 @@ const ParseHTML: React.FC = ({ matchedMention && !disableDetails && !sameAccount && - navigation.push('Tab-Shared-Account', { account: matchedMention }) + navigation.push('Tab-Shared-Account', { + account: matchedMention, + isRemote: status?._remote + }) } children={node.children.map(unwrapNode).join('')} /> diff --git a/src/components/Timeline/Default.tsx b/src/components/Timeline/Default.tsx index ae264a35..48725b8a 100644 --- a/src/components/Timeline/Default.tsx +++ b/src/components/Timeline/Default.tsx @@ -87,9 +87,9 @@ const TimelineDefault: React.FC = ({ const main = () => ( <> {item.reblog ? ( - + ) : item._pinned ? ( - + ) : null} = ({ queryKey, rootQueryKey, status, - reblogStatus: item.reblog ? item : undefined, ownAccount, spoilerHidden, rawContent, diff --git a/src/components/Timeline/Notifications.tsx b/src/components/Timeline/Notifications.tsx index f82332f4..75b7b030 100644 --- a/src/components/Timeline/Notifications.tsx +++ b/src/components/Timeline/Notifications.tsx @@ -61,6 +61,7 @@ const TimelineNotifications: React.FC = ({ notification, queryKey }) => { action={notification.type} isNotification account={notification.account} + rootStatus={notification.status} /> ) : null} diff --git a/src/components/Timeline/Shared/Actioned.tsx b/src/components/Timeline/Shared/Actioned.tsx index 8e73de69..d6446a31 100644 --- a/src/components/Timeline/Shared/Actioned.tsx +++ b/src/components/Timeline/Shared/Actioned.tsx @@ -14,11 +14,12 @@ export interface Props { action: Mastodon.Notification['type'] | 'reblog' | 'pinned' isNotification?: boolean account?: Mastodon.Account // For notification + rootStatus?: Mastodon.Status } const TimelineActioned: React.FC = ({ action, isNotification, ...rest }) => { - const { status, reblogStatus } = useContext(StatusContext) - const account = rest.account || (reblogStatus ? reblogStatus.account : status?.account) + const { status } = useContext(StatusContext) + const account = rest.account || (rest.rootStatus || status)?.account if (!account) return null const { t } = useTranslation('componentTimeline') @@ -36,7 +37,8 @@ const TimelineActioned: React.FC = ({ action, isNotification, ...rest }) /> ) - const onPress = () => navigation.push('Tab-Shared-Account', { account }) + const onPress = () => + navigation.push('Tab-Shared-Account', { account, isRemote: status?._remote }) const children = () => { switch (action) { diff --git a/src/components/Timeline/Shared/Actions.tsx b/src/components/Timeline/Shared/Actions.tsx index 503bd97a..7df190f0 100644 --- a/src/components/Timeline/Shared/Actions.tsx +++ b/src/components/Timeline/Shared/Actions.tsx @@ -22,7 +22,7 @@ import { Pressable, StyleSheet, View } from 'react-native' import StatusContext from './Context' const TimelineActions: React.FC = () => { - const { queryKey, rootQueryKey, status, reblogStatus, ownAccount, highlighted, disableDetails } = + const { queryKey, rootQueryKey, status, ownAccount, highlighted, disableDetails } = useContext(StatusContext) if (!queryKey || !status || disableDetails) return null @@ -38,16 +38,16 @@ const TimelineActions: React.FC = () => { const theParams = params as MutationVarsTimelineUpdateStatusProperty if ( // Un-bookmark from bookmarks page - (queryKey[1].page === 'Bookmarks' && theParams.payload.property === 'bookmarked') || + (queryKey[1].page === 'Bookmarks' && theParams.payload.type === 'bookmarked') || // Un-favourite from favourites page - (queryKey[1].page === 'Favourites' && theParams.payload.property === 'favourited') + (queryKey[1].page === 'Favourites' && theParams.payload.type === 'favourited') ) { queryClient.invalidateQueries(queryKey) - } else if (theParams.payload.property === 'favourited') { + } else if (theParams.payload.type === 'favourited') { // When favourited, update favourited page const tempQueryKey: QueryKeyTimeline = ['Timeline', { page: 'Favourites' }] queryClient.invalidateQueries(tempQueryKey) - } else if (theParams.payload.property === 'bookmarked') { + } else if (theParams.payload.type === 'bookmarked') { // When bookmarked, update bookmark page const tempQueryKey: QueryKeyTimeline = ['Timeline', { page: 'Bookmarks' }] queryClient.invalidateQueries(tempQueryKey) @@ -60,7 +60,7 @@ const TimelineActions: React.FC = () => { type: 'error', message: t('common:message.error.message', { function: t( - `componentTimeline:shared.actions.${correctParam.payload.property}.function` as any + `componentTimeline:shared.actions.${correctParam.payload.type}.function` as any ) }), ...(err.status && @@ -111,13 +111,9 @@ const TimelineActions: React.FC = () => { type: 'updateStatusProperty', queryKey, rootQueryKey, - id: status.id, - isReblog: !!reblogStatus, + status, payload: { - property: 'reblogged', - currentValue: status.reblogged, - propertyCount: 'reblogs_count', - countValue: status.reblogs_count, + type: 'reblogged', visibility: 'public' } }) @@ -127,13 +123,9 @@ const TimelineActions: React.FC = () => { type: 'updateStatusProperty', queryKey, rootQueryKey, - id: status.id, - isReblog: !!reblogStatus, + status, payload: { - property: 'reblogged', - currentValue: status.reblogged, - propertyCount: 'reblogs_count', - countValue: status.reblogs_count, + type: 'reblogged', visibility: 'unlisted' } }) @@ -146,13 +138,9 @@ const TimelineActions: React.FC = () => { type: 'updateStatusProperty', queryKey, rootQueryKey, - id: status.id, - isReblog: !!reblogStatus, + status, payload: { - property: 'reblogged', - currentValue: status.reblogged, - propertyCount: 'reblogs_count', - countValue: status.reblogs_count, + type: 'reblogged', visibility: 'public' } }) @@ -163,13 +151,9 @@ const TimelineActions: React.FC = () => { type: 'updateStatusProperty', queryKey, rootQueryKey, - id: status.id, - isReblog: !!reblogStatus, + status, payload: { - property: 'favourited', - currentValue: status.favourited, - propertyCount: 'favourites_count', - countValue: status.favourites_count + type: 'favourited' } }) } @@ -178,13 +162,9 @@ const TimelineActions: React.FC = () => { type: 'updateStatusProperty', queryKey, rootQueryKey, - id: status.id, - isReblog: !!reblogStatus, + status, payload: { - property: 'bookmarked', - currentValue: status.bookmarked, - propertyCount: undefined, - countValue: undefined + type: 'bookmarked' } }) } diff --git a/src/components/Timeline/Shared/Attachment/AltText.tsx b/src/components/Timeline/Shared/Attachment/AltText.tsx index ce1bf2a6..bd108545 100644 --- a/src/components/Timeline/Shared/Attachment/AltText.tsx +++ b/src/components/Timeline/Shared/Attachment/AltText.tsx @@ -1,8 +1,7 @@ import Button from '@components/Button' -import { useNavigation } from '@react-navigation/native' -import { StackNavigationProp } from '@react-navigation/stack' -import { RootStackParamList } from '@utils/navigation/navigators' import { StyleConstants } from '@utils/styles/constants' +import { useTranslation } from 'react-i18next' +import { Alert } from 'react-native' export interface Props { sensitiveShown: boolean @@ -14,7 +13,7 @@ const AttachmentAltText: React.FC = ({ sensitiveShown, text }) => { return null } - const navigation = useNavigation>() + const { t } = useTranslation('componentTimeline') return !sensitiveShown ? (