mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-5379] change notification history service storage variable (#7026)
* change notification history service storage variable * fix mark as read
This commit is contained in:
@@ -32,6 +32,7 @@ import { Pagination } from '@alfresco/js-api';
|
||||
export class NotificationHistoryComponent implements OnDestroy, OnInit, AfterViewInit {
|
||||
|
||||
public static MAX_NOTIFICATION_STACK_LENGTH = 100;
|
||||
public static NOTIFICATION_STORAGE = 'notification-history';
|
||||
|
||||
@ViewChild(MatMenuTrigger, { static: true })
|
||||
trigger: MatMenuTrigger;
|
||||
@@ -61,16 +62,16 @@ export class NotificationHistoryComponent implements OnDestroy, OnInit, AfterVie
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.notifications = JSON.parse(this.storageService.getItem('notifications')) || [];
|
||||
this.notifications = JSON.parse(this.storageService.getItem(NotificationHistoryComponent.NOTIFICATION_STORAGE)) || [];
|
||||
}
|
||||
|
||||
ngAfterViewInit(): void {
|
||||
this.notificationService.notifications$
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.subscribe((notification: NotificationModel) => {
|
||||
this.addNewNotification(notification);
|
||||
this.cd.detectChanges();
|
||||
});
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.subscribe((notification: NotificationModel) => {
|
||||
this.addNewNotification(notification);
|
||||
this.cd.detectChanges();
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
@@ -90,7 +91,7 @@ export class NotificationHistoryComponent implements OnDestroy, OnInit, AfterVie
|
||||
}
|
||||
|
||||
saveNotifications() {
|
||||
this.storageService.setItem('notifications', JSON.stringify(this.notifications.filter((notification) =>
|
||||
this.storageService.setItem(NotificationHistoryComponent.NOTIFICATION_STORAGE, JSON.stringify(this.notifications.filter((notification) =>
|
||||
notification.type !== NOTIFICATION_TYPE.RECURSIVE
|
||||
)));
|
||||
}
|
||||
@@ -112,7 +113,7 @@ export class NotificationHistoryComponent implements OnDestroy, OnInit, AfterVie
|
||||
markAsRead() {
|
||||
this.notifications = [];
|
||||
this.paginatedNotifications = [];
|
||||
this.storageService.removeItem('notifications');
|
||||
this.storageService.removeItem(NotificationHistoryComponent.NOTIFICATION_STORAGE);
|
||||
this.createPagination();
|
||||
this.trigger.closeMenu();
|
||||
}
|
||||
|
Reference in New Issue
Block a user