mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Fix #612
This commit is contained in:
@ -54,12 +54,16 @@ const useInstanceQuery = (
|
||||
options?: UseQueryOptions<Mastodon.Instance<any>, AxiosError>
|
||||
}
|
||||
) => {
|
||||
const queryKey: QueryKeyInstance = params?.domain ? ['Instance', params] : ['Instance']
|
||||
const queryKey: QueryKeyInstance = params?.domain
|
||||
? ['Instance', { domain: params.domain }]
|
||||
: ['Instance']
|
||||
return useQuery(queryKey, queryFunction, {
|
||||
...params?.options,
|
||||
staleTime: Infinity,
|
||||
cacheTime: Infinity,
|
||||
onSuccess: data => setAccountStorage([{ key: 'version', value: data.version }])
|
||||
...(!params?.domain && {
|
||||
onSuccess: data => setAccountStorage([{ key: 'version', value: data.version }])
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -6,8 +6,10 @@ import {
|
||||
UseInfiniteQueryOptions,
|
||||
useMutation
|
||||
} from '@tanstack/react-query'
|
||||
import apiGeneral from '@utils/api/general'
|
||||
import { PagedResponse } from '@utils/api/helpers'
|
||||
import apiInstance from '@utils/api/instance'
|
||||
import { appendRemote } from '@utils/helpers/appendRemote'
|
||||
import { featureCheck } from '@utils/helpers/featureCheck'
|
||||
import { useNavState } from '@utils/navigation/navigators'
|
||||
import { queryClient } from '@utils/queryHooks'
|
||||
@ -24,7 +26,7 @@ export type QueryKeyTimeline = [
|
||||
'Timeline',
|
||||
(
|
||||
| {
|
||||
page: Exclude<App.Pages, 'Following' | 'Hashtag' | 'List' | 'Toot' | 'Account'>
|
||||
page: Exclude<App.Pages, 'Following' | 'Hashtag' | 'List' | 'Toot' | 'Account' | 'Explore'>
|
||||
}
|
||||
| {
|
||||
page: 'Following'
|
||||
@ -50,6 +52,7 @@ export type QueryKeyTimeline = [
|
||||
toot: Mastodon.Status['id']
|
||||
remote: boolean
|
||||
}
|
||||
| { page: 'Explore'; domain?: string }
|
||||
)
|
||||
]
|
||||
|
||||
@ -117,12 +120,24 @@ export const queryFunctionTimeline = async ({
|
||||
params
|
||||
})
|
||||
|
||||
case 'Trending':
|
||||
return apiInstance<Mastodon.Status[]>({
|
||||
method: 'get',
|
||||
url: 'trends/statuses',
|
||||
params
|
||||
})
|
||||
case 'Explore':
|
||||
if (page.domain) {
|
||||
return apiGeneral<Mastodon.Status[]>({
|
||||
method: 'get',
|
||||
domain: page.domain,
|
||||
url: 'api/v1/timelines/public',
|
||||
params: {
|
||||
...params,
|
||||
local: 'true'
|
||||
}
|
||||
}).then(res => ({ ...res, body: res.body.map(status => appendRemote.status(status)) }))
|
||||
} else {
|
||||
return apiInstance<Mastodon.Status[]>({
|
||||
method: 'get',
|
||||
url: 'trends/statuses',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
case 'Notifications':
|
||||
const notificationsFilter = getAccountStorage.object('notifications')
|
||||
|
@ -5,7 +5,7 @@ export type GlobalV0 = {
|
||||
// string
|
||||
'app.expo_token'?: string
|
||||
'app.prev_tab'?: keyof ScreenTabsStackParamList
|
||||
'app.prev_public_segment'?: Extract<App.Pages, 'Local' | 'LocalPublic' | 'Trending'>
|
||||
'app.prev_public_segment'?: Extract<App.Pages, 'Local' | 'LocalPublic' | 'Explore'>
|
||||
'app.language'?: string
|
||||
'app.theme'?: 'light' | 'dark' | 'auto'
|
||||
'app.theme.dark'?: 'lighter' | 'darker'
|
||||
@ -24,4 +24,10 @@ export type GlobalV0 = {
|
||||
'account.active'?: string
|
||||
// object
|
||||
accounts?: string[]
|
||||
|
||||
//// remote
|
||||
// string
|
||||
'remote.active'?: string
|
||||
// object
|
||||
remotes?: { title: string; domain: string }[]
|
||||
}
|
||||
|
Reference in New Issue
Block a user