Fix notification grouping

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2024-08-27 20:46:03 +02:00
parent d75ea447b3
commit cd3eb6d65a
2 changed files with 6 additions and 15 deletions

View file

@ -94,21 +94,15 @@ const register = () =>
return subscription;
} else {
// Something went wrong, try to subscribe again
return unsubscribe({ registration, subscription }).then((registration) => {
return subscribe(registration, getState);
}).then(async (pushSubscription) => {
const subscription = await dispatch(sendSubscriptionToBackend(pushSubscription, me));
return subscription;
});
return unsubscribe({ registration, subscription })
.then((registration) => subscribe(registration, getState))
.then((pushSubscription) => dispatch(sendSubscriptionToBackend(pushSubscription, me)));
}
}
// No subscription, try to subscribe
return subscribe(registration, getState)
.then(async (pushSubscription) => {
const subscription = await dispatch(sendSubscriptionToBackend(pushSubscription, me));
return subscription;
});
.then((pushSubscription) => dispatch(sendSubscriptionToBackend(pushSubscription, me)));
})
.then((subscription) => {
// If we got a PushSubscription (and not a subscription object from the backend)

View file

@ -34,11 +34,8 @@ const normalizeNotifications = (notifications: Array<BaseNotification>) => {
);
if (existingNotification) {
if (existingNotification?.accounts) {
existingNotification.accounts.push(normalizeAccount(notification.account));
} else {
existingNotification.accounts = [existingNotification.account, normalizeAccount(notification.account)];
}
existingNotification.accounts.push(normalizeAccount(notification.account));
existingNotification.account_ids.push(notification.account.id);
existingNotification.id += '+' + notification.id;
} else {
deduplicatedNotifications.push(normalizeNotification(notification));