mirror of
https://github.com/sct/overseerr.git
synced 2025-12-26 16:27:17 +01:00
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:
@@ -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>
|
||||
)}
|
||||
|
||||
@@ -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)/)) {
|
||||
|
||||
Reference in New Issue
Block a user