diff --git a/apps/red-ui/src/app/components/notifications/notifications.component.html b/apps/red-ui/src/app/components/notifications/notifications.component.html
index 1ed50b65c..518a46c85 100644
--- a/apps/red-ui/src/app/components/notifications/notifications.component.html
+++ b/apps/red-ui/src/app/components/notifications/notifications.component.html
@@ -29,7 +29,7 @@
-
{{ notification.time }}
+
{{ notification.creationDate | date : 'exactDate' }}
;
readonly groupedNotifications$: Observable;
- constructor(private readonly _notificationsService: NotificationsService, private readonly _datePipe: DatePipe) {
+ constructor(
+ private readonly _notificationsService: NotificationsService,
+ private readonly _datePipe: DatePipe,
+ private readonly _translateService: TranslateService,
+ ) {
this.groupedNotifications$ = this._notificationsService.all$.pipe(map(notifications => this.#groupNotifications(notifications)));
this.hasUnreadNotifications$ = this.#hasUnreadNotifications$;
}
@@ -51,12 +60,21 @@ export class NotificationsComponent {
}
#groupNotifications(notifications: Notification[]): NotificationsGroup[] {
- const grouped = [
- ...notifications.groupBy(n => (isToday(n.creationDate) ? n.creationDate : n.creationDate.split('T')[0])).entries(),
- ];
+ const todayTranslation = this._translateService.instant('today');
+ const groupedMap = notifications.groupBy(n => {
+ if (isOlderThan(n.creationDate, 2)) {
+ return dayjs(n.creationDate).year().toString();
+ } else if (isOlderThan(n.creationDate, 1)) {
+ return dayjs(n.creationDate).format('YYYY-MM');
+ }
+
+ return n.creationDate.split('T')[0];
+ });
+
+ const grouped = [...groupedMap.entries()];
const sorted = grouped.sort(([aDate], [bDate]) => chronologically(aDate, bDate));
return sorted.map(([date, _notifications]) => ({
- date: this._datePipe.transform(date, 'sophisticatedDate'),
+ date: isToday(date) ? todayTranslation : this._datePipe.transform(date, 'sophisticatedDate'),
notifications: _notifications.sort((a, b) => chronologically(a.creationDate, b.creationDate)),
}));
}
diff --git a/apps/red-ui/src/app/services/notifications.service.ts b/apps/red-ui/src/app/services/notifications.service.ts
index 86d468ba5..b4187e969 100644
--- a/apps/red-ui/src/app/services/notifications.service.ts
+++ b/apps/red-ui/src/app/services/notifications.service.ts
@@ -7,7 +7,6 @@ import { map, switchMap, tap } from 'rxjs/operators';
import { notificationsTranslations } from '@translations/notifications-translations';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { UserService } from '@users/user.service';
-import dayjs from 'dayjs';
import { CHANGED_CHECK_INTERVAL } from '@utils/constants';
import { DossiersCacheService } from './dossiers/dossiers-cache.service';
@@ -71,12 +70,7 @@ export class NotificationsService extends EntitiesService