From 41d713446c2152d47943ddb0c841a9e36ca5a9db Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 15 Feb 2019 15:52:18 +0100 Subject: Lazy import some modules --- .../src/app/menu/avatar-notification.component.ts | 32 ++++++++++++---------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'client/src/app/menu') diff --git a/client/src/app/menu/avatar-notification.component.ts b/client/src/app/menu/avatar-notification.component.ts index f1af08096..878c5c88c 100644 --- a/client/src/app/menu/avatar-notification.component.ts +++ b/client/src/app/menu/avatar-notification.component.ts @@ -26,18 +26,19 @@ export class AvatarNotificationComponent implements OnInit, OnDestroy { private userNotificationSocket: UserNotificationSocket, private notifier: Notifier, private router: Router - ) {} + ) { + } ngOnInit () { this.userNotificationService.countUnreadNotifications() - .subscribe( - result => { - this.unreadNotifications = Math.min(result, 99) // Limit number to 99 - this.subscribeToNotifications() - }, + .subscribe( + result => { + this.unreadNotifications = Math.min(result, 99) // Limit number to 99 + this.subscribeToNotifications() + }, - err => this.notifier.error(err.message) - ) + err => this.notifier.error(err.message) + ) this.routeSub = this.router.events .pipe(filter(event => event instanceof NavigationEnd)) @@ -53,13 +54,14 @@ export class AvatarNotificationComponent implements OnInit, OnDestroy { this.popover.close() } - private subscribeToNotifications () { - this.notificationSub = this.userNotificationSocket.getMyNotificationsSocket() - .subscribe(data => { - if (data.type === 'new') return this.unreadNotifications++ - if (data.type === 'read') return this.unreadNotifications-- - if (data.type === 'read-all') return this.unreadNotifications = 0 - }) + private async subscribeToNotifications () { + const obs = await this.userNotificationSocket.getMyNotificationsSocket() + + this.notificationSub = obs.subscribe(data => { + if (data.type === 'new') return this.unreadNotifications++ + if (data.type === 'read') return this.unreadNotifications-- + if (data.type === 'read-all') return this.unreadNotifications = 0 + }) } } -- cgit v1.2.3