Implement interactive metadata review for batch updates, with progress tracking and a unified notification system
This commit is contained in:
committed by
Aditya Chandel
parent
6576f3351a
commit
116f0c950e
@@ -0,0 +1,39 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {BehaviorSubject, Observable} from 'rxjs';
|
||||
import {filter} from 'rxjs/operators';
|
||||
import {LogNotification} from './model/log-notification.model';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class NotificationEventService {
|
||||
private latestNotificationSubject = new BehaviorSubject<LogNotification | null>(null);
|
||||
|
||||
latestNotification$: Observable<LogNotification> = this.latestNotificationSubject.asObservable().pipe(
|
||||
filter((event): event is LogNotification => event !== null)
|
||||
);
|
||||
|
||||
private notificationHighlightSubject = new BehaviorSubject<boolean>(false);
|
||||
notificationHighlight$ = this.notificationHighlightSubject.asObservable();
|
||||
|
||||
private highlightTimeout: any;
|
||||
|
||||
handleNewNotification(notification: LogNotification): void {
|
||||
this.latestNotificationSubject.next(notification);
|
||||
this.notificationHighlightSubject.next(true);
|
||||
|
||||
if (this.highlightTimeout) {
|
||||
clearTimeout(this.highlightTimeout);
|
||||
}
|
||||
|
||||
this.highlightTimeout = setTimeout(() => {
|
||||
this.notificationHighlightSubject.next(false);
|
||||
}, 7500);
|
||||
|
||||
setTimeout(() => {
|
||||
if (!this.notificationHighlightSubject.value) {
|
||||
this.latestNotificationSubject.next(null);
|
||||
}
|
||||
}, 20000);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user