diff --git a/src/lib/helpers/store.js b/src/lib/helpers/store.js index 7b2677e..328cbb4 100644 --- a/src/lib/helpers/store.js +++ b/src/lib/helpers/store.js @@ -9,7 +9,16 @@ const conversationSearchOptionKey = "conversation_search_option"; const conversationUserMessageKey = "conversation_user_messages"; /** @type {Writable} */ -export const globalEventStore = writable({ name: "", payload: {} }); +const createGlobalEventStore = () => { + const { subscribe, set } = writable({ name: "", payload: {} }); + return { + subscribe, + set, + reset: () => set({}) + }; +} + +export const globalEventStore = createGlobalEventStore(); /** @type {Writable} */ diff --git a/src/routes/VerticalLayout/Sidebar.svelte b/src/routes/VerticalLayout/Sidebar.svelte index 479127f..5084b90 100644 --- a/src/routes/VerticalLayout/Sidebar.svelte +++ b/src/routes/VerticalLayout/Sidebar.svelte @@ -8,6 +8,7 @@ import { page } from '$app/stores'; import { browser } from '$app/environment'; import { _ } from 'svelte-i18n'; + import { globalEventStore } from '$lib/helpers/store'; /** @type {import('$pluginTypes').PluginMenuDefModel[]} */ export let menu; @@ -199,6 +200,11 @@ const path = $page.url.pathname; return path?.startsWith('/') ? path.substring(1) : path; }; + + /** @param {string} link */ + const goToPage = (link) => { + globalEventStore.reset(); + }
@@ -225,19 +231,19 @@ {:else} -
  • {$_(subMenu.label)}
  • +
  • goToPage(subMenu.link)}>{$_(subMenu.label)}
  • {/if} {/each} {:else}
  • - + goToPage(item.link)} > {$_(item.label)}