Added notification readed status
Change-Id: I1ba84a34988d53888977d38aba32d7a1a6aa8282
diff --git a/src/app/core/header/header.ts b/src/app/core/header/header.ts
index 06c4984..140abff 100644
--- a/src/app/core/header/header.ts
+++ b/src/app/core/header/header.ts
@@ -3,10 +3,15 @@
import {IStoreService} from '../../datasources/stores/slices.store';
import {IWSEvent} from '../../datasources/websocket/global';
+interface INotification extends IWSEvent {
+ viewed?: boolean;
+}
+
class HeaderController {
static $inject = ['SynchronizerStore'];
public title: string;
- public notifications: IWSEvent[] = [];
+ public notifications: INotification[] = [];
+ public newNotifications: INotification[] = [];
constructor(
private syncStore: IStoreService
@@ -16,11 +21,22 @@
this.syncStore.query()
.subscribe(
(event: IWSEvent) => {
- console.log(event);
- this.notifications.push(event);
+ this.notifications.unshift(event);
+ this.newNotifications = this.getNewNotifications(this.notifications);
}
);
}
+
+ public viewNotification = (notification: INotification) => {
+ notification.viewed = true;
+ this.newNotifications = this.getNewNotifications(this.notifications);
+ };
+
+ private getNewNotifications = (notifications: INotification[]) => {
+ return this.notifications.filter((n: INotification) => {
+ return !n.viewed;
+ });
+ };
}
export const xosHeader: angular.IComponentOptions = {