- {JSON.stringify($Migration.error, null, 4)}
+ {JSON.stringify(Migration.value.error, null, 4)}
{:else if sources}
diff --git a/src/routes/(app)/browse/migrate/manga/[MangaID]/+page.svelte b/src/routes/(app)/browse/migrate/manga/[MangaID]/+page.svelte
index a8a8b3a..8ce1212 100644
--- a/src/routes/(app)/browse/migrate/manga/[MangaID]/+page.svelte
+++ b/src/routes/(app)/browse/migrate/manga/[MangaID]/+page.svelte
@@ -12,8 +12,9 @@
import GlobalSearch from '../../../globalSearch.svelte';
import { getModalStore } from '@skeletonlabs/skeleton';
import MigrateModal from './migrateModal.svelte';
- import { getContextClient, queryStore } from '@urql/svelte';
+ import { getContextClient } from '@urql/svelte';
import { getManga } from '$lib/gql/Queries';
+ import { queryState } from '$lib/util.svelte';
interface Props {
data: PageData;
@@ -25,20 +26,21 @@
const query = queryParam('q', ssp.string(), { pushHistory: false });
const client = getContextClient();
- const manga = queryStore({
+ const manga = queryState({
client,
query: getManga,
variables: { id: data.MangaID }
});
- const unSub = manga.subscribe(onSub);
+ let unSub = false;
+ $effect(() => {
+ if (!unSub) onSub(manga.value);
+ });
- function onSub(mangaNow: typeof $manga) {
+ function onSub(mangaNow: typeof manga.value) {
if (mangaNow?.data?.manga?.title) {
$query = mangaNow?.data?.manga?.title;
- setTimeout(() => {
- unSub();
- }, 1);
+ unSub = true;
}
}
@@ -50,13 +52,13 @@
ref: MigrateModal,
props: {
id,
- manga: $manga.data?.manga
+ manga: manga.value.data?.manga
}
}
});
}
-{#if $manga.data?.manga?.title}
-
+{#if manga.value.data?.manga?.title}
+
{/if}
diff --git a/src/routes/(app)/browse/migrate/manga/[MangaID]/migrateModal.svelte b/src/routes/(app)/browse/migrate/manga/[MangaID]/migrateModal.svelte
index c7da00a..847a14a 100644
--- a/src/routes/(app)/browse/migrate/manga/[MangaID]/migrateModal.svelte
+++ b/src/routes/(app)/browse/migrate/manga/[MangaID]/migrateModal.svelte
@@ -24,7 +24,7 @@
import { getContextClient, type OperationResult } from '@urql/svelte';
import { type ResultOf } from '$lib/gql/graphql';
import type { SvelteComponent } from 'svelte';
- import { ErrorHelp } from '$lib/util';
+ import { ErrorHelp } from '$lib/util.svelte';
import ModalTemplate from '$lib/components/ModalTemplate.svelte';
const modalStore = getModalStore();
diff --git a/src/routes/(app)/browse/migrate/source/[SourceID]/+page.svelte b/src/routes/(app)/browse/migrate/source/[SourceID]/+page.svelte
index dc82d70..402063a 100644
--- a/src/routes/(app)/browse/migrate/source/[SourceID]/+page.svelte
+++ b/src/routes/(app)/browse/migrate/source/[SourceID]/+page.svelte
@@ -10,9 +10,10 @@
import { AppBarData } from '$lib/MountTitleAction';
import IntersectionObserver from '$lib/components/IntersectionObserver.svelte';
import MangaCard from '$lib/components/MangaCard.svelte';
- import { Meta, display } from '$lib/simpleStores';
- import { gridValues } from '$lib/util';
- import { getContextClient, queryStore } from '@urql/svelte';
+ import { display, gmState } from '$lib/simpleStores.svelte';
+
+ import { gridValues, queryState } from '$lib/util.svelte';
+ import { getContextClient } from '@urql/svelte';
import type { PageData } from './$types';
import {
sourceMigrationManga,
@@ -27,33 +28,33 @@
AppBarData(data.SourceID);
const client = getContextClient();
- const Manga = queryStore({
+ const Manga = queryState({
client,
query: sourceMigrationManga,
variables: { sourceId: data.SourceID }
});
- const source = queryStore({
+ const source = queryState({
client,
query: sourceMigrationSource,
variables: { sourceId: data.SourceID }
});
$effect(() => {
- if ($source.data?.source?.displayName)
- AppBarData($source.data?.source.displayName);
+ if (source.value.data?.source?.displayName)
+ AppBarData(source.value.data?.source.displayName);
});
-{#if $Manga.fetching}
+{#if Manga.value.fetching}
{#each new Array(30) as _}
- {#if $Meta.Display === display.Comfortable}
+ {#if gmState.value.Display === display.Comfortable}
@@ -61,13 +62,13 @@
{/each}
-{:else if $Manga.error}
+{:else if Manga.value.error}
- {JSON.stringify($Manga.error, null, 4)}
+ {JSON.stringify(Manga.value.error, null, 4)}
-{:else if $Manga.data}
+{:else if Manga.value.data}
- {#each $Manga.data.mangas.nodes as manga}
+ {#each Manga.value.data.mangas.nodes as manga}
- {#if $Meta.Display === display.Compact}
+ {#if gmState.value.Display === display.Compact}
@@ -100,7 +102,7 @@
{/if}
- {#if $Meta.Display === display.Comfortable}
+ {#if gmState.value.Display === display.Comfortable}
{/if}
- {#if !intersecting && $Meta.Display === display.Comfortable}
+ {#if !intersecting && gmState.value.Display === display.Comfortable}
{/if}
{/snippet}
diff --git a/src/routes/(app)/browse/source/[sourceID]/+layout.svelte b/src/routes/(app)/browse/source/[sourceID]/+layout.svelte
index 569020a..385f150 100644
--- a/src/routes/(app)/browse/source/[sourceID]/+layout.svelte
+++ b/src/routes/(app)/browse/source/[sourceID]/+layout.svelte
@@ -8,10 +8,11 @@
diff --git a/src/routes/(app)/browse/source/[sourceID]/filter/+page.svelte b/src/routes/(app)/browse/source/[sourceID]/filter/+page.svelte
index 32f2a0c..f197bb5 100644
--- a/src/routes/(app)/browse/source/[sourceID]/filter/+page.svelte
+++ b/src/routes/(app)/browse/source/[sourceID]/filter/+page.svelte
@@ -16,8 +16,10 @@
import FilterModal from './FilterModal.svelte';
import type { fetchSourceManga } from '$lib/gql/Mutations';
import type { VariablesOf } from '$lib/gql/graphql';
- import { getContextClient, queryStore } from '@urql/svelte';
+ import { getContextClient } from '@urql/svelte';
import { getSource } from '$lib/gql/Queries';
+ import { queryState } from '$lib/util.svelte';
+ import { untrack } from 'svelte';
const modalStore = getModalStore();
@@ -32,16 +34,16 @@
}
$filtersSause = data.sourceID;
- const sause2 = queryStore({
- client: getContextClient(),
- query: getSource,
- variables: { id: data.sourceID }
- });
-
- let sause: typeof $sause2 | undefined = $state();
-
- $effect(() => {
- sause = structuredClone($sause2);
+ let sause = $derived.by(() => {
+ const _ = [data.sourceID];
+ return untrack(
+ () =>
+ queryState({
+ client: getContextClient(),
+ query: getSource,
+ variables: { id: data.sourceID }
+ }).value
+ );
});
const query = queryParam('q', ssp.string(), { pushHistory: false });
diff --git a/src/routes/(app)/browse/source/[sourceID]/filter/FilterModal.svelte b/src/routes/(app)/browse/source/[sourceID]/filter/FilterModal.svelte
index 4a8d960..fd0d12d 100644
--- a/src/routes/(app)/browse/source/[sourceID]/filter/FilterModal.svelte
+++ b/src/routes/(app)/browse/source/[sourceID]/filter/FilterModal.svelte
@@ -22,9 +22,10 @@
import { queryParam, ssp } from 'sveltekit-search-params';
import type { VariablesOf } from '$lib/gql/graphql';
import type { fetchSourceManga } from '$lib/gql/Mutations';
- import { getContextClient, queryStore } from '@urql/svelte';
+ import { getContextClient } from '@urql/svelte';
import { getSource } from '$lib/gql/Queries';
import ModalTemplate from '$lib/components/ModalTemplate.svelte';
+ import { queryState } from '$lib/util.svelte';
interface Props {
parent: SvelteComponent;
@@ -38,24 +39,18 @@
let { parent, data, submit }: Props = $props();
const modalStore = getModalStore();
- const sause2 = queryStore({
- client: getContextClient(),
- query: getSource,
- variables: {
- id: data.sourceID
- }
- });
let sauce = $derived.by(() => {
- untrack(() => {
- sause2.pause();
- });
- const _ = [$sause2];
- const tmp = untrack(() => {
- sause2.resume();
- return $state.snapshot($sause2).data?.source;
+ const _ = [data.sourceID];
+ return untrack(() => {
+ return queryState({
+ client: getContextClient(),
+ query: getSource,
+ variables: {
+ id: data.sourceID
+ }
+ });
});
- return tmp;
});
const queryy = queryParam('q', ssp.string(), { pushHistory: false });
@@ -90,8 +85,8 @@
{/snippet}
{#snippet children()}
- {#if sauce?.filters}
- {#each sauce.filters as filter, index}
+ {#if sauce.value.data?.source?.filters}
+ {#each sauce.value.data?.source.filters as filter, index}
{#if filter.__typename === 'CheckBoxFilter'}
diff --git a/src/routes/(app)/browse/source/[sourceID]/filter/filters/TriStateFilter.svelte b/src/routes/(app)/browse/source/[sourceID]/filter/filters/TriStateFilter.svelte
index 100c01d..87e7879 100644
--- a/src/routes/(app)/browse/source/[sourceID]/filter/filters/TriStateFilter.svelte
+++ b/src/routes/(app)/browse/source/[sourceID]/filter/filters/TriStateFilter.svelte
@@ -8,7 +8,7 @@
-test
-
-{#if !all && $CurrentHistory.fetching}
+{#if !all && CurrentHistory.value.fetching}
{#each new Array(110) as _}
- {#if $Meta.Display === display.Comfortable}
+ {#if gmState.value.Display === display.Comfortable}
@@ -64,9 +66,9 @@
{/each}
-{:else if !all && $CurrentHistory.error}
+{:else if !all && CurrentHistory.value.error}
- {JSON.stringify($CurrentHistory.error, null, 4)}
+ {JSON.stringify(CurrentHistory.value.error, null, 4)}
{:else if all?.nodes}
@@ -89,10 +91,11 @@
title={updat.manga.title}
titleA="{updat.isDownloaded ? 'Downloaded' : ''}
{updat.isBookmarked ? 'Bookmarked' : ''}"
- rounded="{$Meta.Display === display.Compact && 'rounded-lg'}
- {$Meta.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 $Meta.Display === display.Compact}
+ {#if gmState.value.Display === display.Compact}
@@ -127,7 +130,7 @@
{/if}
- {#if $Meta.Display === display.Comfortable}
+ {#if gmState.value.Display === display.Comfortable}
{/each}
- {#if !$CurrentHistory.fetching && all.pageInfo.hasNextPage}
+ {#if !CurrentHistory.value.fetching && all.pageInfo.hasNextPage}
{/if}
- {#if $CurrentHistory.fetching && all.pageInfo.hasNextPage}
+ {#if CurrentHistory.value.fetching && all.pageInfo.hasNextPage}
{#each new Array(10) as _}
- {#if $Meta.Display === display.Comfortable}
+ {#if gmState.value.Display === display.Comfortable}
diff --git a/src/routes/(app)/manga/[MangaID]/(manga)/+page.svelte b/src/routes/(app)/manga/[MangaID]/(manga)/+page.svelte
index fe93558..5e83c1a 100644
--- a/src/routes/(app)/manga/[MangaID]/(manga)/+page.svelte
+++ b/src/routes/(app)/manga/[MangaID]/(manga)/+page.svelte
@@ -8,16 +8,16 @@
-
-
+
+
diff --git a/src/routes/(app)/manga/[MangaID]/(manga)/ChaptersFilterModal.svelte b/src/routes/(app)/manga/[MangaID]/(manga)/ChaptersFilterModal.svelte
index ed60b66..9723cff 100644
--- a/src/routes/(app)/manga/[MangaID]/(manga)/ChaptersFilterModal.svelte
+++ b/src/routes/(app)/manga/[MangaID]/(manga)/ChaptersFilterModal.svelte
@@ -18,8 +18,8 @@
getModalStore,
localStorageStore
} from '@skeletonlabs/skeleton';
- import { ChapterSort, ChapterTitle, MangaMeta } from '$lib/simpleStores';
- import { enumKeys } from '$lib/util';
+ import { ChapterSort, ChapterTitle, mmState } from '$lib/simpleStores.svelte';
+ import { enumKeys } from '$lib/util.svelte';
import Tooltip from '$lib/components/Tooltip.svelte';
const modalStore = getModalStore();
let tabSet = localStorageStore('libraryModalTabs', 0);
@@ -28,7 +28,7 @@
}
let { MangaID }: Props = $props();
- const mangaMeta = MangaMeta(MangaID);
+ mmState.id = MangaID;
{#if $modalStore[0]}
@@ -85,7 +85,7 @@
{#if $tabSet === 0}
Unread
Downloaded
Groups
{
- $mangaMeta.groupPartials = e.currentTarget.value
+ mmState.value.groupPartials = e.currentTarget.value
.split(',')
.map((a) => a.trim())
.filter((a) => a.length > 0);
e.currentTarget.value =
- $mangaMeta.groupPartials?.join(',') ?? '';
+ mmState.value.groupPartials?.join(',') ?? '';
}}
- value={$mangaMeta.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();
- $mangaMeta.showMissingChapters =
- !$mangaMeta.showMissingChapters;
+ mmState.value.showMissingChapters =
+ !mmState.value.showMissingChapters;
}}
>
Show Missing Chapters
{#each enumKeys(ChapterTitle) as value}
> & Pausable;
MangaID: number;
- mangaMeta: ReturnType;
}
- let { manga: manga2, MangaID, mangaMeta }: Props = $props();
+ let { MangaID }: Props = $props();
function libToggle() {
if (
- $Meta.DownloadAllChaptersOnAddToLibrary &&
- !manga.data?.manga?.inLibrary
+ gmState.value.DownloadAllChaptersOnAddToLibrary &&
+ !manga.value?.data?.manga?.inLibrary
) {
client
.mutation(enqueueChapterDownloads, {
- ids: manga.data?.manga?.chapters.nodes?.map((e) => e.id) ?? []
+ ids: manga.value?.data?.manga?.chapters.nodes?.map((e) => e.id) ?? []
})
.toPromise();
}
if (
- manga.data?.manga?.inLibrary &&
- $Meta.DeleteAllChaptersOnRemoveFromLibrary
+ manga.value?.data?.manga?.inLibrary &&
+ gmState.value.DeleteAllChaptersOnRemoveFromLibrary
) {
client
.mutation(deleteDownloadedChapters, {
- ids: manga.data?.manga?.chapters.nodes?.map((e) => e.id) ?? []
+ ids: manga.value?.data?.manga?.chapters.nodes?.map((e) => e.id) ?? []
})
.toPromise();
}
if (
- manga.data?.manga?.inLibrary &&
- $Meta.RemoveChaptersFromDownloadQueueOnRemoveFromLibrary
+ manga.value?.data?.manga?.inLibrary &&
+ gmState.value.RemoveChaptersFromDownloadQueueOnRemoveFromLibrary
) {
client
.mutation(dequeueChapterDownloads, {
- ids: manga.data?.manga?.chapters.nodes?.map((e) => e.id) ?? []
+ ids: manga.value?.data?.manga?.chapters.nodes?.map((e) => e.id) ?? []
})
.toPromise();
}
@@ -81,15 +74,15 @@
client
.mutation(updateMangas, {
ids: [MangaID],
- inLibrary: !manga.data?.manga?.inLibrary
+ inLibrary: !manga.value?.data?.manga?.inLibrary
})
.toPromise();
}
let ImageFailed = $state(false);
function LongHandler() {
- if (manga.data?.manga?.title) {
- navigator.clipboard.writeText(manga.data?.manga?.title);
+ if (manga.value?.data?.manga?.title) {
+ navigator.clipboard.writeText(manga.value?.data?.manga?.title);
toastStore.trigger({
message: 'Title copied to clipboard',
background: 'bg-primary-600'
@@ -101,21 +94,9 @@
});
}
}
-
- let manga = $derived.by(() => {
- untrack(() => {
- manga2.pause();
- });
- const _ = [$manga2];
- const tmp = untrack(() => {
- manga2.resume();
- return $state.snapshot($manga2);
- });
- return tmp;
- });
-{#if manga.fetching}
+{#if manga.value?.fetching}
-{:else if manga.error}
+{:else if manga.value?.error}
- Errors loading manga Info: {JSON.stringify(manga.error, null, 4)}
+ Errors loading manga Info: {JSON.stringify(manga.value?.error, null, 4)}
-{:else if manga.data?.manga}
- {@const mangaFrag = manga.data.manga}
+{:else if manga.value?.data?.manga}
+ {@const mangaFrag = manga.value?.data.manga}
@@ -286,7 +267,9 @@
modalStore.trigger({
type: 'component',
backdropClasses: '!p-0',
- component: { ref: TrackingModal, props: { manga: manga2 } }
+ component: {
+ ref: TrackingModal
+ }
});
}}
class="variant-soft btn flex h-12 items-center px-2 sm:px-5"
@@ -323,15 +306,15 @@
modalStore.trigger({
type: 'component',
backdropClasses: '!p-0',
- component: { ref: NotesModal, props: { mangaMeta } }
+ component: { ref: NotesModal }
});
}}
>
Notes:
- {#if $mangaMeta.notes}
- {$mangaMeta.notes}
+ {#if mmState.value.notes}
+ {mmState.value.notes}
{/if}
diff --git a/src/routes/(app)/manga/[MangaID]/(manga)/MangaActions.svelte b/src/routes/(app)/manga/[MangaID]/(manga)/MangaActions.svelte
index 6bfb899..14b633b 100644
--- a/src/routes/(app)/manga/[MangaID]/(manga)/MangaActions.svelte
+++ b/src/routes/(app)/manga/[MangaID]/(manga)/MangaActions.svelte
@@ -10,15 +10,13 @@
import TooltipIconButton from '$lib/components/TooltipIconButton.svelte';
import MangaCatagoryModal from './MangaCatagoryModal.svelte';
import { getModalStore } from '@skeletonlabs/skeleton';
- import { type ResultOf } from '$lib/gql/graphql';
- import type { getManga } from '$lib/gql/Queries';
+ import { manga } from './mangaStores.svelte';
interface Props {
- manga: ResultOf['manga'] | undefined;
fetchChapters: () => Promise;
}
- let { manga, fetchChapters }: Props = $props();
+ let { fetchChapters }: Props = $props();
const modalStore = getModalStore();
@@ -42,7 +40,7 @@
onclick={refreshManga}
/>
- {#if manga?.inLibrary}
+ {#if manga.value?.data?.manga.inLibrary}
['manga'] | undefined;
- }
-
- let { manga }: Props = $props();
const client = getContextClient();
const modalStore = getModalStore();
- const getCategories = queryStore({ client, query: GetCategories });
+ const getCategories = queryState({ client, query: GetCategories });
let categories = $derived(
- $getCategories.data?.categories?.nodes
+ getCategories.value.data?.categories?.nodes
?.filter((e) => e.id !== 0)
.sort((a, b) => (a.order > b.order ? 1 : -1))
);
- let MangaCategories = manga?.categories.nodes?.map((e) => e.id) ?? [];
+ let MangaCategories =
+ manga.value?.data?.manga.categories.nodes?.map((e) => e.id) ?? [];
let selectedCategories: number[] = [...MangaCategories];
@@ -62,7 +59,7 @@
'Failed to change mangas categories',
client
.mutation(updateMangaCategories, {
- id: manga!.id,
+ id: manga.value?.data?.manga.id!,
addTo: selectedCategories,
clear: true
})
diff --git a/src/routes/(app)/manga/[MangaID]/(manga)/NotesModal.svelte b/src/routes/(app)/manga/[MangaID]/(manga)/NotesModal.svelte
index 8f6d646..5d57264 100644
--- a/src/routes/(app)/manga/[MangaID]/(manga)/NotesModal.svelte
+++ b/src/routes/(app)/manga/[MangaID]/(manga)/NotesModal.svelte
@@ -8,15 +8,11 @@
{#if $modalStore[0]}
@@ -24,8 +20,8 @@
diff --git a/src/routes/(app)/manga/[MangaID]/(manga)/TrackingModal.svelte b/src/routes/(app)/manga/[MangaID]/(manga)/TrackingModal.svelte
index 5cd5b80..59ef1e1 100644
--- a/src/routes/(app)/manga/[MangaID]/(manga)/TrackingModal.svelte
+++ b/src/routes/(app)/manga/[MangaID]/(manga)/TrackingModal.svelte
@@ -15,46 +15,41 @@
unbindTrack,
updateTrack
} from '$lib/gql/Mutations';
- import { searchTracker, type getManga, trackers } from '$lib/gql/Queries';
+ import { searchTracker, trackers } from '$lib/gql/Queries';
import { Tab, TabGroup, getModalStore } from '@skeletonlabs/skeleton';
- import {
- getContextClient,
- queryStore,
- type OperationResultStore,
- type Pausable,
- mutationStore
- } from '@urql/svelte';
+ import { getContextClient, mutationStore } from '@urql/svelte';
import { type ResultOf } from '$lib/gql/graphql';
import IconButton from '$lib/components/IconButton.svelte';
-
- interface Props {
- manga: OperationResultStore>;
- }
-
- let { manga }: Props = $props();
+ import { manga } from './mangaStores.svelte';
+ import { queryState } from '$lib/util.svelte';
const modalStore = getModalStore();
- let preQuery = $state($manga.data?.manga?.title ?? '');
- let query = $state($manga.data?.manga?.title ?? '');
+ let preQuery = $state(manga.value?.data?.manga?.title ?? '');
+ let query = $state(manga.value?.data?.manga?.title ?? '');
const client = getContextClient();
- let items:
- | (OperationResultStore> & Pausable)
- | undefined = $state();
- const Trackers2 = queryStore({
+ let items = $derived.by(() => {
+ console.log('tabSet', tabSet);
+ if (tabSet === 'Tracking') return undefined;
+ return queryState({
+ client,
+ query: searchTracker,
+ variables: { query, trackerId: tabSet }
+ });
+ });
+
+ let Trackers = queryState({
client,
query: trackers,
variables: { isLoggedIn: true },
requestPolicy: 'network-only'
});
- let Trackers = $derived.by(() => {
- return $state.snapshot($Trackers2);
- });
+ $inspect(Trackers.value);
$effect(() => {
- $manga.data?.manga?.trackRecords.nodes.forEach((e) => {
+ manga.value?.data?.manga?.trackRecords.nodes.forEach((e) => {
mutationStore({
client,
query: fetchTrack,
@@ -70,7 +65,7 @@
| ResultOf
| ResultOf['searchTracker']['trackSearches'][0]
) {
- const same = $manga.data?.manga?.trackRecords.nodes.find(
+ const same = manga.value?.data?.manga?.trackRecords.nodes.find(
(e) => e.remoteId === item.remoteId
);
if (same) {
@@ -81,7 +76,7 @@
.toPromise();
return;
}
- const id = $manga.data?.manga?.id;
+ const id = manga.value?.data?.manga?.id;
if (!id) return;
if (tabSet === 'Tracking') return;
await client
@@ -116,14 +111,6 @@
}
});
}
- $effect(() => {
- if (tabSet !== 'Tracking')
- items = queryStore({
- client,
- query: searchTracker,
- variables: { query, trackerId: tabSet }
- });
- });
{#if $modalStore[0]}
@@ -131,13 +118,13 @@
Tracking
- {#if Trackers.fetching}
+ {#if Trackers.value.fetching}
Loading...
- {:else if Trackers.error}
+ {:else if Trackers.value.error}
- {JSON.stringify(Trackers.error, null, 4)}
+ {JSON.stringify(Trackers.value.error, null, 4)}
- {:else if Trackers.data?.trackers.nodes.length}
+ {:else if Trackers.value.data?.trackers.nodes.length}
Tracking
- {#each Trackers.data.trackers.nodes as tracke (tracke.id)}
+ {#each Trackers.value.data.trackers.nodes as tracke (tracke.id)}
{@const tracker = tracke}
{tracker.name}
@@ -159,8 +146,9 @@
{#if tabSet === 'Tracking'}
- {@const Records = $manga.data?.manga?.trackRecords.nodes ?? []}
- {@const tracks = Trackers.data?.trackers.nodes}
+ {@const Records =
+ manga.value?.data?.manga?.trackRecords.nodes ?? []}
+ {@const tracks = Trackers.value.data?.trackers.nodes}
{#each Records as RecordItem (RecordItem.id)}
{@const track = tracks.find(
@@ -228,15 +216,15 @@
{:else}
{@const isTracked =
- $manga.data?.manga?.trackRecords.nodes?.filter(
+ manga.value?.data?.manga?.trackRecords.nodes?.filter(
(e) => e.trackerId === tabSet
)}
- {#if $items?.error}
+ {#if items?.value?.error}
- {JSON.stringify($items.error, null, 4)}
+ {JSON.stringify(items?.value.error, null, 4)}
- {:else if !$items || $items?.fetching}
+ {:else if !items?.value || items?.value?.fetching}
{#each new Array(3).fill(0) as _}
{/each}
- {:else if $items.data}
- {#each $items.data.searchTracker.trackSearches as item (item.trackerId + ' ' + item.remoteId)}
+ {:else if items.value.data}
+ {#each items.value.data.searchTracker.trackSearches as item (item.trackerId + ' ' + item.remoteId)}
{
@@ -323,30 +311,6 @@
{/each}
{/if}
-
{/if}
diff --git a/src/routes/(app)/manga/[MangaID]/(manga)/chaptersSide.svelte b/src/routes/(app)/manga/[MangaID]/(manga)/chaptersSide.svelte
index 57febeb..601eb25 100644
--- a/src/routes/(app)/manga/[MangaID]/(manga)/chaptersSide.svelte
+++ b/src/routes/(app)/manga/[MangaID]/(manga)/chaptersSide.svelte
@@ -13,24 +13,19 @@
import TooltipIconButton from '$lib/components/TooltipIconButton.svelte';
import { longPress } from '$lib/press';
import { screens } from '$lib/screens';
- import { ChapterSort, ChapterTitle, MangaMeta } from '$lib/simpleStores';
+ import { ChapterSort, ChapterTitle, mmState } from '$lib/simpleStores.svelte';
import {
HelpDoSelect,
HelpSelectAll,
HelpUpdateChapters,
dlreabook
- } from '$lib/util';
+ } from '$lib/util.svelte';
import { getModalStore, popup } from '@skeletonlabs/skeleton';
import { fade } from 'svelte/transition';
import ChaptersFilterModal from './ChaptersFilterModal.svelte';
import DownloadProgressRadial from './DownloadProgressRadial.svelte';
- import { selected, selectMode, type chaptertype } from './mangaStores';
- import {
- getContextClient,
- subscriptionStore,
- type OperationResultStore,
- type Pausable
- } from '@urql/svelte';
+ import { selected, selectMode, type chapterType } from './mangaStores.svelte';
+ import { getContextClient, subscriptionStore } from '@urql/svelte';
import { getSingleChapter, getManga } from '$lib/gql/Queries';
import { type ResultOf } from '$lib/gql/graphql';
import { downloadsOnChapters } from '$lib/gql/Subscriptions';
@@ -42,14 +37,13 @@
} from '$lib/gql/Mutations';
import { filterChapters } from '../util';
import { untrack } from 'svelte';
+ import { manga } from './mangaStores.svelte';
interface Props {
- manga: OperationResultStore> & Pausable;
MangaID: number;
- mangaMeta: ReturnType;
}
- let { manga, MangaID, mangaMeta }: Props = $props();
+ let { MangaID }: Props = $props();
const client = getContextClient();
const modalStore = getModalStore();
@@ -61,7 +55,7 @@
let lastDownloads: ResultOf | undefined =
$state(undefined);
- function checkinNeedRefresh() {
+ function checkingNeedRefresh() {
let filtered = lastDownloads?.downloadChanged.queue.filter(
(e) =>
!$downloads?.data?.downloadChanged.queue.find(
@@ -90,7 +84,7 @@
}
}
- function updateselected() {
+ function updateSelected() {
const _ = [sortedChapters];
untrack(() => {
$selected?.forEach((e) => {
@@ -106,39 +100,39 @@
let chapterSideElement: HTMLDivElement | undefined = $state();
- async function handelPrevRead(chapter: chaptertype) {
+ async function handelPrevRead(chapter: chapterType) {
if (!sortedChapters) return;
const ind = sortedChapters?.findIndex((e) => e.id === chapter.id);
const chapters = sortedChapters.slice(ind, sortedChapters.length);
const ids = chapters.map((e) => e.id);
await client.mutation(updateChapters, { isRead: true, ids }).toPromise();
- if ($manga.data?.manga.id)
+ if (manga.value?.data?.manga.id)
await client
- .mutation(trackProgress, { mangaId: $manga.data.manga.id })
+ .mutation(trackProgress, { mangaId: manga.value?.data.manga.id })
.toPromise();
}
function HighestChapterNumber() {
return Math.floor(
- $manga.data?.manga.chapters.nodes?.reduce((a, c) => {
+ manga.value?.data?.manga.chapters.nodes?.reduce((a, c) => {
return c.isRead && c.chapterNumber > a ? c.chapterNumber : a;
}, 0) ?? 0
);
}
- async function handelRead(chapter: chaptertype) {
+ async function handelRead(chapter: chapterType) {
if (!manga) return;
await client
.mutation(updateChapters, { isRead: true, ids: [chapter.id] })
.toPromise();
- if ($manga.data?.manga.id)
+ if (manga.value?.data?.manga.id)
await client
- .mutation(trackProgress, { mangaId: $manga.data.manga.id })
+ .mutation(trackProgress, { mangaId: manga.value?.data.manga.id })
.toPromise();
}
- async function handelUnRead(chapter: chaptertype) {
+ async function handelUnRead(chapter: chapterType) {
if (!manga) return '';
if (Math.floor(chapter.chapterNumber) !== HighestChapterNumber()) {
client
@@ -155,7 +149,7 @@
$selectMode = true;
}
- let lastSelected: chaptertype | undefined = $state();
+ let lastSelected: chapterType | undefined = $state();
function handelFilter() {
modalStore.trigger({
@@ -204,31 +198,33 @@
$effect(() => {
if ($downloads?.data?.downloadChanged) {
- untrack(checkinNeedRefresh);
+ untrack(checkingNeedRefresh);
lastDownloads = $downloads?.data;
}
});
- let chaptersInfo = $derived($manga?.data?.manga?.chapters.nodes);
+ let chaptersInfo = $derived(manga.value?.data?.manga?.chapters.nodes);
let filteredChapters = $derived(
- chaptersInfo?.filter(filterChapters(mangaMeta))
+ chaptersInfo?.filter(filterChapters(mmState))
);
let sortedChapters = $derived(
filteredChapters
? [...filteredChapters].sort((a, b) => {
let tmp = true;
- if ($mangaMeta.ChapterSort === ChapterSort.Source) {
+ if (mmState.value.ChapterSort === ChapterSort.Source) {
tmp = a.sourceOrder > b.sourceOrder;
- } else if ($mangaMeta.ChapterSort === ChapterSort['Fetched Date']) {
+ } else if (
+ mmState.value.ChapterSort === ChapterSort['Fetched Date']
+ ) {
tmp = a.fetchedAt > b.fetchedAt;
} else {
tmp = a.uploadDate > b.uploadDate;
}
- if ($mangaMeta.ChapterAsc) tmp = !tmp;
+ if (mmState.value.ChapterAsc) tmp = !tmp;
return tmp ? -1 : 1;
})
: undefined
);
- $effect(updateselected);
+ $effect(updateSelected);
$effect(() => {
if (scrollTo && _scrollToChaps) untrack(handelScrollToChaps);
});
@@ -251,7 +247,7 @@
);
-{#if !$manga || $manga.fetching}
+{#if !manga.value || manga.value?.fetching}
{/each}
-{:else if $manga.error}
+{:else if manga.value?.error}
- Error loading chapters: {JSON.stringify($manga.error, null, 4)}
+ Error loading chapters: {JSON.stringify(manga.value?.error, null, 4)}
{:else if sortedChapters}
- {@const mangaFrag = $manga.data?.manga}
+ {@const mangaFrag = manga.value?.data?.manga}
{sortedChapters.length} Chapters
- {#if $mangaMeta.showMissingChapters && missingChapters?.length}
+ {#if mmState.value.showMissingChapters && missingChapters?.length}
- {$mangaMeta.ChapterTitle ===
+ {mmState.value.ChapterTitle ===
ChapterTitle['Source Title']
? chapter.name
: `Chapter ${chapter.chapterNumber}`}
@@ -473,7 +469,7 @@
).toLocaleString()}"
>
{new Date(
- $mangaMeta.ChapterFetchUpload
+ mmState.value.ChapterFetchUpload
? parseInt(chapter.uploadDate)
: parseInt(chapter.fetchedAt) * 1000
).toLocaleDateString()}{chapter.isDownloaded
diff --git a/src/routes/(app)/manga/[MangaID]/(manga)/mangaStores.svelte.ts b/src/routes/(app)/manga/[MangaID]/(manga)/mangaStores.svelte.ts
new file mode 100644
index 0000000..6cdb108
--- /dev/null
+++ b/src/routes/(app)/manga/[MangaID]/(manga)/mangaStores.svelte.ts
@@ -0,0 +1,44 @@
+// Copyright (c) 2023 Contributors to the Suwayomi project
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+import type { ChapterTypeFragment } from '$lib/gql/Fragments';
+import type { ResultOf, VariablesOf } from '$lib/gql/graphql';
+import { getManga } from '$lib/gql/Queries';
+import type { OperationResultF } from '$lib/util.svelte';
+import { getContextClient, queryStore } from '@urql/svelte';
+import { onDestroy } from 'svelte';
+import { writable } from 'svelte/store';
+
+export type chapterType = ResultOf
;
+
+export const selectMode = writable(false);
+export const selected = writable([]);
+
+export const manga: {
+ value:
+ | OperationResultF, VariablesOf>
+ | undefined;
+} = $state({
+ value: undefined
+});
+
+let unSub = () => {};
+
+export function setMangaId(id: number) {
+ unSub();
+ const client = getContextClient();
+ const mga = queryStore({
+ client,
+ query: getManga,
+ variables: { id }
+ });
+ unSub = mga.subscribe((queryResult) => {
+ manga.value = queryResult;
+ });
+ onDestroy(() => {
+ unSub();
+ });
+}
diff --git a/src/routes/(app)/manga/[MangaID]/(manga)/mangaStores.ts b/src/routes/(app)/manga/[MangaID]/(manga)/mangaStores.ts
deleted file mode 100644
index 3d5544d..0000000
--- a/src/routes/(app)/manga/[MangaID]/(manga)/mangaStores.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (c) 2023 Contributors to the Suwayomi project
-//
-// This Source Code Form is subject to the terms of the Mozilla Public
-// License, v. 2.0. If a copy of the MPL was not distributed with this
-// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-import type { ChapterTypeFragment } from '$lib/gql/Fragments';
-import type { ResultOf } from '$lib/gql/graphql';
-// import { localStorageStore } from "@skeletonlabs/skeleton";
-import { writable } from 'svelte/store';
-
-export type chaptertype = ResultOf;
-
-export const selectMode = writable(false);
-export const selected = writable([]);
diff --git a/src/routes/(app)/manga/[MangaID]/chapter/[ChapterID]/+layout@.svelte b/src/routes/(app)/manga/[MangaID]/chapter/[ChapterID]/+layout@.svelte
index 8ff40c2..1a75fc5 100644
--- a/src/routes/(app)/manga/[MangaID]/chapter/[ChapterID]/+layout@.svelte
+++ b/src/routes/(app)/manga/[MangaID]/chapter/[ChapterID]/+layout@.svelte
@@ -11,7 +11,7 @@
import { getDrawerStore, AppShell } from '@skeletonlabs/skeleton';
import type { LayoutData } from './$types';
import { writable } from 'svelte/store';
- import { makeToggleDrawer } from './chapterStores';
+ import { makeToggleDrawer } from './chapterStores.svelte';
interface Props {
data: LayoutData;
diff --git a/src/routes/(app)/manga/[MangaID]/chapter/[ChapterID]/+page.svelte b/src/routes/(app)/manga/[MangaID]/chapter/[ChapterID]/+page.svelte
index a2446d2..958a39a 100644
--- a/src/routes/(app)/manga/[MangaID]/chapter/[ChapterID]/+page.svelte
+++ b/src/routes/(app)/manga/[MangaID]/chapter/[ChapterID]/+page.svelte
@@ -13,25 +13,21 @@
import Image from '$lib/components/Image.svelte';
import IntersectionObserver from '$lib/components/IntersectionObserver.svelte';
import { getToastStore } from '$lib/components/Toast/stores';
- import { Layout, MangaMeta, Mode } from '$lib/simpleStores';
- import { ErrorHelp } from '$lib/util';
+ import { Layout, mmState, Mode } from '$lib/simpleStores.svelte';
+ import { ErrorHelp } from '$lib/util.svelte';
import { getDrawerStore } from '@skeletonlabs/skeleton';
import { onMount, untrack } from 'svelte';
import type { PageData } from './$types';
import {
ViewNav,
chapterTitle,
+ get_manga,
makeToggleDrawer,
mangaTitle
- } from './chapterStores';
+ } from './chapterStores.svelte';
import { filterChapters } from '../../util';
import { paths, type PathLayout, type Paths, type TPath } from './paths';
- import {
- getContextClient,
- queryStore,
- type OperationResult
- } from '@urql/svelte';
- import { getManga } from '$lib/gql/Queries';
+ import { getContextClient, type OperationResult } from '@urql/svelte';
import { type ResultOf } from '$lib/gql/graphql';
import {
fetchChapterPages,
@@ -47,7 +43,7 @@
}
let { data }: Props = $props();
- let mangaMeta = MangaMeta(data.MangaID);
+ mmState.id = data.MangaID;
let pagenav = queryParam('pagenav', ssp.boolean(), { pushHistory: false });
@@ -56,7 +52,7 @@
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
navigator.userAgent
) &&
- $mangaMeta.mobileFullScreenOnChapterPage
+ mmState.value.mobileFullScreenOnChapterPage
) {
document.documentElement.requestFullscreen();
}
@@ -65,7 +61,7 @@
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
navigator.userAgent
) &&
- $mangaMeta.mobileFullScreenOnChapterPage
+ mmState.value.mobileFullScreenOnChapterPage
) {
document.exitFullscreen();
}
@@ -79,11 +75,9 @@
const toastStore = getToastStore();
const client = getContextClient();
- const manga = queryStore({
- client,
- query: getManga,
- variables: { id: data.MangaID }
- });
+ get_manga.id = data.MangaID;
+ const manga = $derived(get_manga.manga);
+
let pageElement = undefined as HTMLDivElement | undefined;
const drawerStore = getDrawerStore();
@@ -102,7 +96,7 @@
}[] = $state([]);
let filteredChapters = $derived(
- $manga.data?.manga?.chapters.nodes?.filter(filterChapters(mangaMeta, true))
+ manga?.data?.manga?.chapters.nodes?.filter(filterChapters(mmState, true))
);
let pages:
| Promise>>
@@ -382,7 +376,7 @@
pageElement?.scrollTo({
top:
addition + (pageElement.scrollTop + pageElement.clientHeight * decimal),
- behavior: $mangaMeta.SmoothScroll ? 'smooth' : 'instant'
+ behavior: mmState.value.SmoothScroll ? 'smooth' : 'instant'
});
}
@@ -415,10 +409,10 @@
isRead: pageIndex >= maxPages * 0.8 ? true : null
})
.toPromise();
- if (!$manga.data?.manga?.id || pageIndex !== maxPages - 1) return;
+ if (!manga?.data?.manga?.id || pageIndex !== maxPages - 1) return;
await client
.mutation(trackProgress, {
- mangaId: $manga.data?.manga?.id
+ mangaId: manga?.data?.manga?.id
})
.toPromise();
})();
@@ -469,13 +463,13 @@
let nextid = $derived.by(() => {
const _ = [currentChapterID];
untrack(() => {
- return getChapterAfterID(currentChapterID, $manga)?.id;
+ return getChapterAfterID(currentChapterID, manga)?.id;
});
});
$effect(() => {
if (
nextid !== undefined &&
- $mangaMeta.preLoadNextChapter &&
+ mmState.value.preLoadNextChapter &&
nextid !== preLoadingId
) {
untrack(() => {
@@ -493,17 +487,17 @@
});
});
$effect(() => {
- if ($mangaMeta.ReaderMode === Mode.RTL) {
- path = layoutToPath(paths.rtl, $mangaMeta.NavLayout);
+ if (mmState.value.ReaderMode === Mode.RTL) {
+ path = layoutToPath(paths.rtl, mmState.value.NavLayout);
} else {
- path = layoutToPath(paths.ltr, $mangaMeta.NavLayout);
+ path = layoutToPath(paths.ltr, mmState.value.NavLayout);
}
});
$effect(() => {
dataStore.set(data);
});
$effect(() => {
- $mangaTitle = $manga.data?.manga?.title ?? '';
+ $mangaTitle = manga?.data?.manga?.title ?? '';
});
$effect(() => {
$chapterTitle =
@@ -534,7 +528,7 @@
) as HTMLElement | undefined
);
$effect(() => {
- AppBarData(`${$manga.data?.manga?.title} ${$chapterTitle}`);
+ AppBarData(`${manga?.data?.manga?.title} ${$chapterTitle}`);
});
let currPath = $derived(
path
@@ -589,36 +583,38 @@
- {#if ($mangaMeta.ReaderMode === Mode.RTL || $mangaMeta.ReaderMode === Mode.LTR) && $mangaMeta.Offset}
+ {#if (mmState.value.ReaderMode === Mode.RTL || mmState.value.ReaderMode === Mode.LTR) && mmState.value.Offset}
{/if}
{#each chapter.pages as page, pageIndex (page)}