Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: replace persisted provider with default one #2943

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/app.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{
packages = {
app = unstablePkgs.buildNpmPackage {
npmDepsHash = "sha256-5wMINt346EVAAPt32eRsFvF7m6rH6taeE55Z9tEme1A=";
npmDepsHash = "sha256-/K7Qkq4pjeyrFETev1xIaGK0x2A1k+YZDR0na/32FOo=";
src = ./.;
sourceRoot = "app";
npmFlags = [ "--legacy-peer-deps" "--ignore-scripts" ];
Expand Down
46 changes: 0 additions & 46 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
"@sentry/sveltekit": "^8.29.0",
"@tanstack/match-sorter-utils": "^8.19.4",
"@tanstack/query-core": "^5.55.4",
"@tanstack/query-sync-storage-persister": "^5.55.4",
"@tanstack/svelte-query": "^5.55.4",
"@tanstack/svelte-query-persist-client": "^5.55.4",
"@tanstack/svelte-table": "^8.20.5",
"@tanstack/svelte-virtual": "^3.10.7",
"@unionlabs/client": "^0.0.18",
Expand Down
17 changes: 6 additions & 11 deletions app/src/lib/query-client.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { toast } from "svelte-sonner"
import { browser } from "$app/environment"
import { PersistQueryClientProvider } from "@tanstack/svelte-query-persist-client"
import { createSyncStoragePersister } from "@tanstack/query-sync-storage-persister"
import { MutationCache, QueryCache, QueryClient, QueryClientProvider } from "@tanstack/svelte-query"

const SECOND = 1_000
const MINUTE = 60 * SECOND
const HOUR = 60 * MINUTE

export function createQueryClient() {
const queryClient: QueryClient = new QueryClient({
defaultOptions: {
queries: {
enabled: browser,
gcTime: 1000 * 60 * 60 * 24,
gcTime: HOUR * 1, // 1 hour
refetchOnReconnect: () => !queryClient.isMutating()
}
},
Expand All @@ -34,15 +36,8 @@ export function createQueryClient() {
})
})

const localStoragePersister = createSyncStoragePersister({
key: "SVELTE_QUERY",
storage: typeof window !== "undefined" ? window.localStorage : undefined // Use local storage if in browser
})

return {
queryClient,
QueryClientProvider,
localStoragePersister,
PersistQueryClientProvider
QueryClientProvider
}
}
11 changes: 3 additions & 8 deletions app/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { SvelteQueryDevtools } from "@tanstack/svelte-query-devtools"
import { checkWebGLSupport, deviceWidth } from "$lib/utilities/device.ts"
import { disablePinchToZoom } from "$lib/utilities/disable-pinch-to-zoom.ts"

const { queryClient, localStoragePersister, PersistQueryClientProvider } = createQueryClient()
const { queryClient, QueryClientProvider } = createQueryClient()
if (browser) notifyManager.setScheduler(window.requestAnimationFrame)

onMount(() => {
Expand Down Expand Up @@ -56,10 +56,7 @@ $: updateTheme({ path: $page.url.pathname, activeTheme: "dark" })

<LoadingBar />

<PersistQueryClientProvider
client={queryClient}
persistOptions={{ persister: localStoragePersister }}
>
<QueryClientProvider client={queryClient}>
<ModeWatcher defaultMode="system" />
<Toaster position="bottom-right" expand />

Expand All @@ -76,9 +73,7 @@ $: updateTheme({ path: $page.url.pathname, activeTheme: "dark" })
buttonPosition="bottom-right"
/>
<DevTools />
<!-- will be enabled once powered by index status !-->
<!-- <OnlineStatus /> !-->
</PersistQueryClientProvider>
</QueryClientProvider>

<div
class:crt={$crtEffectEnabled}
Expand Down