Skip to content

Commit 20b0d03

Browse files
authored
Merge pull request #263 from iceljc/features/refine-chat-window
Features/refine chat window
2 parents 8d4f855 + e9852aa commit 20b0d03

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/lib/helpers/store.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,16 @@ const conversationSearchOptionKey = "conversation_search_option";
99
const conversationUserMessageKey = "conversation_user_messages";
1010

1111
/** @type {Writable<import('$commonTypes').GlobalEvent>} */
12-
export const globalEventStore = writable({ name: "", payload: {} });
12+
const createGlobalEventStore = () => {
13+
const { subscribe, set } = writable({ name: "", payload: {} });
14+
return {
15+
subscribe,
16+
set,
17+
reset: () => set({})
18+
};
19+
}
20+
21+
export const globalEventStore = createGlobalEventStore();
1322

1423

1524
/** @type {Writable<import('$userTypes').UserModel>} */

src/routes/VerticalLayout/Sidebar.svelte

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import { page } from '$app/stores';
99
import { browser } from '$app/environment';
1010
import { _ } from 'svelte-i18n';
11+
import { globalEventStore } from '$lib/helpers/store';
1112
1213
/** @type {import('$pluginTypes').PluginMenuDefModel[]} */
1314
export let menu;
@@ -199,6 +200,11 @@
199200
const path = $page.url.pathname;
200201
return path?.startsWith('/') ? path.substring(1) : path;
201202
};
203+
204+
/** @param {string} link */
205+
const goToPage = (link) => {
206+
globalEventStore.reset();
207+
}
202208
</script>
203209
204210
<div class="vertical-menu">
@@ -225,19 +231,19 @@
225231
</Link>
226232
<ul class="sub-menu mm-collapse">
227233
{#each subMenu.childItems as childItem}
228-
<li><Link href={childItem.link}>{$_(childItem.label)}</Link></li>
234+
<li><Link href={childItem.link} on:click={() => goToPage(childItem.link)}>{$_(childItem.label)}</Link></li>
229235
{/each}
230236
</ul>
231237
</li>
232238
{:else}
233-
<li><Link href={subMenu.link}>{$_(subMenu.label)}</Link></li>
239+
<li><Link href={subMenu.link} on:click={() => goToPage(subMenu.link)}>{$_(subMenu.label)}</Link></li>
234240
{/if}
235241
{/each}
236242
</ul>
237243
</li>
238244
{:else}
239245
<li>
240-
<Link href={item.link} class="waves-effect">
246+
<Link class="waves-effect" href={item.link} on:click={() => goToPage(item.link)} >
241247
<i class={item.icon} /> <span>{$_(item.label)}</span>
242248
</Link>
243249
</li>

0 commit comments

Comments
 (0)