diff --git a/apps/mobile/stores/core/store-interval-update.tsx b/apps/mobile/stores/core/store-interval-update.tsx index 361a7d76..78339469 100644 --- a/apps/mobile/stores/core/store-interval-update.tsx +++ b/apps/mobile/stores/core/store-interval-update.tsx @@ -1,4 +1,5 @@ -import { useSuspenseQueries } from '@tanstack/react-query' +import { useAuth } from '@clerk/clerk-expo' +import { useQueries } from '@tanstack/react-query' import type { FC } from 'react' import { useCategoryListQueryOptions } from '../category/hooks' import { useTransactionListQueryOptions } from '../transaction/hooks' @@ -12,9 +13,12 @@ export type StoreIntervalUpdateProps = { export const StoreIntervalUpdate: FC = ({ interval = STORE_SYNC_INTERVAL, }) => { + const { isSignedIn } = useAuth() + const queryOptions: StoreHookQueryOptions = { refetchInterval: interval, refetchIntervalInBackground: true, + enabled: isSignedIn, } const categoryListQueryOptions = useCategoryListQueryOptions(queryOptions) const transactionListQueryOptions = useTransactionListQueryOptions( @@ -22,8 +26,8 @@ export const StoreIntervalUpdate: FC = ({ queryOptions, ) - useSuspenseQueries({ - queries: [{ ...categoryListQueryOptions }, transactionListQueryOptions], + useQueries({ + queries: [categoryListQueryOptions, transactionListQueryOptions], }) return null diff --git a/apps/mobile/stores/core/stores.d.ts b/apps/mobile/stores/core/stores.d.ts index cb499abd..1686339a 100644 --- a/apps/mobile/stores/core/stores.d.ts +++ b/apps/mobile/stores/core/stores.d.ts @@ -1,4 +1,5 @@ export type StoreHookQueryOptions = { refetchInterval?: number refetchIntervalInBackground?: boolean + enabled?: boolean }