From 2a8d4b3a96db055bdae7df0d3de2319ad7463fbe Mon Sep 17 00:00:00 2001 From: Abhinav Raut Date: Mon, 30 Mar 2026 17:17:27 +0530 Subject: [PATCH] Fix notification count in document title on navigation --- frontend/apps/main/src/App.vue | 3 ++- frontend/apps/main/src/router/index.js | 5 +---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/frontend/apps/main/src/App.vue b/frontend/apps/main/src/App.vue index 977b9843..cfa9522b 100644 --- a/frontend/apps/main/src/App.vue +++ b/frontend/apps/main/src/App.vue @@ -190,7 +190,8 @@ const { t } = useI18n() const notificationStore = useNotificationStore() // Update browser tab title with unread notification count. -watch(() => notificationStore.unreadCount, (count) => { +// Watch both unreadCount and route so the prefix is preserved after navigation. +watch([() => notificationStore.unreadCount, () => route.fullPath], ([count]) => { const base = document.title.replace(/^\(\d+\)\s*/, '') document.title = count > 0 ? `(${count}) ${base}` : base }) diff --git a/frontend/apps/main/src/router/index.js b/frontend/apps/main/src/router/index.js index 3bf19019..1aea01ec 100644 --- a/frontend/apps/main/src/router/index.js +++ b/frontend/apps/main/src/router/index.js @@ -5,7 +5,6 @@ import InboxLayout from '@main/layouts/inbox/InboxLayout.vue' import AccountLayout from '@main/layouts/account/AccountLayout.vue' import AdminLayout from '@main/layouts/admin/AdminLayout.vue' import { useAppSettingsStore } from '../stores/appSettings' -import { useNotificationStore } from '../stores/notification' import { getI18n } from '../i18n' const routes = [ @@ -572,7 +571,6 @@ const router = createRouter({ router.beforeEach((to, from, next) => { const appSettingsStore = useAppSettingsStore() - const notificationStore = useNotificationStore() const siteName = appSettingsStore.settings?.['app.site_name'] || 'Libredesk' const i18n = getI18n() const typeKey = typeof to.meta?.typeKey === 'function' ? to.meta.typeKey(to) : '' @@ -580,8 +578,7 @@ router.beforeEach((to, from, next) => { const pageTitle = titleKey && i18n ? i18n.global.t(titleKey, to.meta?.titleCount || 1) : '' - const base = `${pageTitle} - ${siteName}` - document.title = notificationStore.unreadCount > 0 ? `(${notificationStore.unreadCount}) ${base}` : base + document.title = `${pageTitle} - ${siteName}` next() })