Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ff fix #71

Merged
merged 3 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions src/lib/simpleStores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,19 @@ const trueDefaults = {
type globalMeta = typeof trueDefaults;

function GlobalMetaUpdator(cache: ApolloCache<unknown>, key: string, value: string) {
const { metas } = cache.readQuery({
query: MetasDoc
}) as MetasQuery;
metas.nodes = metas.nodes.filter((e) => e.key !== key);
metas.nodes.push({
const { metas: tmp } = structuredClone(
cache.readQuery({
query: MetasDoc
})
) as MetasQuery;
tmp.nodes = tmp.nodes.filter((e) => e.key !== key);
tmp.nodes.push({
key,
value
});
cache.writeQuery({
query: MetasDoc,
data: { metas }
data: { metas: tmp }
});
}

Expand All @@ -134,8 +136,8 @@ function GlobalMeta() {
});
});

async function set(value: globalMeta) {
(Object.entries(value) as [keyof globalMeta, unknown][]).forEach(async (entry) => {
async function set(val: globalMeta) {
(Object.entries(val) as [keyof globalMeta, unknown][]).forEach(async (entry) => {
const value = JSON.stringify(entry[1]);
const key = `VUI3_${entry[0]}`;
const tmp = get(Meta).data.metas?.nodes.find((e) => e.key === key)?.value;
Expand Down Expand Up @@ -176,10 +178,12 @@ function GlobalMeta() {
export const Meta = GlobalMeta();

function MangaMetaUpdator(cache: ApolloCache<unknown>, key: string, value: string, id: number) {
const { manga } = cache.readQuery({
query: GetMangaDoc,
variables: { id }
}) as GetMangaQuery;
const { manga } = structuredClone(
cache.readQuery({
query: GetMangaDoc,
variables: { id }
})
) as GetMangaQuery;
manga.meta = manga.meta.filter((e) => e.key !== key);
manga.meta.push({
key,
Expand Down
30 changes: 18 additions & 12 deletions src/routes/(app)/(library)/LibraryMassCategoryModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@
// try set each mangas own categories
mangaids.forEach((e) => {
try {
const { manga } = cache.readQuery({
query: GetMangaDoc,
variables: { id: e }
}) as GetMangaQuery;
const { manga } = structuredClone(
cache.readQuery({
query: GetMangaDoc,
variables: { id: e }
})
) as GetMangaQuery;
manga.categories.nodes = selectedCategories.map((ee) => {
return {
__typename: 'CategoryType',
Expand All @@ -63,18 +65,22 @@
selected = [0];
}

const { category: currentCategory } = cache.readQuery({
query: CategoryDoc,
variables: { id: $tab ?? 0 }
}) as CategoryQuery;
const { category: currentCategory } = structuredClone(
cache.readQuery({
query: CategoryDoc,
variables: { id: $tab ?? 0 }
})
) as CategoryQuery;
const mangas = currentCategory.mangas.nodes.filter((e) => mangaids.includes(e.id));

$categories.data.categories.nodes.forEach((oldCategoryID) => {
try {
const { category: oldCategory } = cache.readQuery({
query: CategoryDoc,
variables: { id: oldCategoryID.id }
}) as CategoryQuery;
const { category: oldCategory } = structuredClone(
cache.readQuery({
query: CategoryDoc,
variables: { id: oldCategoryID.id }
})
) as CategoryQuery;
if (selected.includes(oldCategoryID.id)) {
const mangatoadd: CategoryQuery['category']['mangas']['nodes'] = [];
mangas.forEach((manga) => {
Expand Down
29 changes: 17 additions & 12 deletions src/routes/(app)/browse/extensions/ExtensionCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,30 @@
): void {
if (!data) return;
try {
const {
extensions: { nodes }
} = cache.readQuery({
query: ExtensionsDoc,
variables: { isNsfw: $Meta.nsfw ? null : false }
}) as ExtensionsQuery;
const { extensions } = structuredClone(
structuredClone(
cache.readQuery({
query: ExtensionsDoc,
variables: { isNsfw: $Meta.nsfw ? null : false }
})
)
) as ExtensionsQuery;

nodes[nodes.findIndex((e) => e.pkgName === pkgName)] = data.updateExtension.extension;
extensions.nodes[extensions.nodes.findIndex((e) => e.pkgName === pkgName)] =
data.updateExtension.extension;
cache.writeQuery({
query: ExtensionsDoc,
data: { extensions: { nodes } },
data: { extensions },
variables: { isNsfw: $Meta.nsfw ? null : false }
});
} catch {}
try {
const { sources } = cache.readQuery({
query: SourcesDoc,
variables: { isNsfw: $Meta.nsfw ? null : false }
}) as SourcesQuery;
const { sources } = structuredClone(
cache.readQuery({
query: SourcesDoc,
variables: { isNsfw: $Meta.nsfw ? null : false }
})
) as SourcesQuery;
if (data.updateExtension.extension.isInstalled) {
const souceToPush: SourcesQuery['sources']['nodes'] = [];
data.updateExtension.extension.source.nodes.forEach((source) => {
Expand Down
40 changes: 24 additions & 16 deletions src/routes/(app)/browse/migrate/manga/[MangaID]/migrateModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,12 @@
nodes.forEach((newnode) => {
if (oldNodes.find((oldnode) => oldnode.id === newnode.id)) return;
try {
const { category } = cache.readQuery({
query: CategoryDoc,
variables: { id: newnode.id }
}) as CategoryQuery;
const { category } = structuredClone(
cache.readQuery({
query: CategoryDoc,
variables: { id: newnode.id }
})
) as CategoryQuery;
category.mangas.nodes.push(currentmanga);

cache.writeQuery({
Expand All @@ -151,10 +153,12 @@
// add to 0 if now in default
if (nodes.length === 0 && oldNodes.length > 0) {
try {
const { category } = cache.readQuery({
query: CategoryDoc,
variables: { id: 0 }
}) as CategoryQuery;
const { category } = structuredClone(
cache.readQuery({
query: CategoryDoc,
variables: { id: 0 }
})
) as CategoryQuery;

category.mangas.nodes.push(currentmanga);

Expand All @@ -171,10 +175,12 @@
oldNodes.forEach((oldnode) => {
if (nodes.find((newnode) => oldnode.id === newnode.id)) return;
try {
const { category } = cache.readQuery({
query: CategoryDoc,
variables: { id: oldnode.id }
}) as CategoryQuery;
const { category } = structuredClone(
cache.readQuery({
query: CategoryDoc,
variables: { id: oldnode.id }
})
) as CategoryQuery;

category.mangas.nodes = category.mangas.nodes.filter((e) => e.id !== dat.manga.id);

Expand All @@ -190,10 +196,12 @@
if (oldNodes.length === 0 && nodes.length > 0) {
//remove from default
try {
const { category } = cache.readQuery({
query: CategoryDoc,
variables: { id: 0 }
}) as CategoryQuery;
const { category } = structuredClone(
cache.readQuery({
query: CategoryDoc,
variables: { id: 0 }
})
) as CategoryQuery;

category.mangas.nodes = category.mangas.nodes.filter((e) => e.id !== dat.manga.id);

Expand Down
40 changes: 24 additions & 16 deletions src/routes/(app)/manga/[MangaID]/(manga)/MangaCatagoryModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@
nodes.forEach((newnode) => {
if (oldNodes.find((oldnode) => oldnode.id === newnode.id)) return;
try {
const { category } = cache.readQuery({
query: CategoryDoc,
variables: { id: newnode.id }
}) as CategoryQuery;
const { category } = structuredClone(
cache.readQuery({
query: CategoryDoc,
variables: { id: newnode.id }
})
) as CategoryQuery;

category.mangas.nodes.push(currentmanga);

Expand All @@ -95,10 +97,12 @@
// add to 0 if now in default
if (nodes.length === 0 && oldNodes.length > 0) {
try {
const { category } = cache.readQuery({
query: CategoryDoc,
variables: { id: 0 }
}) as CategoryQuery;
const { category } = structuredClone(
cache.readQuery({
query: CategoryDoc,
variables: { id: 0 }
})
) as CategoryQuery;

category.mangas.nodes.push(currentmanga);

Expand All @@ -115,10 +119,12 @@
oldNodes.forEach((oldnode) => {
if (nodes.find((newnode) => oldnode.id === newnode.id)) return;
try {
const { category } = cache.readQuery({
query: CategoryDoc,
variables: { id: oldnode.id }
}) as CategoryQuery;
const { category } = structuredClone(
cache.readQuery({
query: CategoryDoc,
variables: { id: oldnode.id }
})
) as CategoryQuery;

category.mangas.nodes = category.mangas.nodes.filter((e) => e.id !== manga.id);

Expand All @@ -133,10 +139,12 @@
if (oldNodes.length === 0 && nodes.length > 0) {
//remove from default
try {
const { category } = cache.readQuery({
query: CategoryDoc,
variables: { id: 0 }
}) as CategoryQuery;
const { category } = structuredClone(
cache.readQuery({
query: CategoryDoc,
variables: { id: 0 }
})
) as CategoryQuery;

category.mangas.nodes = category.mangas.nodes.filter((e) => e.id !== manga.id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
View Navigation Layout
</Slide>
<label class="pl-3">
<span>Navidation Layout</span>
<span>Navigation Layout</span>
<select bind:value={$mangaMeta.NavLayout} class="select">
{#each enumKeys(Layout) as value}
<option {value}>{value}</option>
Expand Down
12 changes: 12 additions & 0 deletions src/routes/(app)/settings/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import ReaderDefaultsModal from './ReaderDefaultsModal.svelte';
import BackupModal from './BackupModal.svelte';
import { enumKeys } from '$lib/util';
import MangaSettingsModal from './MangaSettingsModal.svelte';
const modalStore = getModalStore();
AppBarData('Settings');
</script>
Expand Down Expand Up @@ -54,6 +55,17 @@
<IconWrapper class="h-full w-auto p-2" name="mdi:bookmark-box-multiple" />
<div class="w-full">Library Settings</div>
</button>
<button
on:click={() =>
modalStore.trigger({
type: 'component',
component: { ref: MangaSettingsModal }
})}
class=" text-left flex items-center w-full h-16 hover:variant-glass-surface cursor-pointer"
>
<IconWrapper class="h-full w-auto p-2" name="streamline:insert-top-left" />
<div class="w-full">Manga Settings</div>
</button>
<label class="text-left flex items-center w-full h-16 hover:variant-glass-surface cursor-pointer">
<IconWrapper class="h-full w-auto p-2" name="mdi:television-guide" />
<div class="w-full">Grid Display</div>
Expand Down
Loading