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:
@@ -63,7 +63,7 @@ describe('Notification History Component', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
storage.removeItem('notifications');
|
storage.removeItem(NotificationHistoryComponent.NOTIFICATION_STORAGE);
|
||||||
fixture.destroy();
|
fixture.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ describe('Notification History Component', () => {
|
|||||||
const markAllAsRead = <HTMLButtonElement> overlayContainerElement.querySelector('#adf-notification-history-mark-as-read');
|
const markAllAsRead = <HTMLButtonElement> overlayContainerElement.querySelector('#adf-notification-history-mark-as-read');
|
||||||
markAllAsRead.click();
|
markAllAsRead.click();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(storage.getItem('notifications')).toBeNull();
|
expect(storage.getItem(NotificationHistoryComponent.NOTIFICATION_STORAGE)).toBeNull();
|
||||||
expect(component.notifications.length).toBe(0);
|
expect(component.notifications.length).toBe(0);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@@ -150,7 +150,7 @@ describe('Notification History Component', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should read notifications from local storage', (done) => {
|
it('should read notifications from local storage', (done) => {
|
||||||
storage.setItem('notifications', JSON.stringify([{
|
storage.setItem(NotificationHistoryComponent.NOTIFICATION_STORAGE, JSON.stringify([{
|
||||||
messages: ['My new message'],
|
messages: ['My new message'],
|
||||||
datetime: new Date(),
|
datetime: new Date(),
|
||||||
type: NOTIFICATION_TYPE.RECURSIVE
|
type: NOTIFICATION_TYPE.RECURSIVE
|
||||||
|
@@ -32,6 +32,7 @@ import { Pagination } from '@alfresco/js-api';
|
|||||||
export class NotificationHistoryComponent implements OnDestroy, OnInit, AfterViewInit {
|
export class NotificationHistoryComponent implements OnDestroy, OnInit, AfterViewInit {
|
||||||
|
|
||||||
public static MAX_NOTIFICATION_STACK_LENGTH = 100;
|
public static MAX_NOTIFICATION_STACK_LENGTH = 100;
|
||||||
|
public static NOTIFICATION_STORAGE = 'notification-history';
|
||||||
|
|
||||||
@ViewChild(MatMenuTrigger, { static: true })
|
@ViewChild(MatMenuTrigger, { static: true })
|
||||||
trigger: MatMenuTrigger;
|
trigger: MatMenuTrigger;
|
||||||
@@ -61,7 +62,7 @@ export class NotificationHistoryComponent implements OnDestroy, OnInit, AfterVie
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.notifications = JSON.parse(this.storageService.getItem('notifications')) || [];
|
this.notifications = JSON.parse(this.storageService.getItem(NotificationHistoryComponent.NOTIFICATION_STORAGE)) || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit(): void {
|
ngAfterViewInit(): void {
|
||||||
@@ -90,7 +91,7 @@ export class NotificationHistoryComponent implements OnDestroy, OnInit, AfterVie
|
|||||||
}
|
}
|
||||||
|
|
||||||
saveNotifications() {
|
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
|
notification.type !== NOTIFICATION_TYPE.RECURSIVE
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
@@ -112,7 +113,7 @@ export class NotificationHistoryComponent implements OnDestroy, OnInit, AfterVie
|
|||||||
markAsRead() {
|
markAsRead() {
|
||||||
this.notifications = [];
|
this.notifications = [];
|
||||||
this.paginatedNotifications = [];
|
this.paginatedNotifications = [];
|
||||||
this.storageService.removeItem('notifications');
|
this.storageService.removeItem(NotificationHistoryComponent.NOTIFICATION_STORAGE);
|
||||||
this.createPagination();
|
this.createPagination();
|
||||||
this.trigger.closeMenu();
|
this.trigger.closeMenu();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user