feat: added the PWA badge indicator for requests pending (#3411)

refactor: removed unnecessary code when sending web push notification

fix: moved all notify user logic into webpush

refactor: n

refactor: remove all unnecessary prettier changes

fix: n

fix: n

fix: n

fix: n

fix: increment sw version

fix: n
This commit is contained in:
Brandon Cohen
2025-02-26 02:12:36 -06:00
committed by OwsleyJr
parent a8f3035bb1
commit 3cfe9b7826
2 changed files with 15 additions and 27 deletions

View File

@@ -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}
</Badge>
</div>
)}

View File

@@ -140,32 +140,18 @@ const CoreApp: Omit<NextAppComponentType, 'origGetInitialProps'> = ({
clearAppBadge?: () => Promise<void>;
};
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)/)) {