Skip to content

Commit

Permalink
clean up some sub unsub with get
Browse files Browse the repository at this point in the history
  • Loading branch information
Robonau committed Oct 30, 2023
1 parent 733d2da commit 52bcd95
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import { MangaMetaWritable, ChapterTitles, type MangaMetaClass } from '$lib/MangaMeta';
import { boolInitMeta, strInitMeta, Meta } from '$lib/MetaStore';
import { paths } from './paths';
import { get } from 'svelte/store';
let swapactive = false;
let title = 'title Placeholder...';
let Chaptername = 'Chapter name Placeholder...';
Expand All @@ -27,14 +28,12 @@
let defoffset = false;
Meta.then((met) => {
const unsub = met.subscribe((e) => {
defmode = strInitMeta(e, 'mode', 'vertical');
defnav = strInitMeta(e, 'nav', 'L');
defmargins = boolInitMeta(e, 'margins', false);
defscale = boolInitMeta(e, 'scale', false);
defoffset = boolInitMeta(e, 'offset', false);
});
unsub();
const e = get(met);
defmode = strInitMeta(e, 'mode', 'vertical');
defnav = strInitMeta(e, 'nav', 'L');
defmargins = boolInitMeta(e, 'margins', false);
defscale = boolInitMeta(e, 'scale', false);
defoffset = boolInitMeta(e, 'offset', false);
});
$: Unsubscriber = MangaMetaClass?.MangaMeta.subscribe((val) => {
const tmpp = strInitMeta(val, 'mode', defmode);
Expand Down
40 changes: 19 additions & 21 deletions src/routes/(app)/manga/[MangaID]/chapter/[ChapterID]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import { goto } from '$app/navigation';
import { paths, type Tpath } from './paths';
import { navOptions, type modeop, type navop, modeOptions } from '$lib/Options';
import { get } from 'svelte/store';
const mangaID = parseInt(data.MangaID);
let CurrChapterID = parseInt(data.ChapterID);
Expand Down Expand Up @@ -127,28 +128,25 @@
const MangaMetaClas = new MangaMetaClass(structuredClone(e.data.manga.meta), mangaID);
Meta.then((met) => {
const unsub = met.subscribe((e) => {
defmode = strInitMeta(e, 'mode', 'vertical');
defnav = strInitMeta(e, 'nav', 'L');
defmargins = boolInitMeta(e, 'margins', false);
defscale = boolInitMeta(e, 'scale', false);
defoffset = boolInitMeta(e, 'offset', false);
MangaMetaClas.MangaMeta.subscribe((val) => {
const tmpp = strInitMeta(val, 'mode', defmode);
if (modeOptions.find((ele) => ele.value === tmpp)) {
mode = tmpp as modeop;
}
const tmp = strInitMeta(val, 'nav', defnav);
if (navOptions.find((ele) => ele.value === tmp)) {
nav = tmp as navop;
}
margins = boolInitMeta(val, 'margins', defmargins);
scale = boolInitMeta(val, 'scale', defscale);
offset = boolInitMeta(val, 'offset', defoffset);
});
const e = get(met);
defmode = strInitMeta(e, 'mode', 'vertical');
defnav = strInitMeta(e, 'nav', 'L');
defmargins = boolInitMeta(e, 'margins', false);
defscale = boolInitMeta(e, 'scale', false);
defoffset = boolInitMeta(e, 'offset', false);
MangaMetaClas.MangaMeta.subscribe((val) => {
const tmpp = strInitMeta(val, 'mode', defmode);
if (modeOptions.find((ele) => ele.value === tmpp)) {
mode = tmpp as modeop;
}
const tmp = strInitMeta(val, 'nav', defnav);
if (navOptions.find((ele) => ele.value === tmp)) {
nav = tmp as navop;
}
margins = boolInitMeta(val, 'margins', defmargins);
scale = boolInitMeta(val, 'scale', defscale);
offset = boolInitMeta(val, 'offset', defoffset);
});
unsub();
});
});
Expand Down

0 comments on commit 52bcd95

Please sign in to comment.