diff --git a/src/stores/banner/BannerLocation.tsx b/src/stores/banner/BannerLocation.tsx index 8834f0c2..d00ee95c 100644 --- a/src/stores/banner/BannerLocation.tsx +++ b/src/stores/banner/BannerLocation.tsx @@ -10,6 +10,7 @@ export function Banner(props: { id: string; }) { const [ref] = useRegisterBanner(props.id); + const hideBanner = useBannerStore((s) => s.hideBanner); const styles = { error: "bg-[#C93957] text-white", }; @@ -29,6 +30,12 @@ export function Banner(props: {
{props.children}
+ hideBanner(props.id, true)} + > + + ); @@ -38,6 +45,7 @@ export function BannerLocation(props: { location?: string }) { const { t } = useTranslation(); const isOnline = useBannerStore((s) => s.isOnline); const setLocation = useBannerStore((s) => s.setLocation); + const ignoredBannerIds = useBannerStore((s) => s.ignoredBannerIds); const currentLocation = useBannerStore((s) => s.location); const loc = props.location ?? null; @@ -53,7 +61,7 @@ export function BannerLocation(props: { location?: string }) { return (
- {!isOnline ? ( + {!isOnline && !ignoredBannerIds.includes("offline") ? ( {t("navigation.banner.offline")} diff --git a/src/stores/banner/index.ts b/src/stores/banner/index.ts index 22df9fc2..00cf6b94 100644 --- a/src/stores/banner/index.ts +++ b/src/stores/banner/index.ts @@ -13,9 +13,10 @@ interface BannerStore { isOnline: boolean; isTurnstile: boolean; location: string | null; + ignoredBannerIds: string[]; updateHeight(id: string, height: number): void; showBanner(id: string): void; - hideBanner(id: string): void; + hideBanner(id: string, force?: boolean): void; setLocation(loc: string | null): void; updateOnline(isOnline: boolean): void; updateTurnstile(isTurnstile: boolean): void; @@ -27,6 +28,7 @@ export const useBannerStore = create( isOnline: true, isTurnstile: false, location: null, + ignoredBannerIds: [], updateOnline(isOnline) { set((s) => { s.isOnline = isOnline; @@ -45,14 +47,16 @@ export const useBannerStore = create( showBanner(id) { set((s) => { if (s.banners.find((v) => v.id === id)) return; + if (s.ignoredBannerIds.includes(id)) return; s.banners.push({ id, height: 0, }); }); }, - hideBanner(id) { + hideBanner(id, force = false) { set((s) => { + if (force) s.ignoredBannerIds.push(id); s.banners = s.banners.filter((v) => v.id !== id); }); },