From 8d6a3ae2902419199e82aecd5381483e3edd43f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nicole=20miko=C5=82ajczyk?= Date: Mon, 9 Jun 2025 14:22:11 +0200 Subject: [PATCH] pl-fe: fix notification count display on gotosocial MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: nicole mikołajczyk --- packages/pl-fe/src/reducers/notifications.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/pl-fe/src/reducers/notifications.ts b/packages/pl-fe/src/reducers/notifications.ts index 395038f14..1b56a8d05 100644 --- a/packages/pl-fe/src/reducers/notifications.ts +++ b/packages/pl-fe/src/reducers/notifications.ts @@ -41,8 +41,6 @@ const initialState: State = { lastRead: -1, }; -const parseId = (id: string | number) => parseInt(id as string, 10); - const filterUnique = (notification: NotificationGroup, index: number, notifications: Array) => notifications.findIndex(({ group_key }) => group_key === notification.group_key) === index; @@ -55,7 +53,8 @@ const comparator = (a: Pick, b // Count how many notifications appear after the given ID (for unread count) const countFuture = (notifications: Array, lastId: string | number) => notifications.reduce((acc, notification) => { - if (parseId(notification.group_key) > parseId(lastId)) { + const length = Math.max(notification.group_key.length, lastId.toString().length); + if (notification.group_key.padStart(length, '0').localeCompare(lastId.toString().padStart(length, '0')) === 1) { return acc + 1; } else { return acc;