Tune queries

This commit is contained in:
xmflsct 2023-01-09 19:18:48 +01:00
parent be772f905d
commit b9c4b139f5
2 changed files with 6 additions and 12 deletions

View File

@ -30,7 +30,7 @@ const TimelineCard: React.FC = () => {
const statusQuery = useStatusQuery({ const statusQuery = useStatusQuery({
status: match?.status ? { ...match.status, uri: status.card.url } : undefined, status: match?.status ? { ...match.status, uri: status.card.url } : undefined,
options: { enabled: false, retry: 1 } options: { enabled: false, retry: false }
}) })
useEffect(() => { useEffect(() => {
if (match?.status) { if (match?.status) {
@ -47,7 +47,7 @@ const TimelineCard: React.FC = () => {
const accountQuery = useAccountQuery({ const accountQuery = useAccountQuery({
account: match?.account ? { ...match?.account, url: status.card.url } : undefined, account: match?.account ? { ...match?.account, url: status.card.url } : undefined,
options: { enabled: false, retry: 1 } options: { enabled: false, retry: false }
}) })
useEffect(() => { useEffect(() => {
if (match?.account) { if (match?.account) {

View File

@ -1,5 +1,7 @@
import { QueryClient } from '@tanstack/react-query' import { QueryClient } from '@tanstack/react-query'
export const globalRetry = (failureCount: number) => failureCount <= 2
export const queryClient = new QueryClient({ export const queryClient = new QueryClient({
defaultOptions: { defaultOptions: {
queries: { queries: {
@ -8,17 +10,9 @@ export const queryClient = new QueryClient({
if ([401, 404].includes(error?.status)) { if ([401, 404].includes(error?.status)) {
return false return false
} }
if (failureCount <= 2) {
return true return globalRetry(failureCount)
} else {
return false
}
} }
} }
},
logger: {
log: log => console.log(log),
warn: () => {},
error: () => {}
} }
}) })