From 1611f963a9a2d1f496c319d6a85891f43e32b651 Mon Sep 17 00:00:00 2001 From: robonau <30987265+Robonau@users.noreply.github.com> Date: Sun, 26 Nov 2023 16:03:03 +0000 Subject: [PATCH] don't double fetch manga in tracking modal --- .../[MangaID]/(manga)/TrackingModal.svelte | 76 ++++++++++--------- 1 file changed, 42 insertions(+), 34 deletions(-) diff --git a/src/routes/(app)/manga/[MangaID]/(manga)/TrackingModal.svelte b/src/routes/(app)/manga/[MangaID]/(manga)/TrackingModal.svelte index 4be6791c..465d8747 100644 --- a/src/routes/(app)/manga/[MangaID]/(manga)/TrackingModal.svelte +++ b/src/routes/(app)/manga/[MangaID]/(manga)/TrackingModal.svelte @@ -77,13 +77,15 @@ } } - let currentTracking: undefined | GetMangaResponse = undefined; - $: $mangaMeta.mangaUpdatesSeriesID, getCurrentManga(); + let currentTracking: undefined | Promise = undefined; + $: getCurrentManga($mangaMeta.mangaUpdatesSeriesID); - async function getCurrentManga() { - if ($mangaMeta.mangaUpdatesSeriesID) { - currentTracking = await (await MangaUpdates).getManga($mangaMeta.mangaUpdatesSeriesID); - } else { + async function getCurrentManga(id: number | null) { + if (id && currentTracking === undefined) { + currentTracking = (await MangaUpdates).getManga(id); + return; + } + if (!id) { currentTracking = undefined; } } @@ -127,11 +129,13 @@

- - {@html sanitizeHtml(value.record.title)} + + + {@html sanitizeHtml(value.record.title)} +

- + {@html sanitizeHtml(value.record.description)} @@ -161,33 +165,37 @@ {/if}

- {#if currentTracking} - -

Currently tracking:

-
-
- {sanitizeHtml(currentTracking.title)} -
-
- - + + {/await} {:else}

Currently not tracking

{/if}