From 4b3cc9e67bb4485dac129d023ae2b41b33de89af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Fri, 3 May 2024 17:15:01 +0200 Subject: [PATCH] Fix unread notification count MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- src/actions/notifications.ts | 6 +++++- src/reducers/notifications.ts | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/actions/notifications.ts b/src/actions/notifications.ts index f0ae162c8..b269efe3c 100644 --- a/src/actions/notifications.ts +++ b/src/actions/notifications.ts @@ -373,9 +373,13 @@ const markReadNotifications = () => const state = getState(); const topNotificationId = state.notifications.items.first()?.id; - const lastReadId = state.notifications.lastRead; + let lastReadId = state.notifications.lastRead; const v = parseVersion(state.instance.version); + if (typeof lastReadId === 'string' && lastReadId?.includes('+')) { + lastReadId = lastReadId.split('+')[0]; + } + if (topNotificationId && (lastReadId === -1 || compareId(topNotificationId, lastReadId) > 0)) { const marker = { notifications: { diff --git a/src/reducers/notifications.ts b/src/reducers/notifications.ts index da5f7d11e..b2512c683 100644 --- a/src/reducers/notifications.ts +++ b/src/reducers/notifications.ts @@ -107,7 +107,7 @@ const isValid = (notification: APIEntity) => { // Count how many notifications appear after the given ID (for unread count) const countFuture = (notifications: ImmutableOrderedMap, lastId: string | number) => { return notifications.reduce((acc, notification) => { - if (parseId(notification.get('id')) > parseId(lastId)) { + if (parseId(notification.get('id').split('+')[0]) > parseId(lastId)) { return acc + 1; } else { return acc;