From c990301f1b2ef12144051d24a2c58d173a359c36 Mon Sep 17 00:00:00 2001 From: Anton Date: Fri, 14 Apr 2023 14:46:57 +0200 Subject: [PATCH] Fix date sorting in notifications [SCI-8325] --- app/controllers/user_notifications_controller.rb | 1 + .../vue/navigation/notifications/notifications_flyout.vue | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/controllers/user_notifications_controller.rb b/app/controllers/user_notifications_controller.rb index 9f7c452c2..78ad05287 100644 --- a/app/controllers/user_notifications_controller.rb +++ b/app/controllers/user_notifications_controller.rb @@ -65,6 +65,7 @@ class UserNotificationsController < ApplicationController title: notification.title, message: notification.message, created_at: I18n.l(notification.created_at, format: :full), + today: notification.created_at.today?, checked: notification.checked } end diff --git a/app/javascript/vue/navigation/notifications/notifications_flyout.vue b/app/javascript/vue/navigation/notifications/notifications_flyout.vue index 0b8c22c83..036824ede 100644 --- a/app/javascript/vue/navigation/notifications/notifications_flyout.vue +++ b/app/javascript/vue/navigation/notifications/notifications_flyout.vue @@ -75,12 +75,10 @@ export default { this.loadNotifications(); }, todayNotifications() { - let startOfDay = (new Date()).setUTCHours(0, 0, 0, 0); - return this.notifications.filter(n => moment(n.created_at) >= startOfDay); + return this.notifications.filter(n => n.today); }, olderNotifications() { - let startOfDay = (new Date()).setUTCHours(0, 0, 0, 0); - return this.notifications.filter(n => moment(n.created_at) < startOfDay); + return this.notifications.filter(n => !n.today); } }, methods: {