From 4993a31fe68022ba13b65b89e631b3e55e2a0aa3 Mon Sep 17 00:00:00 2001 From: MrMelon54 Date: Tue, 31 Oct 2023 12:17:29 +0000 Subject: [PATCH] Don't fully reload when the table data is already in store --- src/views/RedirectsView.svelte | 7 ++++++- src/views/RoutesView.svelte | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/views/RedirectsView.svelte b/src/views/RedirectsView.svelte index a69ad7f..da5da95 100644 --- a/src/views/RedirectsView.svelte +++ b/src/views/RedirectsView.svelte @@ -26,7 +26,7 @@ return p.endsWith(domain); } - let promiseForTable: Promise = reloadTable(); + let promiseForTable: Promise = Object.keys($redirectsTable).length === 0 ? reloadTable() : Promise.resolve(); function reloadTable(): Promise { return new Promise((res, rej) => { @@ -37,12 +37,17 @@ }) .then(x => { let rows = x as Redirect[]; + let srcs = new Set(Object.keys($redirectsTable)); rows.forEach(x => { $redirectsTable[x.src] = { client: !$redirectsTable[x.src] ? JSON.parse(JSON.stringify(x)) : $redirectsTable[x.src]?.client, server: x, p: Promise.resolve(), }; + srcs.delete(x.src); + }); + srcs.forEach(x => { + $redirectsTable[x].server = null; }); res(); }) diff --git a/src/views/RoutesView.svelte b/src/views/RoutesView.svelte index bf17b65..03edd57 100644 --- a/src/views/RoutesView.svelte +++ b/src/views/RoutesView.svelte @@ -26,7 +26,7 @@ return p.endsWith(domain); } - let promiseForTable: Promise = reloadTable(); + let promiseForTable: Promise = Object.keys($routesTable).length === 0 ? reloadTable() : Promise.resolve(); function reloadTable(): Promise { return new Promise((res, rej) => {