File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
frontend/src/components/navbar Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -88,7 +88,17 @@ const fetchEnrichedNotifications = async () => {
8888
8989const { data : notifications } = useQuery ({ key: [' notifications' ], query: fetchEnrichedNotifications });
9090
91- const notificationItems = computed (() => (notifications .value ?.data as EnrichedNotification []) || []);
91+ const notificationItems = computed (() => {
92+ const items = (notifications .value ?.data as EnrichedNotification []) || [];
93+ // sort newest first — try common timestamp fields (date, createdAt, created_at)
94+ return items .slice ().sort ((a , b ) => {
95+ const aTs = Date .parse ((a as any ).date || (a as any ).createdAt || (a as any ).created_at || " " );
96+ const bTs = Date .parse ((b as any ).date || (b as any ).createdAt || (b as any ).created_at || " " );
97+ const na = Number .isFinite (aTs ) ? aTs : 0 ;
98+ const nb = Number .isFinite (bTs ) ? bTs : 0 ;
99+ return nb - na ;
100+ });
101+ });
92102
93103const _deleteNotificationMutation = useDeleteNotificationMutation ();
94104const _deleteAllNotificationsMutation = useDeleteAllNotificationsMutation ();
You can’t perform that action at this time.
0 commit comments