mirror of
https://github.com/sct/overseerr.git
synced 2025-09-30 05:54:03 +02:00
fix: pwa app badge (#4117)
* fix: clear app badge at zero without notification * fix: correct users check sometimes failing when searching push subs
This commit is contained in:
@@ -241,7 +241,7 @@ class WebPushAgent
|
||||
const allSubs = await userPushSubRepository
|
||||
.createQueryBuilder('pushSub')
|
||||
.leftJoinAndSelect('pushSub.user', 'user')
|
||||
.where('pushSub.userId IN (:users)', {
|
||||
.where('pushSub.userId IN (:...users)', {
|
||||
users: manageUsers.map((user) => user.id),
|
||||
})
|
||||
.getMany();
|
||||
|
@@ -143,18 +143,32 @@ const CoreApp: Omit<NextAppComponentType, 'origGetInitialProps'> = ({
|
||||
clearAppBadge?: () => Promise<void>;
|
||||
};
|
||||
|
||||
if ('setAppBadge' in navigator) {
|
||||
const handleBadgeUpdate = () => {
|
||||
if ('setAppBadge' in newNavigator) {
|
||||
if (
|
||||
!router.pathname.match(/(login|setup|resetpassword)/) &&
|
||||
hasPermission(Permission.ADMIN)
|
||||
) {
|
||||
requestsCount().then((data) =>
|
||||
newNavigator?.setAppBadge?.(data.pending)
|
||||
);
|
||||
requestsCount().then((data) => {
|
||||
if (data.pending > 0) {
|
||||
newNavigator.setAppBadge?.(data.pending);
|
||||
} else {
|
||||
newNavigator?.clearAppBadge?.();
|
||||
newNavigator.clearAppBadge?.();
|
||||
}
|
||||
});
|
||||
} 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