feat: remove react-query-persist-client

This commit is contained in:
DIYgod 2023-07-13 12:22:37 +01:00
parent c6e263c9d7
commit 07420fd7e7
No known key found for this signature in database
4 changed files with 4 additions and 69 deletions

View File

@ -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",

View File

@ -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

View File

@ -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 (
<WagmiConfig config={wagmiConfig}>
<PersistQueryClientProvider
client={queryClient}
persistOptions={{
persister,
dehydrateOptions: {
shouldDehydrateQuery: (query) => {
const queryIsReadyForPersistance =
query.state.status === "success"
if (queryIsReadyForPersistance) {
return !((query.state?.data as any)?.pages?.length > 1)
} else {
return false
}
},
},
}}
>
<QueryClientProvider client={queryClient}>
<ConnectKitProvider
ipfsLinkToHttpLink={toGateway}
urlComposer={urlComposer}
@ -94,7 +65,7 @@ export default function Providers({
filter={filterNotificationCharacter}
/>
</ConnectKitProvider>
</PersistQueryClientProvider>
</QueryClientProvider>
</WagmiConfig>
)
}

View File

@ -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<PersistedClient>(idbValidKey)
},
removeClient: async () => {
await del(idbValidKey)
},
} as Persister
}