From 4dba304af2661ace845822f6f2b61c78b5f83c2f Mon Sep 17 00:00:00 2001 From: Robonau <30987265+Robonau@users.noreply.github> Date: Sat, 9 Nov 2024 16:22:25 +0000 Subject: [PATCH 1/4] change back --- src/lib/simpleStores.svelte.ts | 340 +++++++++++++++++++-------------- 1 file changed, 198 insertions(+), 142 deletions(-) diff --git a/src/lib/simpleStores.svelte.ts b/src/lib/simpleStores.svelte.ts index eb65225..802e4b8 100644 --- a/src/lib/simpleStores.svelte.ts +++ b/src/lib/simpleStores.svelte.ts @@ -13,7 +13,7 @@ import { type OperationResultStore } from '@urql/svelte'; import type { ResultOf, VariablesOf } from '$lib/gql/graphql'; -import { writable } from 'svelte/store'; +import { get, writable } from 'svelte/store'; import type { ToastStore } from './components/Toast/types'; import { deleteGlobalMeta, @@ -26,6 +26,7 @@ import { client } from './gql/graphqlClient'; import type { presetConst } from './presets'; import type { TriState } from './util.svelte'; import { browser } from '$app/environment'; +import { untrack } from 'svelte'; // function getObjectEntries(obj: T): [keyof T, T[keyof T]][] { // return Object.entries(obj) as [keyof T, T[keyof T]][]; @@ -139,15 +140,20 @@ class LocalStore { this.key = key; if (browser) { const item = localStorage.getItem(this.key); - if (item) this.val = this.#deserialize(item); + if (item) this.val = this.deserialize(item); } + $effect.root(() => { + $effect(() => { + localStorage.setItem(key, this.serialize(this.value)); + }); + }); } - #serialize(value: T): string { + private serialize(value: T): string { return JSON.stringify(value); } - #deserialize(item: string): T { + private deserialize(item: string): T { return JSON.parse(item); } @@ -157,7 +163,7 @@ class LocalStore { set value(value: T) { this.val = value; - localStorage.setItem(this.key, this.#serialize(value)); + localStorage.setItem(this.key, this.serialize(value)); } } @@ -165,10 +171,10 @@ function localStore(key: string, value: T) { return new LocalStore(key, value); } -function GMState() { - const store = localStore('GlobalMeta', trueDefaults); - let runningMutations = false; - const mutations: Map< +class GMState { + private store = localStore('GlobalMeta', trueDefaults); + private runningMutations = false; + private mutations: Map< string, OperationResultSource< | OperationResult< @@ -181,31 +187,76 @@ function GMState() { > > > = new Map(); - let unSub = () => {}; - const Meta = queryStore({ - client, - query: metas - }); - - async function startRunMutations() { - if (runningMutations) return; - runningMutations = true; + private unSub = () => {}; + constructor() { + $effect.root(() => { + const Meta = queryStore({ + client, + query: metas + }); + + this.unSub = Meta.subscribe((queryResult) => { + this.store.value = this.extractGlobalMeta(queryResult); + if (queryResult.fetching) return; + this.unSub(); + }); + $effect(() => { + for (const key of getObjectKeys(trueDefaults)) { + const stringValue = JSON.stringify(this.store.value[key]); + const metaKey = metaKeyBase + key; + const existingValue = get(Meta).data?.metas?.nodes.find( + (e) => e.key === metaKey + )?.value; + + if (stringValue !== existingValue) { + const variables = { key: metaKey, value: stringValue }; + if (stringValue !== JSON.stringify(trueDefaults[key])) { + this.mutations.set( + key, + client.mutation(setGlobalMeta, variables) + ); + continue; + } + if (existingValue !== undefined) { + this.mutations.set( + key, + client.mutation(deleteGlobalMeta, variables) + ); + continue; + } + if ( + this.store.value[key] === undefined && + trueDefaults[key] !== undefined + ) { + (this.store.value[key] as (typeof trueDefaults)[typeof key]) = + trueDefaults[key]; + } + } + } + this.startRunMutations(); + }); + }); + } + + private async startRunMutations() { + if (this.runningMutations) return; + this.runningMutations = true; let prom: Promise | undefined = undefined; - while (mutations.size > 0) { - const key = Array.from(mutations.keys())[0]; - const mutation = mutations.get(key); - mutations.delete(key); + while (this.mutations.size > 0) { + const key = Array.from(this.mutations.keys())[0]; + const mutation = this.mutations.get(key); + this.mutations.delete(key); prom = mutation?.toPromise(); await prom; } await prom; - runningMutations = false; + this.runningMutations = false; } - function extractGlobalMeta( + private extractGlobalMeta( queryResult: OperationResultState> ): typeof trueDefaults { - const globalMetaCopy = $state.snapshot(store.value); + const globalMetaCopy = $state.snapshot(this.store.value); const metas = queryResult.data?.metas?.nodes || []; getObjectKeys(trueDefaults).forEach( (key: T) => { @@ -223,57 +274,42 @@ function GMState() { ); return globalMetaCopy; } - unSub = Meta.subscribe((queryResult) => { - store.value = extractGlobalMeta(queryResult); - if (queryResult.fetching) return; - unSub(); - }); - - const ret = {} as typeof trueDefaults; - - getObjectKeys(trueDefaults).forEach((key) => { - Object.defineProperty(ret, key, { - get: function () { - if (store.value[key] === undefined) { - (store.value[key] as unknown) = trueDefaults[key]; - } - return store.value[key]; - }, - set: function (value: (typeof trueDefaults)[typeof key]) { - (store.value[key] as unknown) = value; - const stringValue = JSON.stringify(value); - if (stringValue !== JSON.stringify(trueDefaults[key])) { - mutations.set( - key, - client.mutation(setGlobalMeta, { - key: metaKeyBase + key, - value: stringValue - }) - ); - startRunMutations(); - return; - } - mutations.set( - key, - client.mutation(deleteGlobalMeta, { key: metaKeyBase + key }) - ); - startRunMutations(); + + private isRecord(obj: unknown): obj is Record { + return obj === Object(obj); + } + + private traverse>(value: T, defaults: T) { + getObjectKeys(value).forEach((key) => { + if (value[key] === undefined) { + value[key] = defaults[key]; } + if (this.isRecord(value[key]) && this.isRecord(defaults[key])) + this.traverse(value[key], defaults[key]); }); - }); + } - return ret; -} + get value() { + this.traverse(this.store.value, trueDefaults); + return this.store.value; + } -export const gmState = GMState(); + set value(val: typeof trueDefaults) { + this.store.value = val; + } +} -function MMState() { - let _id: number = -1; - let store = $state(gmState.mangaMetaDefaults); - let unSub = () => {}; - let MMeta: OperationResultStore> | null = null; - let isRunningMutations = false; - const mutations: Map< +export const gmState = new GMState(); + +class MMState { + private _id: number = -1; + private store = $state( + gmState.value.mangaMetaDefaults + ); + private unSub = () => {}; + private MMeta: OperationResultStore> | null = null; + private isRunningMutations = false; + private mutations: Map< string, OperationResultSource< | OperationResult< @@ -286,27 +322,106 @@ function MMState() { > > > = new Map(); - async function runPendingMutations() { - if (isRunningMutations) return; - isRunningMutations = true; + + constructor() { + $effect.root(() => { + $effect(() => { + for (const key of getObjectKeys( + untrack(() => { + return $state.snapshot(gmState.value.mangaMetaDefaults); + }) + )) { + const serializedValue = JSON.stringify(this.store[key]); + const metaKey = metaKeyBase + key; + const storedValue = untrack(() => { + if (!this.MMeta) return; + return get(this.MMeta).data?.manga?.meta.find( + (e) => e.key === metaKey + )?.value; + }); + if (serializedValue !== storedValue) { + const mutationVariables = { + key: metaKey, + value: serializedValue, + id: this._id + }; + untrack(() => { + if ( + serializedValue !== + JSON.stringify(gmState.value.mangaMetaDefaults[key]) + ) { + this.mutations.set( + key + this.id, + client.mutation(setMangaMeta, mutationVariables) + ); + return; + } + if (storedValue !== undefined) { + this.mutations.set( + key + this.id, + client.mutation(deleteMangaMeta, mutationVariables) + ); + return; + } + if ( + this.store[key] === undefined && + gmState.value.mangaMetaDefaults[key] !== undefined + ) { + (this.store[key] as (typeof this.store)[typeof key]) = + gmState.value.mangaMetaDefaults[key]; + } + }); + } + } + this.runPendingMutations(); + }); + }); + } + + get value() { + return this.store; + } + + set value(val: typeof mangaMetaDefaults) { + this.store = val; + } + + set id(val: number) { + this._id = val; + this.unSub(); + this.MMeta = queryStore({ + client, + query: getManga, + variables: { id: val } + }); + this.unSub = this.MMeta.subscribe((queryResult) => { + this.store = this.extractMangaMeta(queryResult); + if (queryResult.fetching) return; + this.unSub(); + }); + } + + private async runPendingMutations() { + if (this.isRunningMutations) return; + this.isRunningMutations = true; let prom: Promise | undefined = undefined; - while (mutations.size > 0) { - const key = Array.from(mutations.keys())[0]; - const mutation = mutations.get(key); - mutations.delete(key); + while (this.mutations.size > 0) { + const key = Array.from(this.mutations.keys())[0]; + const mutation = this.mutations.get(key); + this.mutations.delete(key); prom = mutation?.toPromise(); await prom; } await prom; - isRunningMutations = false; + this.isRunningMutations = false; } - function extractMangaMeta( + private extractMangaMeta( queryResult: OperationResultState> ): typeof mangaMetaDefaults { - const clonedStore = $state.snapshot(store); + const clonedStore = $state.snapshot(this.store); const metas = queryResult.data?.manga.meta || []; - const Defaults = $state.snapshot(gmState.mangaMetaDefaults); + const Defaults = $state.snapshot(gmState.value.mangaMetaDefaults); getObjectKeys(Defaults).forEach( (key: T) => { const matchedMeta = metas.find( @@ -323,65 +438,6 @@ function MMState() { ); return clonedStore; } - - const ret = { - set id(val: number) { - _id = val; - unSub(); - MMeta = queryStore({ - client, - query: getManga, - variables: { id: val } - }); - unSub = MMeta.subscribe((queryResult) => { - store = extractMangaMeta(queryResult); - if (queryResult.fetching) return; - unSub(); - }); - }, - get id() { - return _id; - } - } as typeof mangaMetaDefaults & { id: number }; - - getObjectKeys(mangaMetaDefaults).forEach((key) => { - Object.defineProperty(ret, key, { - get: function () { - if (store[key] === undefined) { - (store[key] as unknown) = gmState.mangaMetaDefaults[key]; - } - return store[key]; - }, - set: function (value: (typeof mangaMetaDefaults)[typeof key]) { - (store[key] as unknown) = value; - const serializedValue = JSON.stringify(value); - if ( - serializedValue !== JSON.stringify(gmState.mangaMetaDefaults[key]) - ) { - mutations.set( - key + _id, - client.mutation(setMangaMeta, { - key: metaKeyBase + key, - value: serializedValue, - id: _id - }) - ); - runPendingMutations(); - return; - } - mutations.set( - key + _id, - client.mutation(deleteMangaMeta, { - key: metaKeyBase + key, - id: _id - }) - ); - runPendingMutations(); - } - }); - }); - - return ret; } -export const mmState = MMState(); +export const mmState = new MMState(); From 6bdc98555985b10444da2a2b7acc48a9d849c5c3 Mon Sep 17 00:00:00 2001 From: Robonau <30987265+Robonau@users.noreply.github> Date: Sat, 9 Nov 2024 16:47:54 +0000 Subject: [PATCH 2/4] fix States --- src/lib/components/lightswitch.svelte | 14 ++-- src/lib/gql/graphqlClient.ts | 8 +-- src/lib/simpleStores.svelte.ts | 35 ++++----- src/routes/(app)/(library)/+page.svelte | 55 +++++++------- .../(app)/(library)/LibraryFilterModal.svelte | 18 ++--- .../browse/HorisontalmangaElement.svelte | 11 +-- .../(app)/browse/extensions/+page.svelte | 2 +- src/routes/(app)/browse/globalSearch.svelte | 9 +-- .../migrate/source/[SourceID]/+page.svelte | 17 ++--- .../browse/source/[sourceID]/Grid.svelte | 17 ++--- src/routes/(app)/browse/sources/+page.svelte | 2 +- src/routes/(app)/history/+page.svelte | 21 +++--- .../(manga)/ChaptersFilterModal.svelte | 28 ++++---- .../manga/[MangaID]/(manga)/InfoSide.svelte | 10 +-- .../manga/[MangaID]/(manga)/NotesModal.svelte | 4 +- .../[MangaID]/(manga)/chaptersSide.svelte | 15 ++-- .../chapter/[ChapterID]/+page.svelte | 72 +++++++++++-------- .../chapter/[ChapterID]/chapterDrawer.svelte | 23 +++--- src/routes/(app)/manga/[MangaID]/util.ts | 14 ++-- src/routes/(app)/settings/+page.svelte | 10 +-- .../(app)/settings/LibrarySettings.svelte | 2 +- .../(app)/settings/MangaSettingsModal.svelte | 31 ++++---- .../(app)/settings/ReaderDefaultsModal.svelte | 27 ++++--- src/routes/(app)/updates/+page.svelte | 21 +++--- src/routes/+layout.svelte | 12 +++- 25 files changed, 256 insertions(+), 222 deletions(-) diff --git a/src/lib/components/lightswitch.svelte b/src/lib/components/lightswitch.svelte index c99ea1e..279a4e2 100644 --- a/src/lib/components/lightswitch.svelte +++ b/src/lib/components/lightswitch.svelte @@ -44,9 +44,9 @@ }; // State - let trackBg = $derived(!gmState.dark ? bgLight : bgDark); - let thumbBg = $derived(!gmState.dark ? bgDark : bgLight); - let thumbPosition = $derived(!gmState.dark ? 'translate-x-[100%]' : ''); + let trackBg = $derived(!gmState.value.dark ? bgLight : bgDark); + let thumbBg = $derived(!gmState.value.dark ? bgDark : bgLight); + let thumbPosition = $derived(!gmState.value.dark ? 'translate-x-[100%]' : ''); // Reactive let classesTrack = $derived( `cursor-pointer ${cTransition} ${width} ${height} ${ring} ${rounded} ${trackBg} ${className ?? ''}` @@ -55,16 +55,16 @@ `aspect-square scale-[0.8] flex justify-center items-center ${cTransition} ${height} ${rounded} ${thumbBg} ${thumbPosition}` ); let classesIcon = $derived( - `w-[70%] aspect-square ${!gmState.dark ? fillLight : fillDark}` + `w-[70%] aspect-square ${!gmState.value.dark ? fillLight : fillDark}` ); diff --git a/src/lib/gql/graphqlClient.ts b/src/lib/gql/graphqlClient.ts index 687b084..be0bc17 100644 --- a/src/lib/gql/graphqlClient.ts +++ b/src/lib/gql/graphqlClient.ts @@ -751,11 +751,11 @@ function fetchExtensionsUpdater( ) { if (!data?.fetchExtensions) return; let filteredExtensions = data.fetchExtensions.extensions; - if (!gmState.nsfw) + if (!gmState.value.nsfw) filteredExtensions = filteredExtensions.filter((e) => !e.isNsfw); filteredExtensions.forEach((e) => { cache.writeFragment(ExtensionTypeFragment, e, { - isNsfw: gmState.nsfw ? null : false + isNsfw: gmState.value.nsfw ? null : false }); }); lastFetched.set(new Date()); @@ -874,7 +874,7 @@ function updateExtentionsList( cache.updateQuery( { query: getExtensions, - variables: { isNsfw: gmState.nsfw ? null : false } + variables: { isNsfw: gmState.value.nsfw ? null : false } }, (extensionsData) => { if (!extensionsData) return extensionsData; @@ -900,7 +900,7 @@ function updateSourcesList( cache.updateQuery( { query: getSources, - variables: { isNsfw: gmState.nsfw ? null : false } + variables: { isNsfw: gmState.value.nsfw ? null : false } }, (sourcesData) => { if (!sourcesData) return sourcesData; diff --git a/src/lib/simpleStores.svelte.ts b/src/lib/simpleStores.svelte.ts index 802e4b8..003484e 100644 --- a/src/lib/simpleStores.svelte.ts +++ b/src/lib/simpleStores.svelte.ts @@ -117,12 +117,6 @@ const trueDefaults = { mangaMetaDefaults, downloadsBadge: true, unreadBadge: true, - mangaUpdatesTracking: { - enabled: false, - username: '', - password: '', - Authorization: '' - }, libraryCategoryTotalCounts: false, DownloadAllChaptersOnAddToLibrary: false, DeleteAllChaptersOnRemoveFromLibrary: false, @@ -224,13 +218,6 @@ class GMState { ); continue; } - if ( - this.store.value[key] === undefined && - trueDefaults[key] !== undefined - ) { - (this.store.value[key] as (typeof trueDefaults)[typeof key]) = - trueDefaults[key]; - } } } this.startRunMutations(); @@ -363,13 +350,6 @@ class MMState { ); return; } - if ( - this.store[key] === undefined && - gmState.value.mangaMetaDefaults[key] !== undefined - ) { - (this.store[key] as (typeof this.store)[typeof key]) = - gmState.value.mangaMetaDefaults[key]; - } }); } } @@ -378,7 +358,22 @@ class MMState { }); } + private isRecord(obj: unknown): obj is Record { + return obj === Object(obj); + } + + private traverse>(value: T, defaults: T) { + getObjectKeys(value).forEach((key) => { + if (value[key] === undefined) { + value[key] = defaults[key]; + } + if (this.isRecord(value[key]) && this.isRecord(defaults[key])) + this.traverse(value[key], defaults[key]); + }); + } + get value() { + this.traverse(this.store, gmState.value.mangaMetaDefaults); return this.store; } diff --git a/src/routes/(app)/(library)/+page.svelte b/src/routes/(app)/(library)/+page.svelte index 1e37dca..4ef0e63 100644 --- a/src/routes/(app)/(library)/+page.svelte +++ b/src/routes/(app)/(library)/+page.svelte @@ -249,7 +249,7 @@ let filteredMangas = $derived( mangas.value.data?.category?.mangas.nodes.filter((ele) => { if (!ele.inLibrary) return false; - if (gmState.ignoreFiltersWhenSearching) { + if (gmState.value.ignoreFiltersWhenSearching) { if ( parsedQuery !== null && specificSearch(ele, parsedQuery).findIndex((e) => e === false) === -1 @@ -258,15 +258,17 @@ } } - if (gmState.Downloaded === 1 && ele.downloadCount === 0) return false; - if (gmState.Downloaded === 2 && ele.downloadCount !== 0) return false; + if (gmState.value.Downloaded === 1 && ele.downloadCount === 0) + return false; + if (gmState.value.Downloaded === 2 && ele.downloadCount !== 0) + return false; - if (gmState.Unread === 1 && ele.unreadCount === 0) return false; - if (gmState.Unread === 2 && ele.unreadCount !== 0) return false; + if (gmState.value.Unread === 1 && ele.unreadCount === 0) return false; + if (gmState.value.Unread === 2 && ele.unreadCount !== 0) return false; - if (gmState.Tracked === 1 && ele.trackRecords.nodes.length === 0) + if (gmState.value.Tracked === 1 && ele.trackRecords.nodes.length === 0) return false; - if (gmState.Tracked === 2 && ele.trackRecords.nodes.length !== 0) + if (gmState.value.Tracked === 2 && ele.trackRecords.nodes.length !== 0) return false; if ( @@ -295,11 +297,11 @@ }); let sortedMangas = $derived( filteredMangas - ? gmState.Sort === sort.Random + ? gmState.value.Sort === sort.Random ? shuffle([...filteredMangas]) : [...filteredMangas].sort((a, b) => { let tru = true; - switch (gmState.Sort) { + switch (gmState.value.Sort) { case sort.ID: tru = a.id > b.id; break; @@ -326,7 +328,7 @@ break; } - if (gmState.Asc) tru = !tru; + if (gmState.value.Asc) tru = !tru; return tru ? -1 : 1; }) : undefined @@ -344,10 +346,10 @@
- {#if gmState.Display === display.Comfortable} + {#if gmState.value.Display === display.Comfortable}
@@ -366,7 +368,7 @@ {#snippet lead()} {cat.name} - {#if gmState.libraryCategoryTotalCounts} + {#if gmState.value.libraryCategoryTotalCounts} @@ -384,10 +386,10 @@
- {#if gmState.Display === display.Comfortable} + {#if gmState.value.Display === display.Comfortable}
@@ -437,14 +439,15 @@ thumbnailUrl={manga.thumbnailUrl ?? ''} title={manga.title} class="select-none {$selectMode && 'opacity-80'}" - rounded="{gmState.Display === display.Compact && + rounded="{gmState.value.Display === display.Compact && 'rounded-lg'} - {gmState.Display === display.Comfortable && 'rounded-none rounded-t-lg'}" + {gmState.value.Display === display.Comfortable && 'rounded-none rounded-t-lg'}" >
- {#if manga.downloadCount && gmState.downloadsBadge} + {#if manga.downloadCount && gmState.value.downloadsBadge}
{/if} - {#if manga.unreadCount && gmState.unreadBadge} + {#if manga.unreadCount && gmState.value.unreadBadge}
{/if} - {#if gmState.Display === display.Compact} + {#if gmState.value.Display === display.Compact}
@@ -489,7 +492,7 @@
{/if} - {#if gmState.Display === display.Comfortable} + {#if gmState.value.Display === display.Comfortable}
{/if}
- {#if !intersecting && gmState.Display === display.Comfortable} + {#if !intersecting && gmState.value.Display === display.Comfortable}
{/if} {/snippet} diff --git a/src/routes/(app)/(library)/LibraryFilterModal.svelte b/src/routes/(app)/(library)/LibraryFilterModal.svelte index 8411224..dc0be0f 100644 --- a/src/routes/(app)/(library)/LibraryFilterModal.svelte +++ b/src/routes/(app)/(library)/LibraryFilterModal.svelte @@ -79,7 +79,7 @@
{#if $tabSet === 0} Unread Downloaded {#each enumKeys(sort) as value} {:else if $tabSet === 2} Category Total Counts Downloads Badge Unread Badge @@ -158,7 +158,7 @@ > {#each enumKeys(display) as value} - {#if gmState.Display === display.Compact} + {#if gmState.value.Display === display.Compact}
@@ -84,7 +85,7 @@ {/if}
- {#if gmState.Display === display.Comfortable} + {#if gmState.value.Display === display.Comfortable}
{:else}
- {#if gmState.Display === display.Comfortable} + {#if gmState.value.Display === display.Comfortable}
{/if} {/if} diff --git a/src/routes/(app)/browse/extensions/+page.svelte b/src/routes/(app)/browse/extensions/+page.svelte index ff0c223..b858655 100644 --- a/src/routes/(app)/browse/extensions/+page.svelte +++ b/src/routes/(app)/browse/extensions/+page.svelte @@ -54,7 +54,7 @@ extensions = queryState({ client, query: getExtensions, - variables: { isNsfw: gmState.nsfw ? null : false } + variables: { isNsfw: gmState.value.nsfw ? null : false } }); } diff --git a/src/routes/(app)/browse/globalSearch.svelte b/src/routes/(app)/browse/globalSearch.svelte index d439a8f..8cdf279 100644 --- a/src/routes/(app)/browse/globalSearch.svelte +++ b/src/routes/(app)/browse/globalSearch.svelte @@ -48,7 +48,7 @@ const client = getContextClient(); client - .query(getSources, { isNsfw: gmState.nsfw ? null : false }) + .query(getSources, { isNsfw: gmState.value.nsfw ? null : false }) .toPromise() .then((ee) => { rawSources.update((e) => { @@ -214,12 +214,13 @@
- {#if gmState.Display === display.Comfortable} + {#if gmState.value.Display === display.Comfortable}
diff --git a/src/routes/(app)/browse/migrate/source/[SourceID]/+page.svelte b/src/routes/(app)/browse/migrate/source/[SourceID]/+page.svelte index eec41af..402063a 100644 --- a/src/routes/(app)/browse/migrate/source/[SourceID]/+page.svelte +++ b/src/routes/(app)/browse/migrate/source/[SourceID]/+page.svelte @@ -51,10 +51,10 @@
- {#if gmState.Display === display.Comfortable} + {#if gmState.value.Display === display.Comfortable}
@@ -85,10 +85,11 @@ - {#if gmState.Display === display.Compact} + {#if gmState.value.Display === display.Compact}
@@ -101,7 +102,7 @@
{/if}
- {#if gmState.Display === display.Comfortable} + {#if gmState.value.Display === display.Comfortable}
{/if}
- {#if !intersecting && gmState.Display === display.Comfortable} + {#if !intersecting && gmState.value.Display === display.Comfortable}
{/if} {/snippet} diff --git a/src/routes/(app)/browse/source/[sourceID]/Grid.svelte b/src/routes/(app)/browse/source/[sourceID]/Grid.svelte index 96d6cb5..79dc8a3 100644 --- a/src/routes/(app)/browse/source/[sourceID]/Grid.svelte +++ b/src/routes/(app)/browse/source/[sourceID]/Grid.svelte @@ -148,10 +148,11 @@ - {#if gmState.Display === display.Compact} + {#if gmState.value.Display === display.Compact}
@@ -171,7 +172,7 @@
{/if}
- {#if gmState.Display === display.Comfortable} + {#if gmState.value.Display === display.Comfortable}
{/if}
- {#if !intersecting && gmState.Display === display.Comfortable} + {#if !intersecting && gmState.value.Display === display.Comfortable}
{/if} {/snippet} @@ -205,10 +206,10 @@
- {#if gmState.Display === display.Comfortable} + {#if gmState.value.Display === display.Comfortable}
diff --git a/src/routes/(app)/browse/sources/+page.svelte b/src/routes/(app)/browse/sources/+page.svelte index 9a8680c..6f72a7a 100644 --- a/src/routes/(app)/browse/sources/+page.svelte +++ b/src/routes/(app)/browse/sources/+page.svelte @@ -32,7 +32,7 @@ const sources = queryState({ client, query: getSources, - variables: { isNsfw: gmState.nsfw ? null : false } + variables: { isNsfw: gmState.value.nsfw ? null : false } }); const query = queryParam('q', ssp.string(), { pushHistory: false }); diff --git a/src/routes/(app)/history/+page.svelte b/src/routes/(app)/history/+page.svelte index 05d247e..54ed3ba 100644 --- a/src/routes/(app)/history/+page.svelte +++ b/src/routes/(app)/history/+page.svelte @@ -55,10 +55,10 @@
- {#if gmState.Display === display.Comfortable} + {#if gmState.value.Display === display.Comfortable}
@@ -91,10 +91,11 @@ title={updat.manga.title} titleA="{updat.isDownloaded ? 'Downloaded' : ''} {updat.isBookmarked ? 'Bookmarked' : ''}" - rounded="{gmState.Display === display.Compact && 'rounded-lg'} - {gmState.Display === display.Comfortable && 'rounded-none rounded-t-lg'}" + rounded="{gmState.value.Display === display.Compact && + 'rounded-lg'} + {gmState.value.Display === display.Comfortable && 'rounded-none rounded-t-lg'}" > - {#if gmState.Display === display.Compact} + {#if gmState.value.Display === display.Compact}
@@ -129,7 +130,7 @@ {/if}
- {#if gmState.Display === display.Comfortable} + {#if gmState.value.Display === display.Comfortable}
- {#if gmState.Display === display.Comfortable} + {#if gmState.value.Display === display.Comfortable}
diff --git a/src/routes/(app)/manga/[MangaID]/(manga)/ChaptersFilterModal.svelte b/src/routes/(app)/manga/[MangaID]/(manga)/ChaptersFilterModal.svelte index 09954e3..9723cff 100644 --- a/src/routes/(app)/manga/[MangaID]/(manga)/ChaptersFilterModal.svelte +++ b/src/routes/(app)/manga/[MangaID]/(manga)/ChaptersFilterModal.svelte @@ -85,7 +85,7 @@
{#if $tabSet === 0} Unread Downloaded Groups { - mmState.groupPartials = e.currentTarget.value + mmState.value.groupPartials = e.currentTarget.value .split(',') .map((a) => a.trim()) .filter((a) => a.length > 0); e.currentTarget.value = - mmState.groupPartials?.join(',') ?? ''; + mmState.value.groupPartials?.join(',') ?? ''; }} - value={mmState.groupPartials?.join(',') ?? ''} + value={mmState.value.groupPartials?.join(',') ?? ''} class="input w-1/2" type="text" placeholder="asura,dex,..." @@ -132,7 +132,7 @@ {:else if $tabSet === 1} {#each enumKeys(ChapterSort) as value} { e.stopPropagation(); e.preventDefault(); - mmState.showMissingChapters = !mmState.showMissingChapters; + mmState.value.showMissingChapters = + !mmState.value.showMissingChapters; }} > Show Missing Chapters {#each enumKeys(ChapterTitle) as value}
- {#if mmState.notes} - {mmState.notes} + {#if mmState.value.notes} + {mmState.value.notes} {/if}
diff --git a/src/routes/(app)/manga/[MangaID]/(manga)/NotesModal.svelte b/src/routes/(app)/manga/[MangaID]/(manga)/NotesModal.svelte index 22d57cc..af2168e 100644 --- a/src/routes/(app)/manga/[MangaID]/(manga)/NotesModal.svelte +++ b/src/routes/(app)/manga/[MangaID]/(manga)/NotesModal.svelte @@ -18,8 +18,8 @@
diff --git a/src/routes/(app)/manga/[MangaID]/(manga)/chaptersSide.svelte b/src/routes/(app)/manga/[MangaID]/(manga)/chaptersSide.svelte index 19edb3f..d66b411 100644 --- a/src/routes/(app)/manga/[MangaID]/(manga)/chaptersSide.svelte +++ b/src/routes/(app)/manga/[MangaID]/(manga)/chaptersSide.svelte @@ -212,14 +212,16 @@ filteredChapters ? [...filteredChapters].sort((a, b) => { let tmp = true; - if (mmState.ChapterSort === ChapterSort.Source) { + if (mmState.value.ChapterSort === ChapterSort.Source) { tmp = a.sourceOrder > b.sourceOrder; - } else if (mmState.ChapterSort === ChapterSort['Fetched Date']) { + } else if ( + mmState.value.ChapterSort === ChapterSort['Fetched Date'] + ) { tmp = a.fetchedAt > b.fetchedAt; } else { tmp = a.uploadDate > b.uploadDate; } - if (mmState.ChapterAsc) tmp = !tmp; + if (mmState.value.ChapterAsc) tmp = !tmp; return tmp ? -1 : 1; }) : undefined @@ -289,7 +291,7 @@ {sortedChapters.length} Chapters - {#if mmState.showMissingChapters && missingChapters?.length} + {#if mmState.value.showMissingChapters && missingChapters?.length}
- {mmState.ChapterTitle === ChapterTitle['Source Title'] + {mmState.value.ChapterTitle === + ChapterTitle['Source Title'] ? chapter.name : `Chapter ${chapter.chapterNumber}`}
@@ -468,7 +471,7 @@ ).toLocaleString()}" > {new Date( - mmState.ChapterFetchUpload + mmState.value.ChapterFetchUpload ? parseInt(chapter.uploadDate) : parseInt(chapter.fetchedAt) * 1000 ).toLocaleDateString()}{chapter.isDownloaded diff --git a/src/routes/(app)/manga/[MangaID]/chapter/[ChapterID]/+page.svelte b/src/routes/(app)/manga/[MangaID]/chapter/[ChapterID]/+page.svelte index 09472af..958a39a 100644 --- a/src/routes/(app)/manga/[MangaID]/chapter/[ChapterID]/+page.svelte +++ b/src/routes/(app)/manga/[MangaID]/chapter/[ChapterID]/+page.svelte @@ -52,7 +52,7 @@ /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test( navigator.userAgent ) && - mmState.mobileFullScreenOnChapterPage + mmState.value.mobileFullScreenOnChapterPage ) { document.documentElement.requestFullscreen(); } @@ -61,7 +61,7 @@ /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test( navigator.userAgent ) && - mmState.mobileFullScreenOnChapterPage + mmState.value.mobileFullScreenOnChapterPage ) { document.exitFullscreen(); } @@ -376,7 +376,7 @@ pageElement?.scrollTo({ top: addition + (pageElement.scrollTop + pageElement.clientHeight * decimal), - behavior: mmState.SmoothScroll ? 'smooth' : 'instant' + behavior: mmState.value.SmoothScroll ? 'smooth' : 'instant' }); } @@ -469,7 +469,7 @@ $effect(() => { if ( nextid !== undefined && - mmState.preLoadNextChapter && + mmState.value.preLoadNextChapter && nextid !== preLoadingId ) { untrack(() => { @@ -487,10 +487,10 @@ }); }); $effect(() => { - if (mmState.ReaderMode === Mode.RTL) { - path = layoutToPath(paths.rtl, mmState.NavLayout); + if (mmState.value.ReaderMode === Mode.RTL) { + path = layoutToPath(paths.rtl, mmState.value.NavLayout); } else { - path = layoutToPath(paths.ltr, mmState.NavLayout); + path = layoutToPath(paths.ltr, mmState.value.NavLayout); } }); $effect(() => { @@ -583,35 +583,38 @@
- {#if (mmState.ReaderMode === Mode.RTL || mmState.ReaderMode === Mode.LTR) && mmState.Offset} + {#if (mmState.value.ReaderMode === Mode.RTL || mmState.value.ReaderMode === Mode.LTR) && mmState.value.Offset}
{/if} {#each chapter.pages as page, pageIndex (page)}
{ @@ -626,28 +629,35 @@ }} root={document.querySelector('#page') ?? undefined} bottom={0} - top={mmState.Margins ? 16 : 0} + top={mmState.value.Margins ? 16 : 0} />
{/each} - {#if mmState.doPageIndicator} + {#if mmState.value.doPageIndicator}
diff --git a/src/routes/(app)/manga/[MangaID]/chapter/[ChapterID]/chapterDrawer.svelte b/src/routes/(app)/manga/[MangaID]/chapter/[ChapterID]/chapterDrawer.svelte index 1b98823..852951c 100644 --- a/src/routes/(app)/manga/[MangaID]/chapter/[ChapterID]/chapterDrawer.svelte +++ b/src/routes/(app)/manga/[MangaID]/chapter/[ChapterID]/chapterDrawer.svelte @@ -56,7 +56,7 @@ /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test( navigator.userAgent ) && - mmState.mobileFullScreenOnChapterPage + mmState.value.mobileFullScreenOnChapterPage ) { document.exitFullscreen(); } @@ -65,7 +65,7 @@ /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test( navigator.userAgent ) && - mmState.mobileFullScreenOnChapterPage + mmState.value.mobileFullScreenOnChapterPage ) { document.documentElement.requestFullscreen(); } @@ -129,33 +129,33 @@ Page Margins Page Scale Smooth Scroll - {#if mmState.ReaderMode !== Mode.Vertical} + {#if mmState.value.ReaderMode !== Mode.Vertical} Page Offset {/if}