From 07420fd7e7d597dd6f1862ead032c3762bd75deb Mon Sep 17 00:00:00 2001 From: DIYgod Date: Thu, 13 Jul 2023 12:22:37 +0100 Subject: [PATCH] feat: remove react-query-persist-client --- package.json | 2 -- pnpm-lock.yaml | 10 ---------- src/app/providers.tsx | 37 ++++--------------------------------- src/lib/persister.client.ts | 24 ------------------------ 4 files changed, 4 insertions(+), 69 deletions(-) delete mode 100644 src/lib/persister.client.ts diff --git a/package.json b/package.json index 28ad04ca..ce59dee7 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,6 @@ "@supercharge/request-ip": "1.2.0", "@tanstack/react-query": "4.29.19", "@tanstack/react-query-devtools": "4.29.19", - "@tanstack/react-query-persist-client": "4.29.19", "@uiw/codemirror-extensions-events": "4.21.7", "@urql/core": "4.0.11", "ahooks": "3.7.8", @@ -84,7 +83,6 @@ "hast-util-to-text": "3.1.2", "i18next": "23.2.11", "i18next-resources-to-backend": "1.1.4", - "idb-keyval": "6.2.1", "immer": "10.0.2", "ioredis": "5.3.2", "isomorphic-dompurify": "1.8.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e70799fd..d5c653a4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -104,9 +104,6 @@ dependencies: '@tanstack/react-query-devtools': specifier: 4.29.19 version: 4.29.19(@tanstack/react-query@4.29.19)(react-dom@18.2.0)(react@18.2.0) - '@tanstack/react-query-persist-client': - specifier: 4.29.19 - version: 4.29.19(@tanstack/react-query@4.29.19) '@uiw/codemirror-extensions-events': specifier: 4.21.7 version: 4.21.7(@codemirror/view@6.14.1) @@ -167,9 +164,6 @@ dependencies: i18next-resources-to-backend: specifier: 1.1.4 version: 1.1.4 - idb-keyval: - specifier: 6.2.1 - version: 6.2.1 immer: specifier: 10.0.2 version: 10.0.2 @@ -8312,10 +8306,6 @@ packages: safer-buffer: 2.1.2 dev: false - /idb-keyval@6.2.1: - resolution: {integrity: sha512-8Sb3veuYCyrZL+VBt9LJfZjLUPWVvqn8tG28VqYNFCo43KHcKuq+b4EiXGeuaLAQWL2YmyDgMp2aSpH9JHsEQg==} - dev: false - /idb@7.1.1: resolution: {integrity: sha512-gchesWBzyvGHRO9W8tzUWFDycow5gwjvFKfyV9FF32Y7F50yZMp7mP+T2mJIWFx49zicqyC4uefHM17o6xKIVQ==} dev: true diff --git a/src/app/providers.tsx b/src/app/providers.tsx index ac58d54b..121c0816 100644 --- a/src/app/providers.tsx +++ b/src/app/providers.tsx @@ -8,8 +8,7 @@ import { NotificationModal, NotificationModalColorScheme, } from "@crossbell/notification" -import { QueryClient } from "@tanstack/react-query" -import { PersistQueryClientProvider } from "@tanstack/react-query-persist-client" +import { QueryClient, QueryClientProvider } from "@tanstack/react-query" import { ModalStackProvider } from "~/components/ui/ModalStack" // eslint-disable-next-line import/no-unresolved @@ -19,7 +18,6 @@ import { useNProgress } from "~/hooks/useNProgress" import { APP_NAME, WALLET_CONNECT_V2_PROJECT_ID } from "~/lib/env" import { filterNotificationCharacter } from "~/lib/filter-character" import { toGateway } from "~/lib/ipfs-parser" -import { createIDBPersister } from "~/lib/persister.client" import { urlComposer } from "~/lib/url-composer" import { LangProvider } from "~/providers/LangProvider" @@ -29,8 +27,6 @@ const wagmiConfig = createWagmiConfig({ walletConnectV2ProjectId: WALLET_CONNECT_V2_PROJECT_ID, }) -const persister = createIDBPersister() - const colorScheme: NotificationModalColorScheme = { text: `rgb(var(--tw-color-zinc-800))`, textSecondary: `rgb(var(--tw-color-gray-600))`, @@ -49,36 +45,11 @@ export default function Providers({ useMobileLayout() useNProgress() - const [queryClient] = useState( - () => - new QueryClient({ - defaultOptions: { - queries: { - cacheTime: 1000 * 60 * 60 * 24, // 24 hours - }, - }, - }), - ) + const [queryClient] = useState(() => new QueryClient()) return ( - { - const queryIsReadyForPersistance = - query.state.status === "success" - if (queryIsReadyForPersistance) { - return !((query.state?.data as any)?.pages?.length > 1) - } else { - return false - } - }, - }, - }} - > + - + ) } diff --git a/src/lib/persister.client.ts b/src/lib/persister.client.ts deleted file mode 100644 index 2ab0f7eb..00000000 --- a/src/lib/persister.client.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { del, get, set } from "idb-keyval" - -import { - PersistedClient, - Persister, -} from "@tanstack/react-query-persist-client" - -/** - * Creates an Indexed DB persister - * @see https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API - */ -export function createIDBPersister(idbValidKey: IDBValidKey = "reactQuery") { - return { - persistClient: async (client: PersistedClient) => { - set(idbValidKey, client) - }, - restoreClient: async () => { - return await get(idbValidKey) - }, - removeClient: async () => { - await del(idbValidKey) - }, - } as Persister -}