This commit is contained in:
Zhiyuan Zheng 2021-12-18 19:59:38 +01:00
parent ad6c6a98b6
commit 8c9dfb839b
23 changed files with 126 additions and 112 deletions

View File

@ -16,6 +16,7 @@ import * as SplashScreen from 'expo-splash-screen'
import React, { useCallback, useEffect, useState } from 'react' import React, { useCallback, useEffect, useState } from 'react'
import { AppState, LogBox, Platform } from 'react-native' import { AppState, LogBox, Platform } from 'react-native'
import { GestureHandlerRootView } from 'react-native-gesture-handler' import { GestureHandlerRootView } from 'react-native-gesture-handler'
import { enableFreeze } from 'react-native-screens'
import { QueryClientProvider } from 'react-query' import { QueryClientProvider } from 'react-query'
import { Provider } from 'react-redux' import { Provider } from 'react-redux'
import { PersistGate } from 'redux-persist/integration/react' import { PersistGate } from 'redux-persist/integration/react'
@ -29,6 +30,7 @@ dev()
sentry() sentry()
audio() audio()
push() push()
enableFreeze()
const App: React.FC = () => { const App: React.FC = () => {
log('log', 'App', 'rendering App') log('log', 'App', 'rendering App')

View File

@ -136,7 +136,7 @@ const Screens: React.FC<Props> = ({ localCorrupt }) => {
} }
if (previousRoute?.name !== currentRoute?.name) { if (previousRoute?.name !== currentRoute?.name) {
Analytics.setCurrentScreen(currentRoute?.name) Analytics.logEvent('screen_view', { screen_name: currentRoute?.name })
Sentry.Native.setContext('page', { Sentry.Native.setContext('page', {
previous: previousRoute, previous: previousRoute,
current: currentRoute current: currentRoute

View File

@ -21,6 +21,11 @@ export type Params = {
> >
} }
export type InstanceResponse<T = unknown> = {
body: T
links: { prev?: string; next?: string }
}
const apiInstance = async <T = unknown>({ const apiInstance = async <T = unknown>({
method, method,
version = 'v1', version = 'v1',
@ -29,7 +34,7 @@ const apiInstance = async <T = unknown>({
headers, headers,
body, body,
extras extras
}: Params): Promise<{ body: T; links: { prev?: string; next?: string } }> => { }: Params): Promise<InstanceResponse<T>> => {
const { store } = require('@root/store') const { store } = require('@root/store')
const state = store.getState() as RootState const state = store.getState() as RootState
const instanceActive = state.instances.instances.findIndex( const instanceActive = state.instances.instances.findIndex(

View File

@ -47,7 +47,6 @@ const TimelineTranslate = React.memo(
const [enabled, setEnabled] = useState(false) const [enabled, setEnabled] = useState(false)
const { refetch, data, isLoading, isSuccess, isError } = useTranslateQuery({ const { refetch, data, isLoading, isSuccess, isError } = useTranslateQuery({
uri: status.uri,
source: status.language, source: status.language,
target: settingsLanguage, target: settingsLanguage,
text, text,

View File

@ -31,7 +31,7 @@ const Tab = createBottomTabNavigator<ScreenTabsStackParamList>()
const ScreenTabs = React.memo( const ScreenTabs = React.memo(
({ navigation }: RootStackScreenProps<'Screen-Tabs'>) => { ({ navigation }: RootStackScreenProps<'Screen-Tabs'>) => {
const { mode, theme } = useTheme() const { theme } = useTheme()
const instanceActive = useSelector(getInstanceActive) const instanceActive = useSelector(getInstanceActive)
const instanceAccount = useSelector( const instanceAccount = useSelector(

View File

@ -10,9 +10,11 @@ import { Alert, StyleSheet } from 'react-native'
import FlashMessage from 'react-native-flash-message' import FlashMessage from 'react-native-flash-message'
import { ScrollView } from 'react-native-gesture-handler' import { ScrollView } from 'react-native-gesture-handler'
const TabMeProfileName: React.FC<TabMeProfileStackScreenProps< const TabMeProfileName: React.FC<
'Tab-Me-Profile-Name' TabMeProfileStackScreenProps<'Tab-Me-Profile-Name'> & {
> & { messageRef: RefObject<FlashMessage> }> = ({ messageRef: RefObject<FlashMessage>
}
> = ({
messageRef, messageRef,
route: { route: {
params: { display_name } params: { display_name }
@ -91,7 +93,8 @@ const TabMeProfileName: React.FC<TabMeProfileStackScreenProps<
options={{ options={{
maxLength: 30, maxLength: 30,
autoCapitalize: 'none', autoCapitalize: 'none',
autoCompleteType: 'username', autoComplete: 'username',
textContentType: 'username',
autoCorrect: false autoCorrect: false
}} }}
/> />

View File

@ -64,6 +64,7 @@ const SettingsApp: React.FC = () => {
cancelButtonIndex: options.length - 1 cancelButtonIndex: options.length - 1
}, },
buttonIndex => { buttonIndex => {
if (!buttonIndex) return
if (buttonIndex < options.length - 1) { if (buttonIndex < options.length - 1) {
analytics('settings_language_press', { analytics('settings_language_press', {
current: i18n.language, current: i18n.language,

View File

@ -32,9 +32,9 @@ export const mapFontsizeToName = (size: SettingsState['fontsize']) => {
} }
} }
const TabMeSettingsFontsize: React.FC<TabMeStackScreenProps< const TabMeSettingsFontsize: React.FC<
'Tab-Me-Settings-Fontsize' TabMeStackScreenProps<'Tab-Me-Settings-Fontsize'>
>> = () => { > = () => {
const { mode, theme } = useTheme() const { mode, theme } = useTheme()
const { t } = useTranslation('screenTabs') const { t } = useTranslation('screenTabs')
const initialSize = useSelector(getSettingsFontsize) const initialSize = useSelector(getSettingsFontsize)
@ -113,7 +113,12 @@ const TabMeSettingsFontsize: React.FC<TabMeStackScreenProps<
extraMarginLeft={-StyleConstants.Spacing.Global.PagePadding} extraMarginLeft={-StyleConstants.Spacing.Global.PagePadding}
extraMarginRight={-StyleConstants.Spacing.Global.PagePadding} extraMarginRight={-StyleConstants.Spacing.Global.PagePadding}
/> />
<TimelineDefault item={item} disableDetails disableOnPress /> <TimelineDefault
// @ts-ignore
item={item}
disableDetails
disableOnPress
/>
<ComponentSeparator <ComponentSeparator
extraMarginLeft={-StyleConstants.Spacing.Global.PagePadding} extraMarginLeft={-StyleConstants.Spacing.Global.PagePadding}
extraMarginRight={-StyleConstants.Spacing.Global.PagePadding} extraMarginRight={-StyleConstants.Spacing.Global.PagePadding}

View File

@ -18,9 +18,9 @@ import {
} from 'react-native' } from 'react-native'
import { Circle } from 'react-native-animated-spinkit' import { Circle } from 'react-native-animated-spinkit'
const TabSharedSearch: React.FC<TabSharedStackScreenProps< const TabSharedSearch: React.FC<
'Tab-Shared-Search' TabSharedStackScreenProps<'Tab-Shared-Search'>
>> = ({ > = ({
route: { route: {
params: { text } params: { text }
} }
@ -33,7 +33,13 @@ const TabSharedSearch: React.FC<TabSharedStackScreenProps<
hashtags: t('shared.search.sections.hashtags'), hashtags: t('shared.search.sections.hashtags'),
statuses: t('shared.search.sections.statuses') statuses: t('shared.search.sections.statuses')
} }
const { status, data } = useSearchQuery({ const { status, data } = useSearchQuery<
{
title: string
translation: string
data: any[]
}[]
>({
term: text, term: text,
options: { options: {
enabled: text !== undefined, enabled: text !== undefined,

View File

@ -33,24 +33,18 @@ const AccessibilityManager: React.FC = ({ children }) => {
useEffect(() => { useEffect(() => {
loadAccessibilityInfo() loadAccessibilityInfo()
AccessibilityInfo.addEventListener( const reduceMotionSubscription = AccessibilityInfo.addEventListener(
'reduceMotionChanged', 'reduceMotionChanged',
handleReduceMotionChanged handleReduceMotionChanged
) )
AccessibilityInfo.addEventListener( const screenReaderSubscription = AccessibilityInfo.addEventListener(
'screenReaderChanged', 'screenReaderChanged',
handleScreenReaderEnabled handleScreenReaderEnabled
) )
return () => { return () => {
AccessibilityInfo.removeEventListener( reduceMotionSubscription.remove()
'reduceMotionChanged', screenReaderSubscription.remove()
handleReduceMotionChanged
)
AccessibilityInfo.removeEventListener(
'screenReaderChanged',
handleScreenReaderEnabled
)
} }
}, []) }, [])

View File

@ -1,10 +1,10 @@
import apiInstance from '@api/instance' import apiInstance from '@api/instance'
import { AxiosError } from 'axios' import { AxiosError } from 'axios'
import { useQuery, UseQueryOptions } from 'react-query' import { QueryFunctionContext, useQuery, UseQueryOptions } from 'react-query'
export type QueryKeyAccount = ['Account', { id: Mastodon.Account['id'] }] export type QueryKeyAccount = ['Account', { id: Mastodon.Account['id'] }]
const queryFunction = ({ queryKey }: { queryKey: QueryKeyAccount }) => { const queryFunction = ({ queryKey }: QueryFunctionContext<QueryKeyAccount>) => {
const { id } = queryKey[1] const { id } = queryKey[1]
return apiInstance<Mastodon.Account>({ return apiInstance<Mastodon.Account>({
@ -13,11 +13,11 @@ const queryFunction = ({ queryKey }: { queryKey: QueryKeyAccount }) => {
}).then(res => res.body) }).then(res => res.body)
} }
const useAccountQuery = <TData = Mastodon.Account>({ const useAccountQuery = ({
options, options,
...queryKeyParams ...queryKeyParams
}: QueryKeyAccount[1] & { }: QueryKeyAccount[1] & {
options?: UseQueryOptions<Mastodon.Account, AxiosError, TData> options?: UseQueryOptions<Mastodon.Account, AxiosError>
}) => { }) => {
const queryKey: QueryKeyAccount = ['Account', { ...queryKeyParams }] const queryKey: QueryKeyAccount = ['Account', { ...queryKeyParams }]
return useQuery(queryKey, queryFunction, options) return useQuery(queryKey, queryFunction, options)

View File

@ -1,6 +1,7 @@
import apiInstance from '@api/instance' import apiInstance from '@api/instance'
import { AxiosError } from 'axios' import { AxiosError } from 'axios'
import { import {
QueryFunctionContext,
useMutation, useMutation,
UseMutationOptions, UseMutationOptions,
useQuery, useQuery,
@ -9,7 +10,9 @@ import {
type QueryKeyAnnouncement = ['Announcements', { showAll?: boolean }] type QueryKeyAnnouncement = ['Announcements', { showAll?: boolean }]
const queryFunction = ({ queryKey }: { queryKey: QueryKeyAnnouncement }) => { const queryFunction = ({
queryKey
}: QueryFunctionContext<QueryKeyAnnouncement>) => {
const { showAll } = queryKey[1] const { showAll } = queryKey[1]
return apiInstance<Mastodon.Announcement[]>({ return apiInstance<Mastodon.Announcement[]>({
@ -23,11 +26,11 @@ const queryFunction = ({ queryKey }: { queryKey: QueryKeyAnnouncement }) => {
}).then(res => res.body) }).then(res => res.body)
} }
const useAnnouncementQuery = <TData = Mastodon.Announcement[]>({ const useAnnouncementQuery = ({
options, options,
...queryKeyParams ...queryKeyParams
}: QueryKeyAnnouncement[1] & { }: QueryKeyAnnouncement[1] & {
options?: UseQueryOptions<Mastodon.Announcement[], AxiosError, TData> options?: UseQueryOptions<Mastodon.Announcement[], AxiosError>
}) => { }) => {
const queryKey: QueryKeyAnnouncement = [ const queryKey: QueryKeyAnnouncement = [
'Announcements', 'Announcements',

View File

@ -1,11 +1,11 @@
import apiGeneral from '@api/general' import apiGeneral from '@api/general'
import { AxiosError } from 'axios' import { AxiosError } from 'axios'
import * as AuthSession from 'expo-auth-session' import * as AuthSession from 'expo-auth-session'
import { useQuery, UseQueryOptions } from 'react-query' import { QueryFunctionContext, useQuery, UseQueryOptions } from 'react-query'
export type QueryKey = ['Apps', { domain?: string }] export type QueryKeyApps = ['Apps', { domain?: string }]
const queryFunction = ({ queryKey }: { queryKey: QueryKey }) => { const queryFunction = ({ queryKey }: QueryFunctionContext<QueryKeyApps>) => {
const redirectUri = AuthSession.makeRedirectUri({ const redirectUri = AuthSession.makeRedirectUri({
native: 'tooot://instance-auth', native: 'tooot://instance-auth',
useProxy: false useProxy: false
@ -27,13 +27,13 @@ const queryFunction = ({ queryKey }: { queryKey: QueryKey }) => {
}).then(res => res.body) }).then(res => res.body)
} }
const useAppsQuery = <TData = Mastodon.Apps>({ const useAppsQuery = ({
options, options,
...queryKeyParams ...queryKeyParams
}: QueryKey[1] & { }: QueryKeyApps[1] & {
options?: UseQueryOptions<Mastodon.Apps, AxiosError, TData> options?: UseQueryOptions<Mastodon.Apps, AxiosError>
}) => { }) => {
const queryKey: QueryKey = ['Apps', { ...queryKeyParams }] const queryKey: QueryKeyApps = ['Apps', { ...queryKeyParams }]
return useQuery(queryKey, queryFunction, options) return useQuery(queryKey, queryFunction, options)
} }

View File

@ -2,21 +2,22 @@ import apiInstance from '@api/instance'
import { AxiosError } from 'axios' import { AxiosError } from 'axios'
import { useQuery, UseQueryOptions } from 'react-query' import { useQuery, UseQueryOptions } from 'react-query'
type QueryKey = ['Emojis'] type QueryKeyEmojis = ['Emojis']
const queryFunction = () => { const queryFunction = async () => {
return apiInstance<Mastodon.Emoji[]>({ const res = await apiInstance<Mastodon.Emoji[]>({
method: 'get', method: 'get',
url: 'custom_emojis' url: 'custom_emojis'
}).then(res => res.body) })
return res.body
} }
const useEmojisQuery = <TData = Mastodon.Emoji[]>({ const useEmojisQuery = ({
options options
}: { }: {
options?: UseQueryOptions<Mastodon.Emoji[], AxiosError, TData> options?: UseQueryOptions<Mastodon.Emoji[], AxiosError>
}) => { }) => {
const queryKey: QueryKey = ['Emojis'] const queryKey: QueryKeyEmojis = ['Emojis']
return useQuery(queryKey, queryFunction, options) return useQuery(queryKey, queryFunction, options)
} }

View File

@ -1,10 +1,12 @@
import apiGeneral from '@api/general' import apiGeneral from '@api/general'
import { AxiosError } from 'axios' import { AxiosError } from 'axios'
import { useQuery, UseQueryOptions } from 'react-query' import { QueryFunctionContext, useQuery, UseQueryOptions } from 'react-query'
export type QueryKey = ['Instance', { domain?: string }] export type QueryKeyInstance = ['Instance', { domain?: string }]
const queryFunction = async ({ queryKey }: { queryKey: QueryKey }) => { const queryFunction = async ({
queryKey
}: QueryFunctionContext<QueryKeyInstance>) => {
const { domain } = queryKey[1] const { domain } = queryKey[1]
if (!domain) { if (!domain) {
return Promise.reject() return Promise.reject()
@ -18,19 +20,16 @@ const queryFunction = async ({ queryKey }: { queryKey: QueryKey }) => {
return res.body return res.body
} }
const useInstanceQuery = < const useInstanceQuery = ({
TData = Mastodon.Instance & { publicAllow?: boolean }
>({
options, options,
...queryKeyParams ...queryKeyParams
}: QueryKey[1] & { }: QueryKeyInstance[1] & {
options?: UseQueryOptions< options?: UseQueryOptions<
Mastodon.Instance & { publicAllow?: boolean }, Mastodon.Instance & { publicAllow?: boolean },
AxiosError, AxiosError
TData
> >
}) => { }) => {
const queryKey: QueryKey = ['Instance', { ...queryKeyParams }] const queryKey: QueryKeyInstance = ['Instance', { ...queryKeyParams }]
return useQuery(queryKey, queryFunction, options) return useQuery(queryKey, queryFunction, options)
} }

View File

@ -4,17 +4,18 @@ import { useQuery, UseQueryOptions } from 'react-query'
export type QueryKey = ['Lists'] export type QueryKey = ['Lists']
const queryFunction = () => { const queryFunction = async () => {
return apiInstance<Mastodon.List[]>({ const res = await apiInstance<Mastodon.List[]>({
method: 'get', method: 'get',
url: 'lists' url: 'lists'
}).then(res => res.body) })
return res.body
} }
const useListsQuery = <TData = Mastodon.List[]>({ const useListsQuery = ({
options options
}: { }: {
options?: UseQueryOptions<Mastodon.List[], AxiosError, TData> options?: UseQueryOptions<Mastodon.List[], AxiosError>
}) => { }) => {
const queryKey: QueryKey = ['Lists'] const queryKey: QueryKey = ['Lists']
return useQuery(queryKey, queryFunction, options) return useQuery(queryKey, queryFunction, options)

View File

@ -14,17 +14,18 @@ type AccountWithSource = Mastodon.Account &
type QueryKeyProfile = ['Profile'] type QueryKeyProfile = ['Profile']
const queryKey: QueryKeyProfile = ['Profile'] const queryKey: QueryKeyProfile = ['Profile']
const queryFunction = () => { const queryFunction = async () => {
return apiInstance<AccountWithSource>({ const res = await apiInstance<AccountWithSource>({
method: 'get', method: 'get',
url: `accounts/verify_credentials` url: `accounts/verify_credentials`
}).then(res => res.body) })
return res.body
} }
const useProfileQuery = <TData = AccountWithSource>({ const useProfileQuery = ({
options options
}: { }: {
options?: UseQueryOptions<AccountWithSource, AxiosError, TData> options?: UseQueryOptions<AccountWithSource, AxiosError>
}) => { }) => {
return useQuery(queryKey, queryFunction, options) return useQuery(queryKey, queryFunction, options)
} }

View File

@ -1,6 +1,7 @@
import apiInstance from '@api/instance' import apiInstance from '@api/instance'
import { AxiosError } from 'axios' import { AxiosError } from 'axios'
import { import {
QueryFunctionContext,
useMutation, useMutation,
UseMutationOptions, UseMutationOptions,
useQuery, useQuery,
@ -12,7 +13,9 @@ export type QueryKeyRelationship = [
{ id: Mastodon.Account['id'] } { id: Mastodon.Account['id'] }
] ]
const queryFunction = ({ queryKey }: { queryKey: QueryKeyRelationship }) => { const queryFunction = ({
queryKey
}: QueryFunctionContext<QueryKeyRelationship>) => {
const { id } = queryKey[1] const { id } = queryKey[1]
return apiInstance<Mastodon.Relationship[]>({ return apiInstance<Mastodon.Relationship[]>({

View File

@ -1,8 +1,8 @@
import apiInstance from '@api/instance' import apiInstance from '@api/instance'
import { AxiosError } from 'axios' import { AxiosError } from 'axios'
import { useQuery, UseQueryOptions } from 'react-query' import { QueryFunctionContext, useQuery, UseQueryOptions } from 'react-query'
export type QueryKey = [ export type QueryKeySearch = [
'Search', 'Search',
{ {
type?: 'accounts' | 'hashtags' | 'statuses' type?: 'accounts' | 'hashtags' | 'statuses'
@ -17,9 +17,11 @@ export type SearchResult = {
statuses: Mastodon.Status[] statuses: Mastodon.Status[]
} }
const queryFunction = ({ queryKey }: { queryKey: QueryKey }) => { const queryFunction = async ({
queryKey
}: QueryFunctionContext<QueryKeySearch>) => {
const { type, term, limit = 20 } = queryKey[1] const { type, term, limit = 20 } = queryKey[1]
return apiInstance<SearchResult>({ const res = await apiInstance<SearchResult>({
version: 'v2', version: 'v2',
method: 'get', method: 'get',
url: 'search', url: 'search',
@ -29,16 +31,17 @@ const queryFunction = ({ queryKey }: { queryKey: QueryKey }) => {
limit, limit,
resolve: true resolve: true
} }
}).then(res => res.body) })
return res.body
} }
const useSearchQuery = <TData = SearchResult>({ const useSearchQuery = <T = unknown>({
options, options,
...queryKeyParams ...queryKeyParams
}: QueryKey[1] & { }: QueryKeySearch[1] & {
options?: UseQueryOptions<SearchResult, AxiosError, TData> options?: UseQueryOptions<SearchResult, AxiosError, T>
}) => { }) => {
const queryKey: QueryKey = ['Search', { ...queryKeyParams }] const queryKey: QueryKeySearch = ['Search', { ...queryKeyParams }]
return useQuery(queryKey, queryFunction, options) return useQuery(queryKey, queryFunction, options)
} }

View File

@ -1,4 +1,4 @@
import apiInstance from '@api/instance' import apiInstance, { InstanceResponse } from '@api/instance'
import haptics from '@components/haptics' import haptics from '@components/haptics'
import queryClient from '@helpers/queryClient' import queryClient from '@helpers/queryClient'
import { store } from '@root/store' import { store } from '@root/store'
@ -7,6 +7,7 @@ import { AxiosError } from 'axios'
import { uniqBy } from 'lodash' import { uniqBy } from 'lodash'
import { import {
MutationOptions, MutationOptions,
QueryFunctionContext,
useInfiniteQuery, useInfiniteQuery,
UseInfiniteQueryOptions, UseInfiniteQueryOptions,
useMutation useMutation
@ -28,10 +29,7 @@ export type QueryKeyTimeline = [
const queryFunction = async ({ const queryFunction = async ({
queryKey, queryKey,
pageParam pageParam
}: { }: QueryFunctionContext<QueryKeyTimeline>) => {
queryKey: QueryKeyTimeline
pageParam?: { [key: string]: string }
}) => {
const { page, account, hashtag, list, toot } = queryKey[1] const { page, account, hashtag, list, toot } = queryKey[1]
let params: { [key: string]: string } = { ...pageParam } let params: { [key: string]: string } = { ...pageParam }
@ -191,21 +189,15 @@ const queryFunction = async ({
type Unpromise<T extends Promise<any>> = T extends Promise<infer U> ? U : never type Unpromise<T extends Promise<any>> = T extends Promise<infer U> ? U : never
export type TimelineData = Unpromise<ReturnType<typeof queryFunction>> export type TimelineData = Unpromise<ReturnType<typeof queryFunction>>
const useTimelineQuery = <TData = TimelineData>({ const useTimelineQuery = ({
options, options,
...queryKeyParams ...queryKeyParams
}: QueryKeyTimeline[1] & { }: QueryKeyTimeline[1] & {
options?: UseInfiniteQueryOptions< options?: UseInfiniteQueryOptions<
{ InstanceResponse<
body: Mastodon.Status[] | Mastodon.Notification[] | Mastodon.Conversation[]
| Mastodon.Status[] >,
| Mastodon.Notification[] AxiosError
| Mastodon.Conversation[]
links?: { prev?: string; next?: string }
pinned?: Mastodon.Status['id'][]
},
AxiosError,
TData
> >
}) => { }) => {
const queryKey: QueryKeyTimeline = ['Timeline', { ...queryKeyParams }] const queryKey: QueryKeyTimeline = ['Timeline', { ...queryKeyParams }]

View File

@ -1,7 +1,7 @@
import apiTooot from '@api/tooot' import apiTooot from '@api/tooot'
import haptics from '@components/haptics' import haptics from '@components/haptics'
import { AxiosError } from 'axios' import { AxiosError } from 'axios'
import { useQuery, UseQueryOptions } from 'react-query' import { QueryFunctionContext, useQuery, UseQueryOptions } from 'react-query'
type Translations = { type Translations = {
provider: string provider: string
@ -18,7 +18,9 @@ export type QueryKeyTranslate = [
} }
] ]
const queryFunction = async ({ queryKey }: { queryKey: QueryKeyTranslate }) => { const queryFunction = async ({
queryKey
}: QueryFunctionContext<QueryKeyTranslate>) => {
const { source, target, text } = queryKey[1] const { source, target, text } = queryKey[1]
const res = await apiTooot<Translations>({ const res = await apiTooot<Translations>({
@ -34,7 +36,7 @@ const useTranslateQuery = ({
options, options,
...queryKeyParams ...queryKeyParams
}: QueryKeyTranslate[1] & { }: QueryKeyTranslate[1] & {
options?: UseQueryOptions<Translations, AxiosError, Translations> options?: UseQueryOptions<Translations, AxiosError>
}) => { }) => {
const queryKey: QueryKeyTranslate = ['Translate', { ...queryKeyParams }] const queryKey: QueryKeyTranslate = ['Translate', { ...queryKeyParams }]
return useQuery(queryKey, queryFunction, { ...options, retry: false }) return useQuery(queryKey, queryFunction, { ...options, retry: false })

View File

@ -1,7 +1,11 @@
import apiInstance from '@api/instance' import apiInstance, { InstanceResponse } from '@api/instance'
import { TabSharedStackParamList } from '@utils/navigation/navigators' import { TabSharedStackParamList } from '@utils/navigation/navigators'
import { AxiosError } from 'axios' import { AxiosError } from 'axios'
import { useInfiniteQuery, UseInfiniteQueryOptions } from 'react-query' import {
QueryFunctionContext,
useInfiniteQuery,
UseInfiniteQueryOptions
} from 'react-query'
export type QueryKeyUsers = [ export type QueryKeyUsers = [
'Users', 'Users',
@ -11,10 +15,7 @@ export type QueryKeyUsers = [
const queryFunction = ({ const queryFunction = ({
queryKey, queryKey,
pageParam pageParam
}: { }: QueryFunctionContext<QueryKeyUsers>) => {
queryKey: QueryKeyUsers
pageParam?: { [key: string]: string }
}) => {
const { reference, id, type } = queryKey[1] const { reference, id, type } = queryKey[1]
let params: { [key: string]: string } = { ...pageParam } let params: { [key: string]: string } = { ...pageParam }
@ -30,15 +31,8 @@ const useUsersQuery = ({
...queryKeyParams ...queryKeyParams
}: QueryKeyUsers[1] & { }: QueryKeyUsers[1] & {
options?: UseInfiniteQueryOptions< options?: UseInfiniteQueryOptions<
{ InstanceResponse<Mastodon.Account[]>,
body: Mastodon.Account[] AxiosError
links?: { prev?: string; next?: string }
},
AxiosError,
{
body: Mastodon.Account[]
links?: { prev?: string; next?: string }
}
> >
}) => { }) => {
const queryKey: QueryKeyUsers = ['Users', { ...queryKeyParams }] const queryKey: QueryKeyUsers = ['Users', { ...queryKeyParams }]

View File

@ -99,7 +99,7 @@ const addInstance = createAsyncThunk(
mention: { loading: false, value: true }, mention: { loading: false, value: true },
poll: { loading: false, value: true } poll: { loading: false, value: true }
}, },
keys: undefined keys: { auth: undefined, public: undefined, private: undefined }
}, },
drafts: [] drafts: []
} }