From 64c9cbbde23a3b555cb468a58eceb71f559ef3a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicole=20Miko=C5=82ajczyk?= Date: Mon, 7 Apr 2025 12:56:34 +0200 Subject: [PATCH] pl-fe: fix notification sorting 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 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/pl-fe/src/reducers/notifications.ts b/packages/pl-fe/src/reducers/notifications.ts index b11579e75..395038f14 100644 --- a/packages/pl-fe/src/reducers/notifications.ts +++ b/packages/pl-fe/src/reducers/notifications.ts @@ -47,8 +47,10 @@ const filterUnique = (notification: NotificationGroup, index: number, notificati notifications.findIndex(({ group_key }) => group_key === notification.group_key) === index; // For sorting the notifications -const comparator = (a: Pick, b: Pick) => - b.most_recent_notification_id.localeCompare(a.most_recent_notification_id); +const comparator = (a: Pick, b: Pick) => { + const length = Math.max(a.most_recent_notification_id.length, b.most_recent_notification_id.length); + return b.most_recent_notification_id.padStart(length, '0').localeCompare(a.most_recent_notification_id.padStart(length, '0')); +}; // Count how many notifications appear after the given ID (for unread count) const countFuture = (notifications: Array, lastId: string | number) =>