From 435ceba9f667a4bb3abb82d8cbc8c790ff996625 Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Thu, 23 Apr 2026 16:57:41 +0530 Subject: [PATCH] fix header --- src/lib/stores/headerAlert.ts | 14 ++++++++++++-- src/routes/+layout.svelte | 13 +++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/lib/stores/headerAlert.ts b/src/lib/stores/headerAlert.ts index 6accad1f7..1d5faffee 100644 --- a/src/lib/stores/headerAlert.ts +++ b/src/lib/stores/headerAlert.ts @@ -30,8 +30,18 @@ function createHeaderAlertStore() { } }); }, + updateShow: (id: string, show: boolean) => { + update((n) => { + const component = n.components.find((c) => c.id === id); + if (!component || component.show === show) return n; + + component.show = show; + n.components = [...n.components]; + return n; + }); + }, get: (): HeaderAlert => { - //return highest importance component + // return highest importance visible component let component = { id: '', show: false, @@ -40,7 +50,7 @@ function createHeaderAlertStore() { }; update((n) => { n.components.forEach((c) => { - if (c.importance > component.importance) { + if (c.show && c.importance > component.importance) { component = c; } }); diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index dd032cad1..a6ad290d6 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -13,7 +13,11 @@ import { sdk } from '$lib/stores/sdk'; import { user } from '$lib/stores/user'; import { loading } from '$routes/store'; - import { restoreImpersonation } from '$lib/appwrite/impersonation'; + import { + impersonationRevision, + readImpersonationTargetUserId, + restoreImpersonation + } from '$lib/appwrite/impersonation'; import { headerAlert } from '$lib/stores/headerAlert'; import ImpersonationBanner from '$lib/components/impersonation/banner.svelte'; import { Root } from '@appwrite.io/pink-svelte'; @@ -37,7 +41,7 @@ headerAlert.add({ id: 'impersonation', component: ImpersonationBanner, - show: true, + show: !!readImpersonationTargetUserId(), importance: 100 // highest priority — always visible when active }); @@ -129,6 +133,11 @@ } }); + $: if (browser) { + void $impersonationRevision; + headerAlert.updateShow('impersonation', !!readImpersonationTargetUserId()); + } + $: { if (browser) { const isCloudClass = isCloud ? 'is-cloud' : '';