diff --git a/packages/hoppscotch-common/src/components/app/Header.vue b/packages/hoppscotch-common/src/components/app/Header.vue index e43782267..07ae5e73e 100644 --- a/packages/hoppscotch-common/src/components/app/Header.vue +++ b/packages/hoppscotch-common/src/components/app/Header.vue @@ -214,7 +214,7 @@ banner.content.value?.content) -let bannerID: number | null = null +let offlineBannerID: number | null = null const offlineBanner: BannerContent = { type: "warning", text: (t) => t("helpers.offline"), alternateText: (t) => t("helpers.offline_short"), - score: BANNER_PRIORITY_HIGH, + score: BANNER_PRIORITY_LOW, dismissible: true, } +// Show the offline banner if the app is offline const network = reactive(useNetwork()) const isOnline = computed(() => network.isOnline) -// Show the offline banner if the user is offline watch(isOnline, () => { if (!isOnline.value) { - bannerID = banner.showBanner(offlineBanner) + offlineBannerID = banner.showBanner(offlineBanner) return } - if (banner.content && bannerID) { - banner.removeBanner(bannerID) + if (banner.content && offlineBannerID) { + banner.removeBanner(offlineBannerID) } }) -const dismissOfflineBanner = () => banner.removeBanner(bannerID!) +const dismissBanner = () => { + if (banner.content.value) { + banner.removeBanner(banner.content.value.id) + } else if (offlineBannerID) { + banner.removeBanner(offlineBannerID) + offlineBannerID = null + } +} const currentUser = useReadonlyStream( platform.auth.getProbableUserStream(),