mirror of
https://github.com/tooot-app/app
synced 2025-04-24 07:07:24 +02:00
544 migrate to react query v4 (#547)
* Update all imports * Update isLoading * Update onlineManager
This commit is contained in:
parent
b449d50b78
commit
357c4039cb
@ -41,6 +41,7 @@
|
|||||||
"@reduxjs/toolkit": "^1.9.1",
|
"@reduxjs/toolkit": "^1.9.1",
|
||||||
"@sentry/react-native": "4.10.1",
|
"@sentry/react-native": "4.10.1",
|
||||||
"@sharcoux/slider": "^6.1.1",
|
"@sharcoux/slider": "^6.1.1",
|
||||||
|
"@tanstack/react-query": "^4.19.1",
|
||||||
"axios": "^0.27.2",
|
"axios": "^0.27.2",
|
||||||
"expo": "^47.0.8",
|
"expo": "^47.0.8",
|
||||||
"expo-auth-session": "^3.7.3",
|
"expo-auth-session": "^3.7.3",
|
||||||
@ -89,7 +90,6 @@
|
|||||||
"react-native-svg": "^13.6.0",
|
"react-native-svg": "^13.6.0",
|
||||||
"react-native-swipe-list-view": "^3.2.9",
|
"react-native-swipe-list-view": "^3.2.9",
|
||||||
"react-native-tab-view": "^3.3.2",
|
"react-native-tab-view": "^3.3.2",
|
||||||
"react-query": "^3.39.2",
|
|
||||||
"react-redux": "^8.0.5",
|
"react-redux": "^8.0.5",
|
||||||
"redux-persist": "^6.0.0",
|
"redux-persist": "^6.0.0",
|
||||||
"rn-placeholder": "^3.0.3",
|
"rn-placeholder": "^3.0.3",
|
||||||
|
@ -23,7 +23,7 @@ import { LogBox, Platform } from 'react-native'
|
|||||||
import { GestureHandlerRootView } from 'react-native-gesture-handler'
|
import { GestureHandlerRootView } from 'react-native-gesture-handler'
|
||||||
import { SafeAreaProvider } from 'react-native-safe-area-context'
|
import { SafeAreaProvider } from 'react-native-safe-area-context'
|
||||||
import { enableFreeze } from 'react-native-screens'
|
import { enableFreeze } from 'react-native-screens'
|
||||||
import { QueryClientProvider } from 'react-query'
|
import { QueryClientProvider } from '@tanstack/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'
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import { useTheme } from '@utils/styles/ThemeManager'
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { StyleSheet, View } from 'react-native'
|
import { StyleSheet, View } from 'react-native'
|
||||||
import { useQueryClient } from 'react-query'
|
import { useQueryClient } from '@tanstack/react-query'
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
id: Mastodon.Account['id']
|
id: Mastodon.Account['id']
|
||||||
|
@ -10,7 +10,7 @@ import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
|
|||||||
import { useTheme } from '@utils/styles/ThemeManager'
|
import { useTheme } from '@utils/styles/ThemeManager'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { useQueryClient } from 'react-query'
|
import { useQueryClient } from '@tanstack/react-query'
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
id: Mastodon.Account['id']
|
id: Mastodon.Account['id']
|
||||||
|
@ -8,7 +8,7 @@ import { StyleConstants } from '@utils/styles/constants'
|
|||||||
import { useTheme } from '@utils/styles/ThemeManager'
|
import { useTheme } from '@utils/styles/ThemeManager'
|
||||||
import React, { useCallback } from 'react'
|
import React, { useCallback } from 'react'
|
||||||
import { Pressable, View } from 'react-native'
|
import { Pressable, View } from 'react-native'
|
||||||
import { useMutation, useQueryClient } from 'react-query'
|
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
||||||
import TimelineActions from './Shared/Actions'
|
import TimelineActions from './Shared/Actions'
|
||||||
import TimelineContent from './Shared/Content'
|
import TimelineContent from './Shared/Content'
|
||||||
import StatusContext from './Shared/Context'
|
import StatusContext from './Shared/Context'
|
||||||
|
@ -20,7 +20,7 @@ import Animated, {
|
|||||||
useSharedValue,
|
useSharedValue,
|
||||||
withTiming
|
withTiming
|
||||||
} from 'react-native-reanimated'
|
} from 'react-native-reanimated'
|
||||||
import { InfiniteData, useQueryClient } from 'react-query'
|
import { InfiniteData, useQueryClient } from '@tanstack/react-query'
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
flRef: RefObject<FlatList<any>>
|
flRef: RefObject<FlatList<any>>
|
||||||
|
@ -17,7 +17,7 @@ import { uniqBy } from 'lodash'
|
|||||||
import React, { useCallback, useContext, useMemo } from 'react'
|
import React, { useCallback, useContext, useMemo } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Pressable, StyleSheet, View } from 'react-native'
|
import { Pressable, StyleSheet, View } from 'react-native'
|
||||||
import { useQueryClient } from 'react-query'
|
import { useQueryClient } from '@tanstack/react-query'
|
||||||
import { useSelector } from 'react-redux'
|
import { useSelector } from 'react-redux'
|
||||||
import StatusContext from './Context'
|
import StatusContext from './Context'
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import { useTheme } from '@utils/styles/ThemeManager'
|
|||||||
import React, { useContext } from 'react'
|
import React, { useContext } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Pressable, View } from 'react-native'
|
import { Pressable, View } from 'react-native'
|
||||||
import { useQueryClient } from 'react-query'
|
import { useQueryClient } from '@tanstack/react-query'
|
||||||
import StatusContext from './Context'
|
import StatusContext from './Context'
|
||||||
import HeaderSharedCreated from './HeaderShared/Created'
|
import HeaderSharedCreated from './HeaderShared/Created'
|
||||||
import HeaderSharedMuted from './HeaderShared/Muted'
|
import HeaderSharedMuted from './HeaderShared/Muted'
|
||||||
|
@ -16,7 +16,7 @@ import { maxBy } from 'lodash'
|
|||||||
import React, { useCallback, useContext, useMemo, useState } from 'react'
|
import React, { useCallback, useContext, useMemo, useState } from 'react'
|
||||||
import { Trans, useTranslation } from 'react-i18next'
|
import { Trans, useTranslation } from 'react-i18next'
|
||||||
import { Pressable, View } from 'react-native'
|
import { Pressable, View } from 'react-native'
|
||||||
import { useQueryClient } from 'react-query'
|
import { useQueryClient } from '@tanstack/react-query'
|
||||||
import StatusContext from './Context'
|
import StatusContext from './Context'
|
||||||
|
|
||||||
const TimelinePoll: React.FC = () => {
|
const TimelinePoll: React.FC = () => {
|
||||||
|
@ -56,7 +56,7 @@ const TimelineTranslate = () => {
|
|||||||
: settingsLanguage || Localization.locale || 'en'
|
: settingsLanguage || Localization.locale || 'en'
|
||||||
|
|
||||||
const [enabled, setEnabled] = useState(false)
|
const [enabled, setEnabled] = useState(false)
|
||||||
const { refetch, data, isLoading, isSuccess, isError } = useTranslateQuery({
|
const { refetch, data, isFetching, isSuccess, isError } = useTranslateQuery({
|
||||||
source: detectedLanguage.language,
|
source: detectedLanguage.language,
|
||||||
target: targetLanguage,
|
target: targetLanguage,
|
||||||
text,
|
text,
|
||||||
@ -111,7 +111,7 @@ const TimelineTranslate = () => {
|
|||||||
<CustomText
|
<CustomText
|
||||||
fontStyle='M'
|
fontStyle='M'
|
||||||
style={{
|
style={{
|
||||||
color: isLoading || isSuccess ? colors.secondary : isError ? colors.red : colors.blue
|
color: isFetching || isSuccess ? colors.secondary : isError ? colors.red : colors.blue
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{isError
|
{isError
|
||||||
@ -125,7 +125,7 @@ const TimelineTranslate = () => {
|
|||||||
})
|
})
|
||||||
: t('shared.translate.default')}
|
: t('shared.translate.default')}
|
||||||
</CustomText>
|
</CustomText>
|
||||||
{isLoading ? (
|
{isFetching ? (
|
||||||
<Circle
|
<Circle
|
||||||
size={StyleConstants.Font.Size.M}
|
size={StyleConstants.Font.Size.M}
|
||||||
color={colors.disabled}
|
color={colors.disabled}
|
||||||
|
@ -17,7 +17,7 @@ import { getInstanceAccount } from '@utils/slices/instancesSlice'
|
|||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Platform } from 'react-native'
|
import { Platform } from 'react-native'
|
||||||
import { useQueryClient } from 'react-query'
|
import { useQueryClient } from '@tanstack/react-query'
|
||||||
import { useSelector } from 'react-redux'
|
import { useSelector } from 'react-redux'
|
||||||
|
|
||||||
const menuAccount = ({
|
const menuAccount = ({
|
||||||
|
@ -3,7 +3,7 @@ import { QueryKeyTimeline, useTimelineMutation } from '@utils/queryHooks/timelin
|
|||||||
import { getInstanceUrl } from '@utils/slices/instancesSlice'
|
import { getInstanceUrl } from '@utils/slices/instancesSlice'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Alert } from 'react-native'
|
import { Alert } from 'react-native'
|
||||||
import { useQueryClient } from 'react-query'
|
import { useQueryClient } from '@tanstack/react-query'
|
||||||
import { useSelector } from 'react-redux'
|
import { useSelector } from 'react-redux'
|
||||||
|
|
||||||
const menuInstance = ({
|
const menuInstance = ({
|
||||||
|
@ -12,7 +12,7 @@ import { checkInstanceFeature, getInstanceAccount } from '@utils/slices/instance
|
|||||||
import { useTheme } from '@utils/styles/ThemeManager'
|
import { useTheme } from '@utils/styles/ThemeManager'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Alert } from 'react-native'
|
import { Alert } from 'react-native'
|
||||||
import { useQueryClient } from 'react-query'
|
import { useQueryClient } from '@tanstack/react-query'
|
||||||
import { useSelector } from 'react-redux'
|
import { useSelector } from 'react-redux'
|
||||||
|
|
||||||
const menuStatus = ({
|
const menuStatus = ({
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { QueryClient } from 'react-query'
|
import { QueryClient } from '@tanstack/react-query'
|
||||||
|
|
||||||
const queryClient = new QueryClient({ defaultOptions: { queries: { staleTime: 1000 * 60 * 5 } } })
|
const queryClient = new QueryClient({ defaultOptions: { queries: { staleTime: 1000 * 60 * 5 } } })
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import { StyleConstants } from '@utils/styles/constants'
|
|||||||
import React, { useMemo } from 'react'
|
import React, { useMemo } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { useSelector } from 'react-redux'
|
import { useSelector } from 'react-redux'
|
||||||
import { useQueryClient } from 'react-query'
|
import { useQueryClient } from '@tanstack/react-query'
|
||||||
import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
|
import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
|
||||||
import { useAppDispatch } from '@root/store'
|
import { useAppDispatch } from '@root/store'
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ import { filter } from 'lodash'
|
|||||||
import React, { useCallback, useEffect, useMemo, useReducer, useState } from 'react'
|
import React, { useCallback, useEffect, useMemo, useReducer, useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Alert, Keyboard, Platform } from 'react-native'
|
import { Alert, Keyboard, Platform } from 'react-native'
|
||||||
import { useQueryClient } from 'react-query'
|
import { useQueryClient } from '@tanstack/react-query'
|
||||||
import { useSelector } from 'react-redux'
|
import { useSelector } from 'react-redux'
|
||||||
import ComposeDraftsList from './Compose/DraftsList'
|
import ComposeDraftsList from './Compose/DraftsList'
|
||||||
import ComposeEditAttachment from './Compose/EditAttachment'
|
import ComposeEditAttachment from './Compose/EditAttachment'
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import LinkifyIt from 'linkify-it'
|
import LinkifyIt from 'linkify-it'
|
||||||
import { debounce, differenceWith, isEqual } from 'lodash'
|
import { debounce, differenceWith, isEqual } from 'lodash'
|
||||||
import React, { Dispatch } from 'react'
|
import React, { Dispatch } from 'react'
|
||||||
import { FetchOptions } from 'react-query/types/core/query'
|
|
||||||
import { useTheme } from '@utils/styles/ThemeManager'
|
import { useTheme } from '@utils/styles/ThemeManager'
|
||||||
import { ComposeAction, ComposeState } from './types'
|
import { ComposeAction, ComposeState } from './types'
|
||||||
import { instanceConfigurationStatusCharsURL } from '../Root'
|
import { instanceConfigurationStatusCharsURL } from '../Root'
|
||||||
@ -12,7 +11,6 @@ export interface Params {
|
|||||||
textInput: ComposeState['textInputFocus']['current']
|
textInput: ComposeState['textInputFocus']['current']
|
||||||
composeDispatch: Dispatch<ComposeAction>
|
composeDispatch: Dispatch<ComposeAction>
|
||||||
content: string
|
content: string
|
||||||
refetch?: (options?: FetchOptions | undefined) => Promise<any>
|
|
||||||
disableDebounce?: boolean
|
disableDebounce?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ import { useTheme } from '@utils/styles/ThemeManager'
|
|||||||
import React, { useEffect, useRef, useState } from 'react'
|
import React, { useEffect, useRef, useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Alert, Platform, ScrollView, TextInput } from 'react-native'
|
import { Alert, Platform, ScrollView, TextInput } from 'react-native'
|
||||||
import { useQueryClient } from 'react-query'
|
import { useQueryClient } from '@tanstack/react-query'
|
||||||
|
|
||||||
const TabMeListEdit: React.FC<TabMeStackScreenProps<'Tab-Me-List-Edit'>> = ({
|
const TabMeListEdit: React.FC<TabMeStackScreenProps<'Tab-Me-List-Edit'>> = ({
|
||||||
navigation,
|
navigation,
|
||||||
|
@ -9,7 +9,7 @@ import { StyleConstants } from '@utils/styles/constants'
|
|||||||
import { useTheme } from '@utils/styles/ThemeManager'
|
import { useTheme } from '@utils/styles/ThemeManager'
|
||||||
import React, { useEffect } from 'react'
|
import React, { useEffect } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { useQueryClient } from 'react-query'
|
import { useQueryClient } from '@tanstack/react-query'
|
||||||
import * as DropdownMenu from 'zeego/dropdown-menu'
|
import * as DropdownMenu from 'zeego/dropdown-menu'
|
||||||
import { menuListAccounts, menuListDelete, menuListEdit } from './menus'
|
import { menuListAccounts, menuListDelete, menuListEdit } from './menus'
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import navigationRef from '@helpers/navigationRef'
|
import navigationRef from '@helpers/navigationRef'
|
||||||
import i18next from 'i18next'
|
import i18next from 'i18next'
|
||||||
import { Alert } from 'react-native'
|
import { Alert } from 'react-native'
|
||||||
import { UseMutationResult } from 'react-query'
|
import { UseMutationResult } from '@tanstack/react-query'
|
||||||
|
|
||||||
export const menuListAccounts = ({ params }: { params: Mastodon.List }) => ({
|
export const menuListAccounts = ({ params }: { params: Mastodon.List }) => ({
|
||||||
key: 'list-accounts',
|
key: 'list-accounts',
|
||||||
|
@ -21,7 +21,7 @@ const TabMeProfileRoot: React.FC<
|
|||||||
|
|
||||||
const { showActionSheetWithOptions } = useActionSheet()
|
const { showActionSheetWithOptions } = useActionSheet()
|
||||||
|
|
||||||
const { data, isLoading } = useProfileQuery()
|
const { data, isFetching } = useProfileQuery()
|
||||||
const { mutateAsync } = useProfileMutation()
|
const { mutateAsync } = useProfileMutation()
|
||||||
const dispatch = useAppDispatch()
|
const dispatch = useAppDispatch()
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ const TabMeProfileRoot: React.FC<
|
|||||||
<MenuRow
|
<MenuRow
|
||||||
title={t('me.profile.root.name.title')}
|
title={t('me.profile.root.name.title')}
|
||||||
content={data?.display_name}
|
content={data?.display_name}
|
||||||
loading={isLoading}
|
loading={isFetching}
|
||||||
iconBack='ChevronRight'
|
iconBack='ChevronRight'
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
data &&
|
data &&
|
||||||
@ -45,7 +45,7 @@ const TabMeProfileRoot: React.FC<
|
|||||||
<MenuRow
|
<MenuRow
|
||||||
title={t('me.profile.root.note.title')}
|
title={t('me.profile.root.note.title')}
|
||||||
content={data?.source.note}
|
content={data?.source.note}
|
||||||
loading={isLoading}
|
loading={isFetching}
|
||||||
iconBack='ChevronRight'
|
iconBack='ChevronRight'
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
data &&
|
data &&
|
||||||
@ -63,7 +63,7 @@ const TabMeProfileRoot: React.FC<
|
|||||||
})
|
})
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
loading={isLoading}
|
loading={isFetching}
|
||||||
iconBack='ChevronRight'
|
iconBack='ChevronRight'
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
navigation.navigate('Tab-Me-Profile-Fields', {
|
navigation.navigate('Tab-Me-Profile-Fields', {
|
||||||
@ -80,7 +80,7 @@ const TabMeProfileRoot: React.FC<
|
|||||||
? t(`me.profile.root.visibility.options.${data?.source.privacy}`)
|
? t(`me.profile.root.visibility.options.${data?.source.privacy}`)
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
loading={isLoading}
|
loading={isFetching}
|
||||||
iconBack='ChevronRight'
|
iconBack='ChevronRight'
|
||||||
onPress={() =>
|
onPress={() =>
|
||||||
showActionSheetWithOptions(
|
showActionSheetWithOptions(
|
||||||
@ -138,7 +138,7 @@ const TabMeProfileRoot: React.FC<
|
|||||||
data: data?.source.sensitive === undefined ? true : !data.source.sensitive
|
data: data?.source.sensitive === undefined ? true : !data.source.sensitive
|
||||||
}).then(() => dispatch(updateAccountPreferences()))
|
}).then(() => dispatch(updateAccountPreferences()))
|
||||||
}
|
}
|
||||||
loading={isLoading}
|
loading={isFetching}
|
||||||
/>
|
/>
|
||||||
</MenuContainer>
|
</MenuContainer>
|
||||||
<MenuContainer>
|
<MenuContainer>
|
||||||
@ -158,7 +158,7 @@ const TabMeProfileRoot: React.FC<
|
|||||||
data: data?.locked === undefined ? true : !data.locked
|
data: data?.locked === undefined ? true : !data.locked
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
loading={isLoading}
|
loading={isFetching}
|
||||||
/>
|
/>
|
||||||
<MenuRow
|
<MenuRow
|
||||||
title={t('me.profile.root.bot.title')}
|
title={t('me.profile.root.bot.title')}
|
||||||
@ -176,7 +176,7 @@ const TabMeProfileRoot: React.FC<
|
|||||||
data: data?.bot === undefined ? true : !data.bot
|
data: data?.bot === undefined ? true : !data.bot
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
loading={isLoading}
|
loading={isFetching}
|
||||||
/>
|
/>
|
||||||
</MenuContainer>
|
</MenuContainer>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
@ -24,17 +24,14 @@ const ProfileAvatarHeader: React.FC<Props> = ({ type, messageRef }) => {
|
|||||||
<MenuRow
|
<MenuRow
|
||||||
title={t(`me.profile.root.${type}.title`)}
|
title={t(`me.profile.root.${type}.title`)}
|
||||||
description={t(`me.profile.root.${type}.description`)}
|
description={t(`me.profile.root.${type}.description`)}
|
||||||
loading={query.isLoading || mutation.isLoading}
|
loading={query.isFetching || mutation.isLoading}
|
||||||
iconBack='ChevronRight'
|
iconBack='ChevronRight'
|
||||||
onPress={async () => {
|
onPress={async () => {
|
||||||
const image = await mediaSelector({
|
const image = await mediaSelector({
|
||||||
mediaType: 'photo',
|
mediaType: 'photo',
|
||||||
maximum: 1,
|
maximum: 1,
|
||||||
showActionSheetWithOptions,
|
showActionSheetWithOptions,
|
||||||
resize:
|
resize: type === 'avatar' ? { width: 400, height: 400 } : { width: 1500, height: 500 }
|
||||||
type === 'avatar'
|
|
||||||
? { width: 400, height: 400 }
|
|
||||||
: { width: 1500, height: 500 }
|
|
||||||
})
|
})
|
||||||
if (image[0].uri) {
|
if (image[0].uri) {
|
||||||
mutation.mutate({
|
mutation.mutate({
|
||||||
|
@ -7,7 +7,7 @@ import { StyleConstants } from '@utils/styles/constants'
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Alert } from 'react-native'
|
import { Alert } from 'react-native'
|
||||||
import { useQueryClient } from 'react-query'
|
import { useQueryClient } from '@tanstack/react-query'
|
||||||
import { useSelector } from 'react-redux'
|
import { useSelector } from 'react-redux'
|
||||||
|
|
||||||
const Logout: React.FC = () => {
|
const Logout: React.FC = () => {
|
||||||
|
@ -13,7 +13,7 @@ import React, { useEffect, useMemo, useRef, useState } from 'react'
|
|||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Text, View } from 'react-native'
|
import { Text, View } from 'react-native'
|
||||||
import { useSharedValue } from 'react-native-reanimated'
|
import { useSharedValue } from 'react-native-reanimated'
|
||||||
import { useIsFetching } from 'react-query'
|
import { useIsFetching } from '@tanstack/react-query'
|
||||||
import * as DropdownMenu from 'zeego/dropdown-menu'
|
import * as DropdownMenu from 'zeego/dropdown-menu'
|
||||||
import AccountAttachments from './Account/Attachments'
|
import AccountAttachments from './Account/Attachments'
|
||||||
import AccountHeader from './Account/Header'
|
import AccountHeader from './Account/Header'
|
||||||
|
@ -10,12 +10,12 @@ import { StyleSheet, TextInput, View } from 'react-native'
|
|||||||
import { Circle } from 'react-native-animated-spinkit'
|
import { Circle } from 'react-native-animated-spinkit'
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
isLoading: boolean
|
isFetching: boolean
|
||||||
inputRef: React.RefObject<TextInput>
|
inputRef: React.RefObject<TextInput>
|
||||||
setSearchTerm: React.Dispatch<React.SetStateAction<string>>
|
setSearchTerm: React.Dispatch<React.SetStateAction<string>>
|
||||||
}
|
}
|
||||||
|
|
||||||
const SearchEmpty: React.FC<Props> = ({ isLoading, inputRef, setSearchTerm }) => {
|
const SearchEmpty: React.FC<Props> = ({ isFetching, inputRef, setSearchTerm }) => {
|
||||||
const { colors } = useTheme()
|
const { colors } = useTheme()
|
||||||
const { t } = useTranslation('screenTabs')
|
const { t } = useTranslation('screenTabs')
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ const SearchEmpty: React.FC<Props> = ({ isLoading, inputRef, setSearchTerm }) =>
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={{ paddingVertical: StyleConstants.Spacing.Global.PagePadding }}>
|
<View style={{ paddingVertical: StyleConstants.Spacing.Global.PagePadding }}>
|
||||||
{isLoading ? (
|
{isFetching ? (
|
||||||
<View style={{ flex: 1, alignItems: 'center' }}>
|
<View style={{ flex: 1, alignItems: 'center' }}>
|
||||||
<Circle size={StyleConstants.Font.Size.M * 1.25} color={colors.secondary} />
|
<Circle size={StyleConstants.Font.Size.M * 1.25} color={colors.secondary} />
|
||||||
</View>
|
</View>
|
||||||
|
@ -84,7 +84,7 @@ const TabSharedSearch: React.FC<TabSharedStackScreenProps<'Tab-Shared-Search'>>
|
|||||||
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 { isLoading, data, refetch } = useSearchQuery<
|
const { isFetching, data, refetch } = useSearchQuery<
|
||||||
{
|
{
|
||||||
title: string
|
title: string
|
||||||
translation: string
|
translation: string
|
||||||
@ -138,7 +138,7 @@ const TabSharedSearch: React.FC<TabSharedStackScreenProps<'Tab-Shared-Search'>>
|
|||||||
}}
|
}}
|
||||||
stickySectionHeadersEnabled
|
stickySectionHeadersEnabled
|
||||||
ListEmptyComponent={
|
ListEmptyComponent={
|
||||||
<SearchEmpty isLoading={isLoading} inputRef={inputRef} setSearchTerm={setSearchTerm} />
|
<SearchEmpty isFetching={isFetching} inputRef={inputRef} setSearchTerm={setSearchTerm} />
|
||||||
}
|
}
|
||||||
keyboardShouldPersistTaps='always'
|
keyboardShouldPersistTaps='always'
|
||||||
renderSectionHeader={({ section: { translation } }) => (
|
renderSectionHeader={({ section: { translation } }) => (
|
||||||
|
@ -6,7 +6,7 @@ import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
|
|||||||
import React, { useEffect, useRef, useState } from 'react'
|
import React, { useEffect, useRef, useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { FlatList } from 'react-native'
|
import { FlatList } from 'react-native'
|
||||||
import { InfiniteQueryObserver, useQueryClient } from 'react-query'
|
import { InfiniteQueryObserver, useQueryClient } from '@tanstack/react-query'
|
||||||
|
|
||||||
const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
|
const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
|
||||||
navigation,
|
navigation,
|
||||||
|
@ -3,7 +3,7 @@ import NetInfo from '@react-native-community/netinfo'
|
|||||||
import { store } from '@root/store'
|
import { store } from '@root/store'
|
||||||
import removeInstance from '@utils/slices/instances/remove'
|
import removeInstance from '@utils/slices/instances/remove'
|
||||||
import { getInstance, updateInstanceAccount } from '@utils/slices/instancesSlice'
|
import { getInstance, updateInstanceAccount } from '@utils/slices/instancesSlice'
|
||||||
import { onlineManager } from 'react-query'
|
import { onlineManager } from '@tanstack/react-query'
|
||||||
import log from './log'
|
import log from './log'
|
||||||
|
|
||||||
const netInfo = async (): Promise<{
|
const netInfo = async (): Promise<{
|
||||||
@ -17,7 +17,7 @@ const netInfo = async (): Promise<{
|
|||||||
|
|
||||||
onlineManager.setEventListener(setOnline => {
|
onlineManager.setEventListener(setOnline => {
|
||||||
return NetInfo.addEventListener(state => {
|
return NetInfo.addEventListener(state => {
|
||||||
setOnline(typeof state.isConnected === 'boolean' ? state.isConnected : undefined)
|
setOnline(!!state.isConnected)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
import apiInstance from '@api/instance'
|
import apiInstance from '@api/instance'
|
||||||
import { AxiosError } from 'axios'
|
import { AxiosError } from 'axios'
|
||||||
import { QueryFunctionContext, useQuery, UseQueryOptions } from 'react-query'
|
import { QueryFunctionContext, useQuery, UseQueryOptions } from '@tanstack/react-query'
|
||||||
|
|
||||||
export type QueryKeyAccount = ['Account', { id: Mastodon.Account['id'] }]
|
export type QueryKeyAccount = ['Account', { id: Mastodon.Account['id'] }]
|
||||||
|
|
||||||
const accountQueryFunction = ({ queryKey }: QueryFunctionContext<QueryKeyAccount>) => {
|
const accountQueryFunction = async ({ queryKey }: QueryFunctionContext<QueryKeyAccount>) => {
|
||||||
const { id } = queryKey[1]
|
const { id } = queryKey[1]
|
||||||
|
|
||||||
return apiInstance<Mastodon.Account>({
|
const res = await apiInstance<Mastodon.Account>({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
url: `accounts/${id}`
|
url: `accounts/${id}`
|
||||||
}).then(res => res.body)
|
})
|
||||||
|
return res.body
|
||||||
}
|
}
|
||||||
|
|
||||||
const useAccountQuery = ({
|
const useAccountQuery = ({
|
||||||
@ -27,15 +28,16 @@ const useAccountQuery = ({
|
|||||||
|
|
||||||
export type QueryKeyAccountInLists = ['AccountInLists', { id: Mastodon.Account['id'] }]
|
export type QueryKeyAccountInLists = ['AccountInLists', { id: Mastodon.Account['id'] }]
|
||||||
|
|
||||||
const accountInListsQueryFunction = ({
|
const accountInListsQueryFunction = async ({
|
||||||
queryKey
|
queryKey
|
||||||
}: QueryFunctionContext<QueryKeyAccountInLists>) => {
|
}: QueryFunctionContext<QueryKeyAccountInLists>) => {
|
||||||
const { id } = queryKey[1]
|
const { id } = queryKey[1]
|
||||||
|
|
||||||
return apiInstance<Mastodon.List[]>({
|
const res = await apiInstance<Mastodon.List[]>({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
url: `accounts/${id}/lists`
|
url: `accounts/${id}/lists`
|
||||||
}).then(res => res.body)
|
})
|
||||||
|
return res.body
|
||||||
}
|
}
|
||||||
|
|
||||||
const useAccountInListsQuery = ({
|
const useAccountInListsQuery = ({
|
||||||
|
@ -6,16 +6,16 @@ import {
|
|||||||
UseMutationOptions,
|
UseMutationOptions,
|
||||||
useQuery,
|
useQuery,
|
||||||
UseQueryOptions
|
UseQueryOptions
|
||||||
} from 'react-query'
|
} from '@tanstack/react-query'
|
||||||
|
|
||||||
type QueryKeyAnnouncement = ['Announcements', { showAll?: boolean }]
|
type QueryKeyAnnouncement = ['Announcements', { showAll?: boolean }]
|
||||||
|
|
||||||
const queryFunction = ({
|
const queryFunction = async ({
|
||||||
queryKey
|
queryKey
|
||||||
}: QueryFunctionContext<QueryKeyAnnouncement>) => {
|
}: QueryFunctionContext<QueryKeyAnnouncement>) => {
|
||||||
const { showAll } = queryKey[1]
|
const { showAll } = queryKey[1]
|
||||||
|
|
||||||
return apiInstance<Mastodon.Announcement[]>({
|
const res = await apiInstance<Mastodon.Announcement[]>({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
url: `announcements`,
|
url: `announcements`,
|
||||||
...(showAll && {
|
...(showAll && {
|
||||||
@ -23,7 +23,8 @@ const queryFunction = ({
|
|||||||
with_dismissed: 'true'
|
with_dismissed: 'true'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}).then(res => res.body)
|
})
|
||||||
|
return res.body
|
||||||
}
|
}
|
||||||
|
|
||||||
const useAnnouncementQuery = ({
|
const useAnnouncementQuery = ({
|
||||||
|
@ -8,7 +8,7 @@ import {
|
|||||||
UseMutationOptions,
|
UseMutationOptions,
|
||||||
useQuery,
|
useQuery,
|
||||||
UseQueryOptions
|
UseQueryOptions
|
||||||
} from 'react-query'
|
} from '@tanstack/react-query'
|
||||||
|
|
||||||
export type QueryKeyApps = ['Apps']
|
export type QueryKeyApps = ['Apps']
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
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 { useQuery, UseQueryOptions } from '@tanstack/react-query'
|
||||||
|
|
||||||
type QueryKeyEmojis = ['Emojis']
|
type QueryKeyEmojis = ['Emojis']
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import apiGeneral from '@api/general'
|
import apiGeneral from '@api/general'
|
||||||
import { AxiosError } from 'axios'
|
import { AxiosError } from 'axios'
|
||||||
import { QueryFunctionContext, useQuery, UseQueryOptions } from 'react-query'
|
import { QueryFunctionContext, useQuery, UseQueryOptions } from '@tanstack/react-query'
|
||||||
|
|
||||||
export type QueryKeyInstance = ['Instance', { domain?: string }]
|
export type QueryKeyInstance = ['Instance', { domain?: string }]
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import {
|
|||||||
UseMutationOptions,
|
UseMutationOptions,
|
||||||
useQuery,
|
useQuery,
|
||||||
UseQueryOptions
|
UseQueryOptions
|
||||||
} from 'react-query'
|
} from '@tanstack/react-query'
|
||||||
|
|
||||||
export type QueryKeyLists = ['Lists']
|
export type QueryKeyLists = ['Lists']
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import { AxiosError } from 'axios'
|
|||||||
import i18next from 'i18next'
|
import i18next from 'i18next'
|
||||||
import { RefObject } from 'react'
|
import { RefObject } from 'react'
|
||||||
import FlashMessage from 'react-native-flash-message'
|
import FlashMessage from 'react-native-flash-message'
|
||||||
import { useMutation, useQuery, UseQueryOptions } from 'react-query'
|
import { useMutation, useQuery, UseQueryOptions } from '@tanstack/react-query'
|
||||||
|
|
||||||
type AccountWithSource = Mastodon.Account & Required<Pick<Mastodon.Account, 'source'>>
|
type AccountWithSource = Mastodon.Account & Required<Pick<Mastodon.Account, 'source'>>
|
||||||
|
|
||||||
|
@ -6,25 +6,26 @@ import {
|
|||||||
UseMutationOptions,
|
UseMutationOptions,
|
||||||
useQuery,
|
useQuery,
|
||||||
UseQueryOptions
|
UseQueryOptions
|
||||||
} from 'react-query'
|
} from '@tanstack/react-query'
|
||||||
|
|
||||||
export type QueryKeyRelationship = [
|
export type QueryKeyRelationship = [
|
||||||
'Relationship',
|
'Relationship',
|
||||||
{ id: Mastodon.Account['id'] }
|
{ id: Mastodon.Account['id'] }
|
||||||
]
|
]
|
||||||
|
|
||||||
const queryFunction = ({
|
const queryFunction = async ({
|
||||||
queryKey
|
queryKey
|
||||||
}: QueryFunctionContext<QueryKeyRelationship>) => {
|
}: QueryFunctionContext<QueryKeyRelationship>) => {
|
||||||
const { id } = queryKey[1]
|
const { id } = queryKey[1]
|
||||||
|
|
||||||
return apiInstance<Mastodon.Relationship[]>({
|
const res = await apiInstance<Mastodon.Relationship[]>({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
url: `accounts/relationships`,
|
url: `accounts/relationships`,
|
||||||
params: {
|
params: {
|
||||||
'id[]': id
|
'id[]': id
|
||||||
}
|
}
|
||||||
}).then(res => res.body)
|
})
|
||||||
|
return res.body
|
||||||
}
|
}
|
||||||
|
|
||||||
const useRelationshipQuery = ({
|
const useRelationshipQuery = ({
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import apiInstance from '@api/instance'
|
import apiInstance from '@api/instance'
|
||||||
import { AxiosError } from 'axios'
|
import { AxiosError } from 'axios'
|
||||||
import { QueryFunctionContext, useQuery, UseQueryOptions } from 'react-query'
|
import { QueryFunctionContext, useQuery, UseQueryOptions } from '@tanstack/react-query'
|
||||||
|
|
||||||
export type QueryKeySearch = [
|
export type QueryKeySearch = [
|
||||||
'Search',
|
'Search',
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
import apiInstance from '@api/instance'
|
import apiInstance from '@api/instance'
|
||||||
import { AxiosError } from 'axios'
|
import { AxiosError } from 'axios'
|
||||||
import { QueryFunctionContext, useQuery, UseQueryOptions } from 'react-query'
|
import { QueryFunctionContext, useQuery, UseQueryOptions } from '@tanstack/react-query'
|
||||||
|
|
||||||
export type QueryKeyStatus = ['Status', { id: Mastodon.Status['id'] }]
|
export type QueryKeyStatus = ['Status', { id: Mastodon.Status['id'] }]
|
||||||
|
|
||||||
const queryFunction = ({ queryKey }: QueryFunctionContext<QueryKeyStatus>) => {
|
const queryFunction = async ({ queryKey }: QueryFunctionContext<QueryKeyStatus>) => {
|
||||||
const { id } = queryKey[1]
|
const { id } = queryKey[1]
|
||||||
|
|
||||||
return apiInstance<Mastodon.Status>({
|
const res = await apiInstance<Mastodon.Status>({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
url: `statuses/${id}`
|
url: `statuses/${id}`
|
||||||
}).then(res => res.body)
|
})
|
||||||
|
return res.body
|
||||||
}
|
}
|
||||||
|
|
||||||
const useStatusQuery = ({
|
const useStatusQuery = ({
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import apiInstance from '@api/instance'
|
import apiInstance from '@api/instance'
|
||||||
import { AxiosError } from 'axios'
|
import { AxiosError } from 'axios'
|
||||||
import { QueryFunctionContext, useQuery, UseQueryOptions } from 'react-query'
|
import { QueryFunctionContext, useQuery, UseQueryOptions } from '@tanstack/react-query'
|
||||||
|
|
||||||
export type QueryKeyStatusesHistory = [
|
export type QueryKeyStatusesHistory = [
|
||||||
'StatusesHistory',
|
'StatusesHistory',
|
||||||
|
@ -6,7 +6,7 @@ import {
|
|||||||
UseMutationOptions,
|
UseMutationOptions,
|
||||||
useQuery,
|
useQuery,
|
||||||
UseQueryOptions
|
UseQueryOptions
|
||||||
} from 'react-query'
|
} from '@tanstack/react-query'
|
||||||
|
|
||||||
type QueryKeyFollowedTags = ['FollowedTags']
|
type QueryKeyFollowedTags = ['FollowedTags']
|
||||||
const useFollowedTagsQuery = ({
|
const useFollowedTagsQuery = ({
|
||||||
@ -27,10 +27,11 @@ const useFollowedTagsQuery = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
type QueryKeyTags = ['Tags', { tag: string }]
|
type QueryKeyTags = ['Tags', { tag: string }]
|
||||||
const queryFunction = ({ queryKey }: QueryFunctionContext<QueryKeyTags>) => {
|
const queryFunction = async ({ queryKey }: QueryFunctionContext<QueryKeyTags>) => {
|
||||||
const { tag } = queryKey[1]
|
const { tag } = queryKey[1]
|
||||||
|
|
||||||
return apiInstance<Mastodon.Tag>({ method: 'get', url: `tags/${tag}` }).then(res => res.body)
|
const res = await apiInstance<Mastodon.Tag>({ method: 'get', url: `tags/${tag}` })
|
||||||
|
return res.body
|
||||||
}
|
}
|
||||||
const useTagsQuery = ({
|
const useTagsQuery = ({
|
||||||
options,
|
options,
|
||||||
|
@ -11,7 +11,7 @@ import {
|
|||||||
useInfiniteQuery,
|
useInfiniteQuery,
|
||||||
UseInfiniteQueryOptions,
|
UseInfiniteQueryOptions,
|
||||||
useMutation
|
useMutation
|
||||||
} from 'react-query'
|
} from '@tanstack/react-query'
|
||||||
import deleteItem from './timeline/deleteItem'
|
import deleteItem from './timeline/deleteItem'
|
||||||
import editItem from './timeline/editItem'
|
import editItem from './timeline/editItem'
|
||||||
import updateStatusProperty from './timeline/updateStatusProperty'
|
import updateStatusProperty from './timeline/updateStatusProperty'
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import queryClient from '@helpers/queryClient'
|
import queryClient from '@helpers/queryClient'
|
||||||
import { InfiniteData } from 'react-query'
|
import { InfiniteData } from '@tanstack/react-query'
|
||||||
import { MutationVarsTimelineDeleteItem } from '../timeline'
|
import { MutationVarsTimelineDeleteItem } from '../timeline'
|
||||||
|
|
||||||
const deleteItem = ({
|
const deleteItem = ({
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import queryClient from '@helpers/queryClient'
|
import queryClient from '@helpers/queryClient'
|
||||||
import { InfiniteData } from 'react-query'
|
import { InfiniteData } from '@tanstack/react-query'
|
||||||
import { MutationVarsTimelineEditItem } from '../timeline'
|
import { MutationVarsTimelineEditItem } from '../timeline'
|
||||||
|
|
||||||
const editItem = ({
|
const editItem = ({
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import queryClient from '@helpers/queryClient'
|
import queryClient from '@helpers/queryClient'
|
||||||
import { InfiniteData } from 'react-query'
|
import { InfiniteData } from '@tanstack/react-query'
|
||||||
import { MutationVarsTimelineUpdateStatusProperty, TimelineData } from '../timeline'
|
import { MutationVarsTimelineUpdateStatusProperty, TimelineData } from '../timeline'
|
||||||
import updateConversation from './update/conversation'
|
import updateConversation from './update/conversation'
|
||||||
import updateNotification from './update/notification'
|
import updateNotification from './update/notification'
|
||||||
|
@ -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 { QueryFunctionContext, useQuery, UseQueryOptions } from 'react-query'
|
import { QueryFunctionContext, useQuery, UseQueryOptions } from '@tanstack/react-query'
|
||||||
|
|
||||||
type Translations =
|
type Translations =
|
||||||
| {
|
| {
|
||||||
|
@ -2,7 +2,7 @@ import apiInstance from '@api/instance'
|
|||||||
import { store } from '@root/store'
|
import { store } from '@root/store'
|
||||||
import { checkInstanceFeature } from '@utils/slices/instancesSlice'
|
import { checkInstanceFeature } from '@utils/slices/instancesSlice'
|
||||||
import { AxiosError } from 'axios'
|
import { AxiosError } from 'axios'
|
||||||
import { QueryFunctionContext, useQuery, UseQueryOptions } from 'react-query'
|
import { QueryFunctionContext, useQuery, UseQueryOptions } from '@tanstack/react-query'
|
||||||
|
|
||||||
export type QueryKeyTrends = ['Trends', { type: 'tags' | 'statuses' | 'links' }]
|
export type QueryKeyTrends = ['Trends', { type: 'tags' | 'statuses' | 'links' }]
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import {
|
|||||||
QueryFunctionContext,
|
QueryFunctionContext,
|
||||||
useInfiniteQuery,
|
useInfiniteQuery,
|
||||||
UseInfiniteQueryOptions
|
UseInfiniteQueryOptions
|
||||||
} from 'react-query'
|
} from '@tanstack/react-query'
|
||||||
|
|
||||||
export type QueryKeyUsers = [
|
export type QueryKeyUsers = [
|
||||||
'Users',
|
'Users',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user