fix: actually wait for store to load before making requests

This commit is contained in:
ThaUnknown 2025-07-27 20:35:06 +02:00
parent b73ee4a841
commit 51ed969702
No known key found for this signature in database
4 changed files with 7 additions and 6 deletions

View file

@ -1,6 +1,6 @@
{
"name": "ui",
"version": "6.4.91",
"version": "6.4.92",
"license": "BUSL-1.1",
"private": true,
"packageManager": "pnpm@9.15.5",

View file

@ -39,6 +39,7 @@ export const storage = makeDefaultStorage({
maxAge: 31 // The maximum age of the persisted data in days
})
debug('Loading urql client')
storagePromise.promise.finally(() => {
debug('Graphcache storage initialized')
})

View file

@ -1,9 +1,14 @@
import { redirect } from '@sveltejs/kit'
import { SETUP_VERSION } from '$lib'
import { storagePromise } from '$lib/modules/anilist/urql-client'
import { outdatedComponent } from '$lib/modules/update'
export async function load () {
if (await outdatedComponent) return redirect(307, '/update/')
// hydrating the cache re-starts all queries, it's better to wait for cache to hydrate, than waste rate limit on requests which are dumped anyways
// this was previously in anilist/client but it was a top level await, which isn't a great solution, this *should* be better?
await storagePromise.promise
redirect(307, Number(localStorage.getItem('setup-finished')) >= SETUP_VERSION ? '/app/home/' : '/setup')
}

View file

@ -2,7 +2,6 @@ import { error, redirect } from '@sveltejs/kit'
import { dev } from '$app/environment'
import { SETUP_VERSION } from '$lib'
import { storagePromise } from '$lib/modules/anilist/urql-client'
import native from '$lib/modules/native'
import { outdatedComponent } from '$lib/modules/update'
@ -11,8 +10,4 @@ export async function load () {
if (Number(localStorage.getItem('setup-finished')) < SETUP_VERSION) redirect(307, '/setup')
if (await outdatedComponent) redirect(307, '/update/')
// hydrating the cache re-starts all queries, it's better to wait for cache to hydrate, than waste rate limit on requests which are dumped anyways
// this was previously in anilist/client but it was a top level await, which isn't a great solution, this *should* be better?
await storagePromise.promise
}