mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Believe #638 can be closed now!
This commit is contained in:
@ -41,10 +41,7 @@ const TimelineConversation: React.FC<Props> = ({ conversation, queryKey, highlig
|
||||
const onPress = useCallback(() => {
|
||||
if (conversation.last_status) {
|
||||
conversation.unread && mutate()
|
||||
navigation.push('Tab-Shared-Toot', {
|
||||
toot: conversation.last_status,
|
||||
rootQueryKey: queryKey
|
||||
})
|
||||
navigation.push('Tab-Shared-Toot', { toot: conversation.last_status })
|
||||
}
|
||||
}, [])
|
||||
|
||||
|
@ -32,7 +32,6 @@ import TimelineTranslate from './Shared/Translate'
|
||||
export interface Props {
|
||||
item: Mastodon.Status & { _pinned?: boolean } // For account page, internal property
|
||||
queryKey?: QueryKeyTimeline
|
||||
rootQueryKey?: QueryKeyTimeline
|
||||
highlighted?: boolean
|
||||
disableDetails?: boolean
|
||||
disableOnPress?: boolean
|
||||
@ -43,7 +42,6 @@ export interface Props {
|
||||
const TimelineDefault: React.FC<Props> = ({
|
||||
item,
|
||||
queryKey,
|
||||
rootQueryKey,
|
||||
highlighted = false,
|
||||
disableDetails = false,
|
||||
disableOnPress = false,
|
||||
@ -131,8 +129,8 @@ const TimelineDefault: React.FC<Props> = ({
|
||||
url: status.url || status.uri,
|
||||
rawContent
|
||||
})
|
||||
const mStatus = menuStatus({ status, queryKey, rootQueryKey })
|
||||
const mInstance = menuInstance({ status, queryKey, rootQueryKey })
|
||||
const mStatus = menuStatus({ status, queryKey })
|
||||
const mInstance = menuInstance({ status, queryKey })
|
||||
|
||||
if (!ownAccount) {
|
||||
let filterResults: FilteredProps['filterResults'] = []
|
||||
@ -163,7 +161,6 @@ const TimelineDefault: React.FC<Props> = ({
|
||||
<StatusContext.Provider
|
||||
value={{
|
||||
queryKey,
|
||||
rootQueryKey,
|
||||
status,
|
||||
ownAccount,
|
||||
spoilerHidden,
|
||||
@ -188,12 +185,7 @@ const TimelineDefault: React.FC<Props> = ({
|
||||
accessible={highlighted ? false : true}
|
||||
style={mainStyle}
|
||||
disabled={highlighted}
|
||||
onPress={() =>
|
||||
navigation.push('Tab-Shared-Toot', {
|
||||
toot: status,
|
||||
rootQueryKey: queryKey
|
||||
})
|
||||
}
|
||||
onPress={() => navigation.push('Tab-Shared-Toot', { toot: status })}
|
||||
onLongPress={() => {}}
|
||||
children={main()}
|
||||
/>
|
||||
|
@ -154,10 +154,7 @@ const TimelineNotifications: React.FC<Props> = ({ notification, queryKey }) => {
|
||||
}}
|
||||
onPress={() =>
|
||||
notification.status &&
|
||||
navigation.push('Tab-Shared-Toot', {
|
||||
toot: notification.status,
|
||||
rootQueryKey: queryKey
|
||||
})
|
||||
navigation.push('Tab-Shared-Toot', { toot: notification.status })
|
||||
}
|
||||
onLongPress={() => {}}
|
||||
children={main()}
|
||||
|
@ -6,7 +6,7 @@ import { useNavigation } from '@react-navigation/native'
|
||||
import { StackNavigationProp } from '@react-navigation/stack'
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
import { androidActionSheetStyles } from '@utils/helpers/androidActionSheetStyles'
|
||||
import { RootStackParamList } from '@utils/navigation/navigators'
|
||||
import { RootStackParamList, useNavState } from '@utils/navigation/navigators'
|
||||
import {
|
||||
MutationVarsTimelineUpdateStatusProperty,
|
||||
QueryKeyTimeline,
|
||||
@ -22,10 +22,10 @@ import { Pressable, StyleSheet, View } from 'react-native'
|
||||
import StatusContext from './Context'
|
||||
|
||||
const TimelineActions: React.FC = () => {
|
||||
const { queryKey, rootQueryKey, status, ownAccount, highlighted, disableDetails } =
|
||||
useContext(StatusContext)
|
||||
const { queryKey, status, ownAccount, highlighted, disableDetails } = useContext(StatusContext)
|
||||
if (!queryKey || !status || disableDetails) return null
|
||||
|
||||
const navigationState = useNavState()
|
||||
const navigation = useNavigation<StackNavigationProp<RootStackParamList>>()
|
||||
const { t } = useTranslation(['common', 'componentTimeline'])
|
||||
const { colors, theme } = useTheme()
|
||||
@ -87,7 +87,7 @@ const TimelineActions: React.FC = () => {
|
||||
type: 'reply',
|
||||
incomingStatus: status,
|
||||
accts,
|
||||
queryKey
|
||||
navigationState
|
||||
})
|
||||
}
|
||||
const { showActionSheetWithOptions } = useActionSheet()
|
||||
@ -109,8 +109,6 @@ const TimelineActions: React.FC = () => {
|
||||
case 0:
|
||||
mutation.mutate({
|
||||
type: 'updateStatusProperty',
|
||||
queryKey,
|
||||
rootQueryKey,
|
||||
status,
|
||||
payload: {
|
||||
type: 'reblogged',
|
||||
@ -122,8 +120,6 @@ const TimelineActions: React.FC = () => {
|
||||
case 1:
|
||||
mutation.mutate({
|
||||
type: 'updateStatusProperty',
|
||||
queryKey,
|
||||
rootQueryKey,
|
||||
status,
|
||||
payload: {
|
||||
type: 'reblogged',
|
||||
@ -138,8 +134,6 @@ const TimelineActions: React.FC = () => {
|
||||
} else {
|
||||
mutation.mutate({
|
||||
type: 'updateStatusProperty',
|
||||
queryKey,
|
||||
rootQueryKey,
|
||||
status,
|
||||
payload: {
|
||||
type: 'reblogged',
|
||||
@ -152,8 +146,6 @@ const TimelineActions: React.FC = () => {
|
||||
const onPressFavourite = () => {
|
||||
mutation.mutate({
|
||||
type: 'updateStatusProperty',
|
||||
queryKey,
|
||||
rootQueryKey,
|
||||
status,
|
||||
payload: {
|
||||
type: 'favourited',
|
||||
@ -164,8 +156,6 @@ const TimelineActions: React.FC = () => {
|
||||
const onPressBookmark = () => {
|
||||
mutation.mutate({
|
||||
type: 'updateStatusProperty',
|
||||
queryKey,
|
||||
rootQueryKey,
|
||||
status,
|
||||
payload: {
|
||||
type: 'bookmarked',
|
||||
|
@ -5,7 +5,6 @@ export type HighlightedStatusContextType = {}
|
||||
|
||||
type StatusContextType = {
|
||||
queryKey?: QueryKeyTimeline
|
||||
rootQueryKey?: QueryKeyTimeline
|
||||
|
||||
status?: Mastodon.Status
|
||||
|
||||
|
@ -10,7 +10,7 @@ import * as DropdownMenu from 'zeego/dropdown-menu'
|
||||
import StatusContext from './Context'
|
||||
|
||||
const TimelineHeaderAndroid: React.FC = () => {
|
||||
const { queryKey, rootQueryKey, status, disableDetails, disableOnPress, rawContent } =
|
||||
const { queryKey, status, disableDetails, disableOnPress, rawContent } =
|
||||
useContext(StatusContext)
|
||||
|
||||
if (Platform.OS !== 'android' || !status || disableDetails || disableOnPress) return null
|
||||
@ -28,10 +28,9 @@ const TimelineHeaderAndroid: React.FC = () => {
|
||||
type: 'status',
|
||||
openChange,
|
||||
account: status.account,
|
||||
...(status && { status }),
|
||||
queryKey
|
||||
...(status && { status })
|
||||
})
|
||||
const mStatus = menuStatus({ status, queryKey, rootQueryKey })
|
||||
const mStatus = menuStatus({ status, queryKey })
|
||||
|
||||
return (
|
||||
<View style={{ position: 'absolute', top: 0, right: 0 }}>
|
||||
|
@ -84,7 +84,6 @@ const HeaderConversation = ({ conversation }: Props) => {
|
||||
mutation.mutate({
|
||||
type: 'deleteItem',
|
||||
source: 'conversations',
|
||||
queryKey,
|
||||
id: conversation.id
|
||||
})
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ import HeaderSharedReplies from './HeaderShared/Replies'
|
||||
import HeaderSharedVisibility from './HeaderShared/Visibility'
|
||||
|
||||
const TimelineHeaderDefault: React.FC = () => {
|
||||
const { queryKey, rootQueryKey, status, disableDetails, rawContent, isRemote } =
|
||||
const { queryKey, status, disableDetails, rawContent, isRemote } =
|
||||
useContext(StatusContext)
|
||||
if (!status) return null
|
||||
|
||||
@ -35,10 +35,9 @@ const TimelineHeaderDefault: React.FC = () => {
|
||||
type: 'status',
|
||||
openChange,
|
||||
account: status.account,
|
||||
...(status && { status }),
|
||||
queryKey
|
||||
...(status && { status })
|
||||
})
|
||||
const mStatus = menuStatus({ status, queryKey, rootQueryKey })
|
||||
const mStatus = menuStatus({ status, queryKey })
|
||||
|
||||
return (
|
||||
<View style={{ flex: 1, flexDirection: 'row' }}>
|
||||
|
@ -41,8 +41,7 @@ const TimelineHeaderNotification: React.FC<Props> = ({ notification }) => {
|
||||
type: 'status',
|
||||
openChange,
|
||||
account: status?.account,
|
||||
...(status && { status }),
|
||||
queryKey
|
||||
...(status && { status })
|
||||
})
|
||||
const mStatus = menuStatus({ status, queryKey })
|
||||
const mInstance = menuInstance({ status, queryKey })
|
||||
|
@ -6,6 +6,7 @@ import { ParseEmojis } from '@components/Parse'
|
||||
import RelativeTime from '@components/RelativeTime'
|
||||
import CustomText from '@components/Text'
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
import { useNavState } from '@utils/navigation/navigators'
|
||||
import {
|
||||
MutationVarsTimelineUpdateStatusProperty,
|
||||
useTimelineMutation
|
||||
@ -20,8 +21,7 @@ import { Pressable, View } from 'react-native'
|
||||
import StatusContext from './Context'
|
||||
|
||||
const TimelinePoll: React.FC = () => {
|
||||
const { queryKey, rootQueryKey, status, ownAccount, spoilerHidden, disableDetails } =
|
||||
useContext(StatusContext)
|
||||
const { queryKey, status, ownAccount, spoilerHidden, disableDetails } = useContext(StatusContext)
|
||||
if (!queryKey || !status || !status.poll) return null
|
||||
const poll = status.poll
|
||||
|
||||
@ -30,17 +30,20 @@ const TimelinePoll: React.FC = () => {
|
||||
|
||||
const [allOptions, setAllOptions] = useState(new Array(status.poll.options.length).fill(false))
|
||||
|
||||
const navigationState = useNavState()
|
||||
const queryClient = useQueryClient()
|
||||
const mutation = useTimelineMutation({
|
||||
onSuccess: ({ body }, params) => {
|
||||
const theParams = params as MutationVarsTimelineUpdateStatusProperty
|
||||
queryClient.cancelQueries(queryKey)
|
||||
rootQueryKey && queryClient.cancelQueries(rootQueryKey)
|
||||
|
||||
haptics('Success')
|
||||
switch (theParams.payload.type) {
|
||||
case 'poll':
|
||||
updateStatusProperty({ ...theParams, poll: body as unknown as Mastodon.Poll })
|
||||
updateStatusProperty(
|
||||
{ ...theParams, poll: body as unknown as Mastodon.Poll },
|
||||
navigationState
|
||||
)
|
||||
break
|
||||
}
|
||||
},
|
||||
@ -74,8 +77,6 @@ const TimelinePoll: React.FC = () => {
|
||||
onPress={() =>
|
||||
mutation.mutate({
|
||||
type: 'updateStatusProperty',
|
||||
queryKey,
|
||||
rootQueryKey,
|
||||
status,
|
||||
payload: {
|
||||
type: 'poll',
|
||||
@ -98,8 +99,6 @@ const TimelinePoll: React.FC = () => {
|
||||
onPress={() =>
|
||||
mutation.mutate({
|
||||
type: 'updateStatusProperty',
|
||||
queryKey,
|
||||
rootQueryKey,
|
||||
status,
|
||||
payload: {
|
||||
type: 'poll',
|
||||
|
@ -3,7 +3,7 @@ import { displayMessage } from '@components/Message'
|
||||
import { useNavigation } from '@react-navigation/native'
|
||||
import { NativeStackNavigationProp } from '@react-navigation/native-stack'
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
import { TabSharedStackParamList } from '@utils/navigation/navigators'
|
||||
import { TabSharedStackParamList, useNavState } from '@utils/navigation/navigators'
|
||||
import { useAccountQuery } from '@utils/queryHooks/account'
|
||||
import {
|
||||
QueryKeyRelationship,
|
||||
@ -12,7 +12,6 @@ import {
|
||||
} from '@utils/queryHooks/relationship'
|
||||
import {
|
||||
MutationVarsTimelineUpdateAccountProperty,
|
||||
QueryKeyTimeline,
|
||||
useTimelineMutation
|
||||
} from '@utils/queryHooks/timeline'
|
||||
import { useAccountStorage } from '@utils/storage/actions'
|
||||
@ -24,19 +23,16 @@ const menuAccount = ({
|
||||
type,
|
||||
openChange,
|
||||
account,
|
||||
status,
|
||||
queryKey,
|
||||
rootQueryKey
|
||||
status
|
||||
}: {
|
||||
type: 'status' | 'account' // Where the action is coming from
|
||||
openChange: boolean
|
||||
account?: Partial<Mastodon.Account> & Pick<Mastodon.Account, 'id' | 'username' | 'acct' | 'url'>
|
||||
status?: Mastodon.Status
|
||||
queryKey?: QueryKeyTimeline
|
||||
rootQueryKey?: QueryKeyTimeline
|
||||
}): ContextMenu[][] => {
|
||||
const navigation =
|
||||
useNavigation<NativeStackNavigationProp<TabSharedStackParamList, any, undefined>>()
|
||||
const navState = useNavState()
|
||||
const { t } = useTranslation(['common', 'componentContextMenu', 'componentRelationship'])
|
||||
|
||||
const menus: ContextMenu[][] = [[]]
|
||||
@ -101,8 +97,9 @@ const menuAccount = ({
|
||||
})
|
||||
},
|
||||
onSettled: () => {
|
||||
queryKey && queryClient.invalidateQueries(queryKey)
|
||||
rootQueryKey && queryClient.invalidateQueries(rootQueryKey)
|
||||
for (const key of navState) {
|
||||
queryClient.invalidateQueries(key)
|
||||
}
|
||||
}
|
||||
})
|
||||
const queryKeyRelationship: QueryKeyRelationship = ['Relationship', { id: actualAccount?.id }]
|
||||
@ -111,8 +108,10 @@ const menuAccount = ({
|
||||
haptics('Success')
|
||||
queryClient.setQueryData<Mastodon.Relationship[]>(queryKeyRelationship, [res])
|
||||
if (action === 'block') {
|
||||
const queryKey = ['Timeline', { page: 'Following' }]
|
||||
queryClient.invalidateQueries({ queryKey, exact: false })
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['Timeline', { page: 'Following' }],
|
||||
exact: false
|
||||
})
|
||||
}
|
||||
},
|
||||
onError: (err: any, { payload: { action } }) => {
|
||||
@ -203,7 +202,6 @@ const menuAccount = ({
|
||||
actualAccount &&
|
||||
timelineMutation.mutate({
|
||||
type: 'updateAccountProperty',
|
||||
queryKey,
|
||||
id: actualAccount.id,
|
||||
payload: { property: 'mute', currentValue: data?.muting }
|
||||
}),
|
||||
@ -236,7 +234,6 @@ const menuAccount = ({
|
||||
actualAccount &&
|
||||
timelineMutation.mutate({
|
||||
type: 'updateAccountProperty',
|
||||
queryKey,
|
||||
id: actualAccount.id,
|
||||
payload: { property: 'block', currentValue: data?.blocking }
|
||||
})
|
||||
|
@ -8,12 +8,10 @@ import parse from 'url-parse'
|
||||
|
||||
const menuInstance = ({
|
||||
status,
|
||||
queryKey,
|
||||
rootQueryKey
|
||||
queryKey
|
||||
}: {
|
||||
status?: Mastodon.Status
|
||||
queryKey?: QueryKeyTimeline
|
||||
rootQueryKey?: QueryKeyTimeline
|
||||
}): ContextMenu[][] => {
|
||||
if (!status || !queryKey) return []
|
||||
|
||||
@ -29,7 +27,6 @@ const menuInstance = ({
|
||||
})
|
||||
})
|
||||
queryClient.invalidateQueries(queryKey)
|
||||
rootQueryKey && queryClient.invalidateQueries(rootQueryKey)
|
||||
}
|
||||
})
|
||||
|
||||
@ -51,11 +48,7 @@ const menuInstance = ({
|
||||
text: t('common:buttons.confirm'),
|
||||
style: 'destructive',
|
||||
onPress: () => {
|
||||
mutation.mutate({
|
||||
type: 'domainBlock',
|
||||
queryKey,
|
||||
domain: instance
|
||||
})
|
||||
mutation.mutate({ type: 'domainBlock', domain: instance })
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -4,7 +4,7 @@ import { NativeStackNavigationProp } from '@react-navigation/native-stack'
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
import apiInstance from '@utils/api/instance'
|
||||
import { featureCheck } from '@utils/helpers/featureCheck'
|
||||
import { RootStackParamList } from '@utils/navigation/navigators'
|
||||
import { RootStackParamList, useNavState } from '@utils/navigation/navigators'
|
||||
import {
|
||||
MutationVarsTimelineUpdateStatusProperty,
|
||||
QueryKeyTimeline,
|
||||
@ -17,12 +17,10 @@ import { Alert } from 'react-native'
|
||||
|
||||
const menuStatus = ({
|
||||
status,
|
||||
queryKey,
|
||||
rootQueryKey
|
||||
queryKey
|
||||
}: {
|
||||
status?: Mastodon.Status
|
||||
queryKey?: QueryKeyTimeline
|
||||
rootQueryKey?: QueryKeyTimeline
|
||||
}): ContextMenu[][] => {
|
||||
if (!status || !queryKey) return []
|
||||
|
||||
@ -30,6 +28,8 @@ const menuStatus = ({
|
||||
const { theme } = useTheme()
|
||||
const { t } = useTranslation(['common', 'componentContextMenu'])
|
||||
|
||||
const navigationState = useNavState()
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const mutation = useTimelineMutation({
|
||||
onMutate: true,
|
||||
@ -90,8 +90,7 @@ const menuStatus = ({
|
||||
spoiler_text: res.body.spoiler_text
|
||||
},
|
||||
...(replyToStatus && { replyToStatus }),
|
||||
queryKey,
|
||||
rootQueryKey
|
||||
navigationState
|
||||
})
|
||||
})
|
||||
},
|
||||
@ -122,18 +121,13 @@ const menuStatus = ({
|
||||
}).then(res => res.body)
|
||||
}
|
||||
mutation
|
||||
.mutateAsync({
|
||||
type: 'deleteItem',
|
||||
source: 'statuses',
|
||||
queryKey,
|
||||
id: status.id
|
||||
})
|
||||
.mutateAsync({ type: 'deleteItem', source: 'statuses', id: status.id })
|
||||
.then(res => {
|
||||
navigation.navigate('Screen-Compose', {
|
||||
type: 'deleteEdit',
|
||||
incomingStatus: res.body as Mastodon.Status,
|
||||
...(replyToStatus && { replyToStatus }),
|
||||
queryKey
|
||||
navigationState
|
||||
})
|
||||
})
|
||||
}
|
||||
@ -162,13 +156,7 @@ const menuStatus = ({
|
||||
text: t('common:buttons.confirm'),
|
||||
style: 'destructive',
|
||||
onPress: async () => {
|
||||
mutation.mutate({
|
||||
type: 'deleteItem',
|
||||
source: 'statuses',
|
||||
queryKey,
|
||||
rootQueryKey,
|
||||
id: status.id
|
||||
})
|
||||
mutation.mutate({ type: 'deleteItem', source: 'statuses', id: status.id })
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -193,8 +181,6 @@ const menuStatus = ({
|
||||
onSelect: () =>
|
||||
mutation.mutate({
|
||||
type: 'updateStatusProperty',
|
||||
queryKey,
|
||||
rootQueryKey,
|
||||
status,
|
||||
payload: {
|
||||
type: 'muted',
|
||||
@ -218,8 +204,6 @@ const menuStatus = ({
|
||||
// Also note that reblogs cannot be pinned.
|
||||
mutation.mutate({
|
||||
type: 'updateStatusProperty',
|
||||
queryKey,
|
||||
rootQueryKey,
|
||||
status,
|
||||
payload: {
|
||||
type: 'pinned',
|
||||
|
Reference in New Issue
Block a user