aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/menu
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-02-15 15:52:18 +0100
committerChocobozzz <me@florianbigard.com>2019-02-15 15:52:18 +0100
commit41d713446c2152d47943ddb0c841a9e36ca5a9db (patch)
tree7b22f6f7ea5652107ef503470d2455c4bb087799 /client/src/app/menu
parent17036be5bc2f14dc4e66053087e39887599df4de (diff)
downloadPeerTube-41d713446c2152d47943ddb0c841a9e36ca5a9db.tar.gz
PeerTube-41d713446c2152d47943ddb0c841a9e36ca5a9db.tar.zst
PeerTube-41d713446c2152d47943ddb0c841a9e36ca5a9db.zip
Lazy import some modules
Diffstat (limited to 'client/src/app/menu')
-rw-r--r--client/src/app/menu/avatar-notification.component.ts32
1 files changed, 17 insertions, 15 deletions
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 {
26 private userNotificationSocket: UserNotificationSocket, 26 private userNotificationSocket: UserNotificationSocket,
27 private notifier: Notifier, 27 private notifier: Notifier,
28 private router: Router 28 private router: Router
29 ) {} 29 ) {
30 }
30 31
31 ngOnInit () { 32 ngOnInit () {
32 this.userNotificationService.countUnreadNotifications() 33 this.userNotificationService.countUnreadNotifications()
33 .subscribe( 34 .subscribe(
34 result => { 35 result => {
35 this.unreadNotifications = Math.min(result, 99) // Limit number to 99 36 this.unreadNotifications = Math.min(result, 99) // Limit number to 99
36 this.subscribeToNotifications() 37 this.subscribeToNotifications()
37 }, 38 },
38 39
39 err => this.notifier.error(err.message) 40 err => this.notifier.error(err.message)
40 ) 41 )
41 42
42 this.routeSub = this.router.events 43 this.routeSub = this.router.events
43 .pipe(filter(event => event instanceof NavigationEnd)) 44 .pipe(filter(event => event instanceof NavigationEnd))
@@ -53,13 +54,14 @@ export class AvatarNotificationComponent implements OnInit, OnDestroy {
53 this.popover.close() 54 this.popover.close()
54 } 55 }
55 56
56 private subscribeToNotifications () { 57 private async subscribeToNotifications () {
57 this.notificationSub = this.userNotificationSocket.getMyNotificationsSocket() 58 const obs = await this.userNotificationSocket.getMyNotificationsSocket()
58 .subscribe(data => { 59
59 if (data.type === 'new') return this.unreadNotifications++ 60 this.notificationSub = obs.subscribe(data => {
60 if (data.type === 'read') return this.unreadNotifications-- 61 if (data.type === 'new') return this.unreadNotifications++
61 if (data.type === 'read-all') return this.unreadNotifications = 0 62 if (data.type === 'read') return this.unreadNotifications--
62 }) 63 if (data.type === 'read-all') return this.unreadNotifications = 0
64 })
63 } 65 }
64 66
65} 67}