mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Properly clean and reset navigators
This commit is contained in:
@ -178,8 +178,6 @@ const Root: React.FC<NativeStackScreenProps<TabLocalStackParamList, 'Tab-Local-R
|
||||
})
|
||||
}, [mode, queryKey[1], pageLocal, lists])
|
||||
|
||||
usePopToTop()
|
||||
|
||||
return (
|
||||
<Timeline
|
||||
queryKey={queryKey}
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { createNativeStackNavigator } from '@react-navigation/native-stack'
|
||||
import { TabLocalStackParamList } from '@utils/navigation/navigators'
|
||||
import usePopToTop from '@utils/navigation/usePopToTop'
|
||||
import React from 'react'
|
||||
import TabShared from '../Shared'
|
||||
import Root from './Root'
|
||||
@ -7,6 +8,7 @@ import Root from './Root'
|
||||
const Stack = createNativeStackNavigator<TabLocalStackParamList>()
|
||||
|
||||
const TabLocal: React.FC = () => {
|
||||
usePopToTop()
|
||||
return (
|
||||
<Stack.Navigator screenOptions={{ headerShadowVisible: false }}>
|
||||
<Stack.Screen name='Tab-Local-Root' component={Root} />
|
||||
|
@ -4,7 +4,6 @@ import TimelineDefault from '@components/Timeline/Default'
|
||||
import SegmentedControl from '@react-native-community/segmented-control'
|
||||
import { NativeStackScreenProps } from '@react-navigation/native-stack'
|
||||
import { TabPublicStackParamList } from '@utils/navigation/navigators'
|
||||
import usePopToTop from '@utils/navigation/usePopToTop'
|
||||
import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
|
||||
import { getGlobalStorage, setGlobalStorage } from '@utils/storage/actions'
|
||||
import { StorageGlobal } from '@utils/storage/global'
|
||||
@ -75,8 +74,6 @@ const Root: React.FC<NativeStackScreenProps<TabPublicStackParamList, 'Tab-Public
|
||||
})
|
||||
}, [mode, segment])
|
||||
|
||||
usePopToTop()
|
||||
|
||||
return (
|
||||
<TabView
|
||||
lazy
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { createNativeStackNavigator } from '@react-navigation/native-stack'
|
||||
import { TabPublicStackParamList } from '@utils/navigation/navigators'
|
||||
import usePopToTop from '@utils/navigation/usePopToTop'
|
||||
import React from 'react'
|
||||
import TabShared from '../Shared'
|
||||
import Root from './Root'
|
||||
@ -7,6 +8,7 @@ import Root from './Root'
|
||||
const Stack = createNativeStackNavigator<TabPublicStackParamList>()
|
||||
|
||||
const TabPublic: React.FC = () => {
|
||||
usePopToTop()
|
||||
return (
|
||||
<Stack.Navigator screenOptions={{ headerShadowVisible: false }}>
|
||||
<Stack.Screen name='Tab-Public-Root' component={Root} />
|
||||
|
@ -145,35 +145,26 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
|
||||
useQuery(
|
||||
queryKey.remote,
|
||||
async () => {
|
||||
let context:
|
||||
| {
|
||||
ancestors: Mastodon.Status[]
|
||||
descendants: Mastodon.Status[]
|
||||
}
|
||||
| undefined
|
||||
const domain = getHost(toot.url || toot.uri)
|
||||
if (!domain?.length) {
|
||||
return Promise.reject('Cannot parse remote doamin')
|
||||
}
|
||||
const id = (toot.url || toot.uri).match(new RegExp(/\/([0-9]+)$/))?.[1]
|
||||
if (!id?.length) {
|
||||
return Promise.reject('Cannot parse remote toot id')
|
||||
}
|
||||
|
||||
try {
|
||||
const domain = getHost(toot.url || toot.uri)
|
||||
if (!domain?.length) {
|
||||
throw new Error()
|
||||
}
|
||||
const id = (toot.url || toot.uri).match(new RegExp(/\/([0-9]+)$/))?.[1]
|
||||
if (!id?.length) {
|
||||
throw new Error()
|
||||
}
|
||||
|
||||
context = await apiGeneral<{
|
||||
ancestors: Mastodon.Status[]
|
||||
descendants: Mastodon.Status[]
|
||||
}>({
|
||||
method: 'get',
|
||||
domain,
|
||||
url: `api/v1/statuses/${id}/context`
|
||||
}).then(res => res.body)
|
||||
} catch {}
|
||||
const context = await apiGeneral<{
|
||||
ancestors: Mastodon.Status[]
|
||||
descendants: Mastodon.Status[]
|
||||
}>({
|
||||
method: 'get',
|
||||
domain,
|
||||
url: `api/v1/statuses/${id}/context`
|
||||
}).then(res => res.body)
|
||||
|
||||
if (!context) {
|
||||
throw new Error()
|
||||
return Promise.reject('Cannot retrieve remote context')
|
||||
}
|
||||
|
||||
const statuses: (Mastodon.Status & { _level?: number })[] = [
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { useNavigation } from '@react-navigation/native'
|
||||
import { StackActions, useFocusEffect, useNavigation } from '@react-navigation/native'
|
||||
import { useGlobalStorage } from '@utils/storage/actions'
|
||||
import { useEffect } from 'react'
|
||||
|
||||
@ -8,8 +8,8 @@ const usePopToTop = () => {
|
||||
const navigation = useNavigation()
|
||||
const [accountActive] = useGlobalStorage.string('account.active')
|
||||
|
||||
return useEffect(() => {
|
||||
// navigation.dispatch(StackActions.popToTop())
|
||||
useEffect(() => {
|
||||
navigation.dispatch(StackActions.popToTop())
|
||||
}, [accountActive])
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,6 @@ const updateStatusProperty = ({
|
||||
if (!key) continue
|
||||
|
||||
queryClient.setQueryData<InfiniteData<TimelineData> | undefined>(key, old => {
|
||||
console.log('key', key)
|
||||
if (old) {
|
||||
let foundToot: Mastodon.Status | undefined = undefined
|
||||
old.pages = old.pages.map(page => {
|
||||
@ -42,7 +41,6 @@ const updateStatusProperty = ({
|
||||
|
||||
if (foundToot) {
|
||||
const toot = foundToot as Mastodon.Status
|
||||
console.log('updating', toot.id)
|
||||
enum MapPropertyToCount {
|
||||
favourited = 'favourites_count',
|
||||
reblogged = 'reblogs_count'
|
||||
@ -53,9 +51,7 @@ const updateStatusProperty = ({
|
||||
toot.poll = poll
|
||||
break
|
||||
default:
|
||||
console.log('11', toot[payload.type])
|
||||
toot[payload.type] = payload.to
|
||||
console.log('22', toot[payload.type])
|
||||
switch (payload.type) {
|
||||
case 'favourited':
|
||||
case 'reblogged':
|
||||
|
@ -212,6 +212,7 @@ export const generateAccountKey = ({
|
||||
export const setAccount = async (account: string) => {
|
||||
storage.account = new MMKV({ id: account })
|
||||
setGlobalStorage('account.active', account)
|
||||
await queryClient.resetQueries()
|
||||
queryClient.clear()
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user