From ebff6f46d51b463f6d0cd20bfc62d91e392cdecd Mon Sep 17 00:00:00 2001 From: Lukas Haase <lukas.haase@mni.thm.de> Date: Sat, 26 Dec 2020 17:26:44 +0100 Subject: [PATCH] add read motd to archive --- .../_dialogs/motd-dialog/motd-dialog.component.html | 8 ++++---- src/app/models/motd-list.ts | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/app/components/shared/_dialogs/motd-dialog/motd-dialog.component.html b/src/app/components/shared/_dialogs/motd-dialog/motd-dialog.component.html index 5514f3c2c..55b77aa3c 100644 --- a/src/app/components/shared/_dialogs/motd-dialog/motd-dialog.component.html +++ b/src/app/components/shared/_dialogs/motd-dialog/motd-dialog.component.html @@ -19,16 +19,16 @@ </ars-col> </ars-row> <ars-row class="message" ars-flex-box> - <ng-container *ngFor="let message of motdsList.messagesNew"> - <app-motd-message [message]="message"></app-motd-message> + <ng-container *ngFor="let message of motdsList.messages"> + <app-motd-message *ngIf="!message.isRead && message.isNew" [message]="message"></app-motd-message> </ng-container> </ars-row> <ars-row> <h4 class="container-title">{{ 'footer.motd-title-old' | translate }}</h4> </ars-row> <ars-row class="message" ars-flex-box> - <ng-container *ngFor="let message of motdsList.messagesOld"> - <app-motd-message [message]="message"></app-motd-message> + <ng-container *ngFor="let message of motdsList.messages"> + <app-motd-message *ngIf="message.isRead || !message.isNew" [message]="message"></app-motd-message> </ng-container> </ars-row> <ars-row [height]="32"></ars-row> diff --git a/src/app/models/motd-list.ts b/src/app/models/motd-list.ts index 4d9c84d10..b3c626f29 100644 --- a/src/app/models/motd-list.ts +++ b/src/app/models/motd-list.ts @@ -4,6 +4,7 @@ export class MotdList { public messagesNew: Motd[] = []; public messagesOld: Motd[] = []; + public messages: Motd[] = []; private localRead: string[]; constructor( @@ -16,6 +17,10 @@ export class MotdList { this.localRead = JSON.parse(localStorage.getItem('motds')); this.parse(this.messagesNew, messagesNew, true); this.parse(this.messagesOld, messagesOld, false); + this.messages = this.messagesNew.concat(this.messagesOld); + this.sortList(this.messagesNew); + this.sortList(this.messagesOld); + this.sortList(this.messages); } private parse(list: Motd[], messages: any, isNew: boolean): void { @@ -34,6 +39,9 @@ export class MotdList { }); list.push(motd); }); + } + + private sortList(list: Motd[]) { list.sort((a, b) => b.startTimestamp.getTime() - a.startTimestamp.getTime()); } -- GitLab