diff --git a/src/lib/components/History/historyState.svelte.ts b/src/lib/components/History/historyState.svelte.ts index 36faccd9..72a35b45 100644 --- a/src/lib/components/History/historyState.svelte.ts +++ b/src/lib/components/History/historyState.svelte.ts @@ -56,19 +56,24 @@ if (mode.value === 'loader') { mode.value = 'manual'; } +// The persisted slot backing a mode; loader is in-memory and has no slot. +const slotFor = (m: HistoryType): Persisted | null => { + switch (m) { + case 'auto': { + return auto; + } + case 'manual': { + return manual; + } + default: { + return null; + } + } +}; + export const historyState = { get entries(): HistoryEntry[] { - switch (mode.value) { - case 'auto': { - return auto.value; - } - case 'loader': { - return loader; - } - default: { - return manual.value; - } - } + return slotFor(mode.value)?.value ?? loader; }, get loaderEntries(): HistoryEntry[] { return loader; @@ -125,22 +130,8 @@ export const setLoaderEntries = (entries: Optional[]): void ); }; -const activeSlot = (): Persisted | null => { - switch (mode.value) { - case 'auto': { - return auto; - } - case 'manual': { - return manual; - } - default: { - return null; - } - } -}; - export const removeEntry = (id: string): void => { - const slot = activeSlot(); + const slot = slotFor(mode.value); if (!slot) { return; } @@ -149,7 +140,7 @@ export const removeEntry = (id: string): void => { }; export const clearActive = (): void => { - const slot = activeSlot(); + const slot = slotFor(mode.value); if (!slot) { return; } diff --git a/src/lib/util/state.ts b/src/lib/util/state.ts index e87c9677..811927aa 100644 --- a/src/lib/util/state.ts +++ b/src/lib/util/state.ts @@ -317,10 +317,6 @@ export const initURLSubscription = (): void => { }); }; -export const getStateString = (): string => { - return JSON.stringify(get(inputStateStore)); -}; - export const verifyState = (): void => { const state = get(inputStateStore); if (!state.panZoom) {