diff options
| author | Fuwn <[email protected]> | 2025-06-12 22:06:31 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-06-12 22:06:31 -0700 |
| commit | e8612618fb20f779ebe2e85edf32d71961d2f1d4 (patch) | |
| tree | fa8565afb8584bbf55f4f4d496c2c350a5a25210 /src/routes/+layout.svelte | |
| parent | refactor(List): Simplify get-set structure of stateBin usage (diff) | |
| download | due.moe-e8612618fb20f779ebe2e85edf32d71961d2f1d4.tar.xz due.moe-e8612618fb20f779ebe2e85edf32d71961d2f1d4.zip | |
feat: Move remaining localStorage usages to localforage
Diffstat (limited to 'src/routes/+layout.svelte')
| -rw-r--r-- | src/routes/+layout.svelte | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 1dd069a0..d9caca74 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -76,22 +76,22 @@ onMount(async () => { if (browser) { - if (localStorage.getItem('redirect')) { - window.location.href = localStorage.getItem('redirect') ?? '/'; + if (await localforage.getItem('redirect')) { + window.location.href = (await localforage.getItem('redirect')) ?? '/'; - localStorage.removeItem('redirect'); + await localforage.removeItem('redirect'); } window.addEventListener('scroll', handleScroll); - if (localStorage.getItem('commit') !== data.commit) { - localStorage.removeItem('identity'); - localStorage.removeItem('anime'); - localStorage.removeItem('manga'); + if ((await localforage.getItem('commit')) !== data.commit) { + await localforage.removeItem('identity'); await localforage.removeItem('anime'); await localforage.removeItem('manga'); - localStorage.removeItem('lastPruneTimes'); - localStorage.setItem('commit', data.commit); + await localforage.removeItem('anime'); + await localforage.removeItem('manga'); + await localforage.removeItem('lastPruneTimes'); + await localforage.setItem('commit', data.commit); } } @@ -213,9 +213,9 @@ name: $locale().navigation.logOut, url: '#', preventDefault: true, - onClick: () => { - localStorage.removeItem('identity'); - localStorage.removeItem('commit'); + onClick: async () => { + await localforage.removeItem('identity'); + await localforage.removeItem('commit'); document.cookie = 'user=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;'; @@ -235,8 +235,8 @@ <a class="header-item" href={`https://anilist.co/api/v2/oauth/authorize?client_id=${env.PUBLIC_ANILIST_CLIENT_ID}&redirect_uri=${env.PUBLIC_ANILIST_REDIRECT_URI}&response_type=code`} - on:click={() => { - localStorage.setItem( + on:click={async () => { + await localforage.setItem( 'redirect', window.location.origin + window.location.pathname + window.location.search ); |