From ffad087907bd52a83b376c8e9f45f7cfd4c037d8 Mon Sep 17 00:00:00 2001 From: axel7083 <42176370+axel7083@users.noreply.github.com> Date: Mon, 22 Jan 2024 17:15:30 +0100 Subject: [PATCH] feat: adding router state persistence (#104) * feat: adding router state persistence Signed-off-by: axel7083 <42176370+axel7083@users.noreply.github.com> * fix: tests Signed-off-by: axel7083 <42176370+axel7083@users.noreply.github.com> * fix: linter Signed-off-by: axel7083 <42176370+axel7083@users.noreply.github.com> * fix: prettier Signed-off-by: axel7083 <42176370+axel7083@users.noreply.github.com> * fix: revert + using state management Signed-off-by: axel7083 <42176370+axel7083@users.noreply.github.com> * fix: moving model file to frontend package Signed-off-by: axel7083 <42176370+axel7083@users.noreply.github.com> --------- Signed-off-by: axel7083 <42176370+axel7083@users.noreply.github.com> --- packages/frontend/src/App.svelte | 15 ++++++++++++-- packages/frontend/src/Route.svelte | 7 +++++++ packages/frontend/src/models/IRouterState.ts | 21 ++++++++++++++++++++ packages/frontend/src/utils/client.ts | 15 ++++++++++++++ 4 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 packages/frontend/src/models/IRouterState.ts diff --git a/packages/frontend/src/App.svelte b/packages/frontend/src/App.svelte index 58ef74a43..33d0d0435 100644 --- a/packages/frontend/src/App.svelte +++ b/packages/frontend/src/App.svelte @@ -11,13 +11,24 @@ import Preferences from '/@/pages/Preferences.svelte'; import Registries from '/@/pages/Registries.svelte'; import Models from '/@/pages/Models.svelte'; import Recipe from '/@/pages/Recipe.svelte'; - import Model from './pages/Model.svelte'; +import Model from './pages/Model.svelte'; +import { onMount } from 'svelte'; +import { getRouterState } from '/@/utils/client'; router.mode.hash(); + +let isMounted = false; + +onMount(() => { + // Load router state on application startup + const state = getRouterState(); + router.goto(state.url); + isMounted = true; +}); - +
diff --git a/packages/frontend/src/Route.svelte b/packages/frontend/src/Route.svelte index 09f5dcbc9..c45d45c14 100644 --- a/packages/frontend/src/Route.svelte +++ b/packages/frontend/src/Route.svelte @@ -1,6 +1,7 @@