private redirectService: RedirectService,
private authService: AuthService,
private i18n: I18n
- ) {}
+ ) {
+ }
ngOnInit () {
this.routeSub = this.route.params
- .pipe(
- map(params => params[ 'accountId' ]),
- distinctUntilChanged(),
- switchMap(accountId => this.accountService.getAccount(accountId)),
- tap(account => {
- this.account = account
-
- this.isAccountManageable = this.account.userId && this.account.userId === this.authService.getUser().id
-
- this.accountFollowerTitle = this.i18n(
- '{{followers}} direct account followers',
- { followers: this.subscribersDisplayFor(account.followersCount) }
- )
-
- this.getUserIfNeeded(account)
- }),
- switchMap(account => this.videoChannelService.listAccountVideoChannels(account)),
- catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 404 ]))
- )
- .subscribe(
- videoChannels => this.videoChannels = videoChannels.data,
-
- err => this.notifier.error(err.message)
- )
+ .pipe(
+ map(params => params[ 'accountId' ]),
+ distinctUntilChanged(),
+ switchMap(accountId => this.accountService.getAccount(accountId)),
+ tap(account => {
+ this.account = account
+
+ if (this.authService.isLoggedIn()) {
+ this.authService.userInformationLoaded.subscribe(
+ () => {
+ this.isAccountManageable = this.account.userId && this.account.userId === this.authService.getUser().id
+
+ this.accountFollowerTitle = this.i18n(
+ '{{followers}} direct account followers',
+ { followers: this.subscribersDisplayFor(account.followersCount) }
+ )
+ }
+ )
+ }
+
+ this.getUserIfNeeded(account)
+ }),
+ switchMap(account => this.videoChannelService.listAccountVideoChannels(account)),
+ catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 404 ]))
+ )
+ .subscribe(
+ videoChannels => this.videoChannels = videoChannels.data,
+
+ err => this.notifier.error(err.message)
+ )
}
ngOnDestroy () {
const user = this.authService.getUser()
if (user.hasRight(UserRight.MANAGE_USERS)) {
- forkJoin([
- this.userService.getUser(account.userId),
- this.authService.userInformationLoaded.pipe(first())
- ]).subscribe(
- ([ accountUser ]) => this.accountUser = accountUser,
+ this.userService.getUser(account.userId).subscribe(
+ accountUser => this.accountUser = accountUser,
err => this.notifier.error(err.message)
)
import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
import { RestExtractor } from '@app/shared'
-import { catchError, distinctUntilChanged, map, switchMap } from 'rxjs/operators'
+import { catchError, distinctUntilChanged, map, switchMap, tap } from 'rxjs/operators'
import { Subscription } from 'rxjs'
import { AuthService, Notifier } from '@app/core'
import { Hotkey, HotkeysService } from 'angular2-hotkeys'
videoChannel: VideoChannel
hotkeys: Hotkey[]
+ isChannelManageable = false
private routeSub: Subscription
switchMap(videoChannelName => this.videoChannelService.getVideoChannel(videoChannelName)),
catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 404 ]))
)
- .subscribe(videoChannel => this.videoChannel = videoChannel)
+ .subscribe(videoChannel => {
+ this.videoChannel = videoChannel
+
+ if (this.authService.isLoggedIn()) {
+ this.authService.userInformationLoaded
+ .subscribe(() => {
+ const channelUserId = this.videoChannel.ownerAccount.userId
+ this.isChannelManageable = channelUserId && channelUserId === this.authService.getUser().id
+ })
+ }
+ })
this.hotkeys = [
new Hotkey('S', (event: KeyboardEvent): boolean => {