mirror of https://github.com/Chocobozzz/PeerTube
Fix is managaeble for channels
parent
0736b2735f
commit
fef213cae1
|
@ -35,7 +35,8 @@ export class AccountsComponent implements OnInit, OnDestroy {
|
||||||
private redirectService: RedirectService,
|
private redirectService: RedirectService,
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
private i18n: I18n
|
private i18n: I18n
|
||||||
) {}
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit () {
|
ngOnInit () {
|
||||||
this.routeSub = this.route.params
|
this.routeSub = this.route.params
|
||||||
|
@ -46,12 +47,18 @@ export class AccountsComponent implements OnInit, OnDestroy {
|
||||||
tap(account => {
|
tap(account => {
|
||||||
this.account = 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.isAccountManageable = this.account.userId && this.account.userId === this.authService.getUser().id
|
||||||
|
|
||||||
this.accountFollowerTitle = this.i18n(
|
this.accountFollowerTitle = this.i18n(
|
||||||
'{{followers}} direct account followers',
|
'{{followers}} direct account followers',
|
||||||
{ followers: this.subscribersDisplayFor(account.followersCount) }
|
{ followers: this.subscribersDisplayFor(account.followersCount) }
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
this.getUserIfNeeded(account)
|
this.getUserIfNeeded(account)
|
||||||
}),
|
}),
|
||||||
|
@ -97,11 +104,8 @@ export class AccountsComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
const user = this.authService.getUser()
|
const user = this.authService.getUser()
|
||||||
if (user.hasRight(UserRight.MANAGE_USERS)) {
|
if (user.hasRight(UserRight.MANAGE_USERS)) {
|
||||||
forkJoin([
|
this.userService.getUser(account.userId).subscribe(
|
||||||
this.userService.getUser(account.userId),
|
accountUser => this.accountUser = accountUser,
|
||||||
this.authService.userInformationLoaded.pipe(first())
|
|
||||||
]).subscribe(
|
|
||||||
([ accountUser ]) => this.accountUser = accountUser,
|
|
||||||
|
|
||||||
err => this.notifier.error(err.message)
|
err => this.notifier.error(err.message)
|
||||||
)
|
)
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="right-buttons">
|
<div class="right-buttons">
|
||||||
<a *ngIf="isManageable" [routerLink]="[ '/my-account/video-channels/update', videoChannel.nameWithHost ]" class="btn btn-outline-tertiary mr-2" i18n>Manage</a>
|
<a *ngIf="isChannelManageable" [routerLink]="[ '/my-account/video-channels/update', videoChannel.nameWithHost ]" class="btn btn-outline-tertiary mr-2" i18n>Manage</a>
|
||||||
<my-subscribe-button #subscribeButton [videoChannels]="[videoChannel]"></my-subscribe-button>
|
<my-subscribe-button #subscribeButton [videoChannels]="[videoChannel]"></my-subscribe-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { ActivatedRoute } from '@angular/router'
|
||||||
import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
|
import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
|
||||||
import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
|
import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
|
||||||
import { RestExtractor } from '@app/shared'
|
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 { Subscription } from 'rxjs'
|
||||||
import { AuthService, Notifier } from '@app/core'
|
import { AuthService, Notifier } from '@app/core'
|
||||||
import { Hotkey, HotkeysService } from 'angular2-hotkeys'
|
import { Hotkey, HotkeysService } from 'angular2-hotkeys'
|
||||||
|
@ -19,6 +19,7 @@ export class VideoChannelsComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
videoChannel: VideoChannel
|
videoChannel: VideoChannel
|
||||||
hotkeys: Hotkey[]
|
hotkeys: Hotkey[]
|
||||||
|
isChannelManageable = false
|
||||||
|
|
||||||
private routeSub: Subscription
|
private routeSub: Subscription
|
||||||
|
|
||||||
|
@ -40,7 +41,17 @@ export class VideoChannelsComponent implements OnInit, OnDestroy {
|
||||||
switchMap(videoChannelName => this.videoChannelService.getVideoChannel(videoChannelName)),
|
switchMap(videoChannelName => this.videoChannelService.getVideoChannel(videoChannelName)),
|
||||||
catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 404 ]))
|
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 = [
|
this.hotkeys = [
|
||||||
new Hotkey('S', (event: KeyboardEvent): boolean => {
|
new Hotkey('S', (event: KeyboardEvent): boolean => {
|
||||||
|
|
Loading…
Reference in New Issue