aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src
diff options
context:
space:
mode:
Diffstat (limited to 'client/src')
-rw-r--r--client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.ts1
-rw-r--r--client/src/app/menu/menu.component.ts56
-rw-r--r--client/src/app/modal/quick-settings-modal.component.ts23
3 files changed, 51 insertions, 29 deletions
diff --git a/client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.ts b/client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.ts
index ee3a6c73e..42259129c 100644
--- a/client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.ts
+++ b/client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.ts
@@ -58,7 +58,6 @@ export class RecommendedVideosComponent implements OnInit, OnChanges, OnDestroy
58 .subscribe(user => { 58 .subscribe(user => {
59 this.user = user 59 this.user = user
60 this.autoPlayNextVideo = user.autoPlayNextVideo 60 this.autoPlayNextVideo = user.autoPlayNextVideo
61 console.log(this.autoPlayNextVideo)
62 }) 61 })
63 } 62 }
64 63
diff --git a/client/src/app/menu/menu.component.ts b/client/src/app/menu/menu.component.ts
index 21354e52d..896c824b8 100644
--- a/client/src/app/menu/menu.component.ts
+++ b/client/src/app/menu/menu.component.ts
@@ -1,8 +1,9 @@
1import { HotkeysService } from 'angular2-hotkeys' 1import { HotkeysService } from 'angular2-hotkeys'
2import * as debug from 'debug' 2import * as debug from 'debug'
3import { switchMap } from 'rxjs/operators' 3import { forkJoin, Subscription } from 'rxjs'
4import { first, switchMap } from 'rxjs/operators'
4import { ViewportScroller } from '@angular/common' 5import { ViewportScroller } from '@angular/common'
5import { Component, OnInit, ViewChild } from '@angular/core' 6import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core'
6import { Router } from '@angular/router' 7import { Router } from '@angular/router'
7import { 8import {
8 AuthService, 9 AuthService,
@@ -30,7 +31,7 @@ const debugLogger = debug('peertube:menu:MenuComponent')
30 templateUrl: './menu.component.html', 31 templateUrl: './menu.component.html',
31 styleUrls: [ './menu.component.scss' ] 32 styleUrls: [ './menu.component.scss' ]
32}) 33})
33export class MenuComponent implements OnInit { 34export class MenuComponent implements OnInit, OnDestroy {
34 @ViewChild('languageChooserModal', { static: true }) languageChooserModal: LanguageChooserComponent 35 @ViewChild('languageChooserModal', { static: true }) languageChooserModal: LanguageChooserComponent
35 @ViewChild('quickSettingsModal', { static: true }) quickSettingsModal: QuickSettingsModalComponent 36 @ViewChild('quickSettingsModal', { static: true }) quickSettingsModal: QuickSettingsModalComponent
36 @ViewChild('dropdown') dropdown: NgbDropdown 37 @ViewChild('dropdown') dropdown: NgbDropdown
@@ -62,6 +63,11 @@ export class MenuComponent implements OnInit {
62 [UserRight.MANAGE_CONFIGURATION]: '/admin/config' 63 [UserRight.MANAGE_CONFIGURATION]: '/admin/config'
63 } 64 }
64 65
66 private languagesSub: Subscription
67 private modalSub: Subscription
68 private hotkeysSub: Subscription
69 private authSub: Subscription
70
65 constructor ( 71 constructor (
66 private viewportScroller: ViewportScroller, 72 private viewportScroller: ViewportScroller,
67 private authService: AuthService, 73 private authService: AuthService,
@@ -102,37 +108,43 @@ export class MenuComponent implements OnInit {
102 this.updateUserState() 108 this.updateUserState()
103 this.buildMenuSections() 109 this.buildMenuSections()
104 110
105 this.authService.loginChangedSource.subscribe( 111 this.authSub = this.authService.loginChangedSource.subscribe(status => {
106 status => { 112 if (status === AuthStatus.LoggedIn) {
107 if (status === AuthStatus.LoggedIn) { 113 this.isLoggedIn = true
108 this.isLoggedIn = true 114 } else if (status === AuthStatus.LoggedOut) {
109 } else if (status === AuthStatus.LoggedOut) { 115 this.isLoggedIn = false
110 this.isLoggedIn = false
111 }
112
113 this.updateUserState()
114 this.buildMenuSections()
115 } 116 }
116 )
117 117
118 this.hotkeysService.cheatSheetToggle 118 this.updateUserState()
119 this.buildMenuSections()
120 })
121
122 this.hotkeysSub = this.hotkeysService.cheatSheetToggle
119 .subscribe(isOpen => this.helpVisible = isOpen) 123 .subscribe(isOpen => this.helpVisible = isOpen)
120 124
121 this.serverService.getVideoLanguages() 125 this.languagesSub = forkJoin([
122 .subscribe(languages => { 126 this.serverService.getVideoLanguages(),
123 this.languages = languages 127 this.authService.userInformationLoaded.pipe(first())
128 ]).subscribe(([ languages ]) => {
129 this.languages = languages
124 130
125 this.authService.userInformationLoaded 131 this.buildUserLanguages()
126 .subscribe(() => this.buildUserLanguages()) 132 })
127 })
128 133
129 this.serverService.getConfig() 134 this.serverService.getConfig()
130 .subscribe(config => this.serverConfig = config) 135 .subscribe(config => this.serverConfig = config)
131 136
132 this.modalService.openQuickSettingsSubject 137 this.modalSub = this.modalService.openQuickSettingsSubject
133 .subscribe(() => this.openQuickSettings()) 138 .subscribe(() => this.openQuickSettings())
134 } 139 }
135 140
141 ngOnDestroy () {
142 if (this.modalSub) this.modalSub.unsubscribe()
143 if (this.languagesSub) this.languagesSub.unsubscribe()
144 if (this.hotkeysSub) this.hotkeysSub.unsubscribe()
145 if (this.authSub) this.authSub.unsubscribe()
146 }
147
136 isRegistrationAllowed () { 148 isRegistrationAllowed () {
137 if (!this.serverConfig) return false 149 if (!this.serverConfig) return false
138 150
diff --git a/client/src/app/modal/quick-settings-modal.component.ts b/client/src/app/modal/quick-settings-modal.component.ts
index 19f75ad5c..8ba58a23a 100644
--- a/client/src/app/modal/quick-settings-modal.component.ts
+++ b/client/src/app/modal/quick-settings-modal.component.ts
@@ -1,6 +1,6 @@
1import { ReplaySubject } from 'rxjs' 1import { ReplaySubject, Subscription } from 'rxjs'
2import { filter } from 'rxjs/operators' 2import { filter } from 'rxjs/operators'
3import { Component, OnInit, ViewChild } from '@angular/core' 3import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core'
4import { ActivatedRoute, Router } from '@angular/router' 4import { ActivatedRoute, Router } from '@angular/router'
5import { AuthService, AuthStatus, LocalStorageService, User, UserService } from '@app/core' 5import { AuthService, AuthStatus, LocalStorageService, User, UserService } from '@app/core'
6import { NgbModal } from '@ng-bootstrap/ng-bootstrap' 6import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
@@ -10,7 +10,7 @@ import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
10 selector: 'my-quick-settings', 10 selector: 'my-quick-settings',
11 templateUrl: './quick-settings-modal.component.html' 11 templateUrl: './quick-settings-modal.component.html'
12}) 12})
13export class QuickSettingsModalComponent implements OnInit { 13export class QuickSettingsModalComponent implements OnInit, OnDestroy {
14 private static readonly QUERY_MODAL_NAME = 'quick-settings' 14 private static readonly QUERY_MODAL_NAME = 'quick-settings'
15 15
16 @ViewChild('modal', { static: true }) modal: NgbModal 16 @ViewChild('modal', { static: true }) modal: NgbModal
@@ -20,6 +20,10 @@ export class QuickSettingsModalComponent implements OnInit {
20 20
21 private openedModal: NgbModalRef 21 private openedModal: NgbModalRef
22 22
23 private routeSub: Subscription
24 private loginSub: Subscription
25 private localStorageSub: Subscription
26
23 constructor ( 27 constructor (
24 private modalService: NgbModal, 28 private modalService: NgbModal,
25 private userService: UserService, 29 private userService: UserService,
@@ -32,14 +36,15 @@ export class QuickSettingsModalComponent implements OnInit {
32 36
33 ngOnInit () { 37 ngOnInit () {
34 this.user = this.userService.getAnonymousUser() 38 this.user = this.userService.getAnonymousUser()
35 this.localStorageService.watch() 39
40 this.localStorageSub = this.localStorageService.watch()
36 .subscribe({ 41 .subscribe({
37 next: () => this.user = this.userService.getAnonymousUser() 42 next: () => this.user = this.userService.getAnonymousUser()
38 }) 43 })
39 44
40 this.userInformationLoaded.next(true) 45 this.userInformationLoaded.next(true)
41 46
42 this.authService.loginChangedSource 47 this.loginSub = this.authService.loginChangedSource
43 .pipe(filter(status => status !== AuthStatus.LoggedIn)) 48 .pipe(filter(status => status !== AuthStatus.LoggedIn))
44 .subscribe({ 49 .subscribe({
45 next: () => { 50 next: () => {
@@ -48,7 +53,7 @@ export class QuickSettingsModalComponent implements OnInit {
48 } 53 }
49 }) 54 })
50 55
51 this.route.queryParams.subscribe(params => { 56 this.routeSub = this.route.queryParams.subscribe(params => {
52 if (params['modal'] === QuickSettingsModalComponent.QUERY_MODAL_NAME) { 57 if (params['modal'] === QuickSettingsModalComponent.QUERY_MODAL_NAME) {
53 this.openedModal = this.modalService.open(this.modal, { centered: true }) 58 this.openedModal = this.modalService.open(this.modal, { centered: true })
54 59
@@ -57,6 +62,12 @@ export class QuickSettingsModalComponent implements OnInit {
57 }) 62 })
58 } 63 }
59 64
65 ngOnDestroy () {
66 if (this.routeSub) this.routeSub.unsubscribe()
67 if (this.loginSub) this.loginSub.unsubscribe()
68 if (this.localStorageSub) this.localStorageSub.unsubscribe()
69 }
70
60 isUserLoggedIn () { 71 isUserLoggedIn () {
61 return this.authService.isLoggedIn() 72 return this.authService.isLoggedIn()
62 } 73 }