From 91f63e8d2ac060692090d8f75379a3a7c6a1a074 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20=C3=96brink?= Date: Fri, 1 Oct 2021 09:24:25 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20Notifications=20sorted?= =?UTF-8?q?=20by=20modified,=20then=20created=20date=20(#151)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/parse/notifications.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/parse/notifications.ts b/lib/parse/notifications.ts index 81bc3328..373a64b0 100644 --- a/lib/parse/notifications.ts +++ b/lib/parse/notifications.ts @@ -26,5 +26,11 @@ export const notification = ({ type, }) +const notificationsSort = (item1: Notification, item2: Notification): number => { + const m1 = item1.dateModified || item1.dateCreated + const m2 = item2.dateModified || item2.dateCreated + return m1 < m2 ? 1 : -1 +} + export const notifications = (data: any): Notification[] => - etjanst(data).map(notification) + etjanst(data).map(notification).sort(notificationsSort)