aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core/notification
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/core/notification
parent17036be5bc2f14dc4e66053087e39887599df4de (diff)
downloadPeerTube-41d713446c2152d47943ddb0c841a9e36ca5a9db.tar.gz
PeerTube-41d713446c2152d47943ddb0c841a9e36ca5a9db.tar.zst
PeerTube-41d713446c2152d47943ddb0c841a9e36ca5a9db.zip
Lazy import some modules
Diffstat (limited to 'client/src/app/core/notification')
-rw-r--r--client/src/app/core/notification/user-notification-socket.service.ts15
1 files changed, 8 insertions, 7 deletions
diff --git a/client/src/app/core/notification/user-notification-socket.service.ts b/client/src/app/core/notification/user-notification-socket.service.ts
index f367d9ae4..29337d3a7 100644
--- a/client/src/app/core/notification/user-notification-socket.service.ts
+++ b/client/src/app/core/notification/user-notification-socket.service.ts
@@ -21,21 +21,22 @@ export class UserNotificationSocket {
21 this.notificationSubject.next({ type, notification }) 21 this.notificationSubject.next({ type, notification })
22 } 22 }
23 23
24 getMyNotificationsSocket () { 24 async getMyNotificationsSocket () {
25 const socket = this.getSocket() 25 await this.initSocket()
26
27 socket.on('new-notification', (n: UserNotificationServer) => this.dispatch('new', n))
28 26
29 return this.notificationSubject.asObservable() 27 return this.notificationSubject.asObservable()
30 } 28 }
31 29
32 private getSocket () { 30 private async initSocket () {
33 if (this.socket) return this.socket 31 if (this.socket) return
32
33 // FIXME: import('..') returns a struct module, containing a "default" field corresponding to our sanitizeHtml function
34 const io: typeof import ('socket.io-client') = (await import('socket.io-client') as any).default
34 35
35 this.socket = io(environment.apiUrl + '/user-notifications', { 36 this.socket = io(environment.apiUrl + '/user-notifications', {
36 query: { accessToken: this.auth.getAccessToken() } 37 query: { accessToken: this.auth.getAccessToken() }
37 }) 38 })
38 39
39 return this.socket 40 this.socket.on('new-notification', (n: UserNotificationServer) => this.dispatch('new', n))
40 } 41 }
41} 42}