diff --git a/src/components/Layout/MobileMenu/index.tsx b/src/components/Layout/MobileMenu/index.tsx index 552e5326a..e89deda16 100644 --- a/src/components/Layout/MobileMenu/index.tsx +++ b/src/components/Layout/MobileMenu/index.tsx @@ -254,9 +254,11 @@ const MobileMenu = ({ router.pathname.match(link.activeRegExp) ? 'border-indigo-600 from-indigo-700 to-purple-700' : 'border-indigo-500 from-indigo-600 to-purple-600' - } !px-1 !py-[1px] leading-none`} + } flex h-4 w-4 items-center justify-center !px-[9px] !py-[9px] text-[9px]`} > - {pendingRequestsCount} + {pendingRequestsCount > 99 + ? '99+' + : pendingRequestsCount} )} diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 5269e87b8..d24c2f87d 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -140,32 +140,18 @@ const CoreApp: Omit = ({ clearAppBadge?: () => Promise; }; - const handleBadgeUpdate = () => { - if ('setAppBadge' in newNavigator) { - if ( - !router.pathname.match(/(login|setup|resetpassword)/) && - hasPermission(Permission.ADMIN) - ) { - requestsCount().then((data) => { - if (data.pending > 0) { - newNavigator.setAppBadge?.(data.pending); - } else { - newNavigator.clearAppBadge?.(); - } - }); - } else { - newNavigator.clearAppBadge?.(); - } + if ('setAppBadge' in navigator) { + if ( + !router.pathname.match(/(login|setup|resetpassword)/) && + hasPermission(Permission.ADMIN) + ) { + requestsCount().then((data) => + newNavigator?.setAppBadge?.(data.pending) + ); + } else { + newNavigator?.clearAppBadge?.(); } - }; - - handleBadgeUpdate(); - - window.addEventListener('focus', handleBadgeUpdate); - - return () => { - window.removeEventListener('focus', handleBadgeUpdate); - }; + } }, [hasPermission, router.pathname]); if (router.pathname.match(/(login|setup|resetpassword)/)) {