aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+video-channels/video-channels.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/+video-channels/video-channels.component.ts')
-rw-r--r--client/src/app/+video-channels/video-channels.component.ts46
1 files changed, 31 insertions, 15 deletions
diff --git a/client/src/app/+video-channels/video-channels.component.ts b/client/src/app/+video-channels/video-channels.component.ts
index bb601e227..037c108f2 100644
--- a/client/src/app/+video-channels/video-channels.component.ts
+++ b/client/src/app/+video-channels/video-channels.component.ts
@@ -3,8 +3,8 @@ import { Subscription } from 'rxjs'
3import { catchError, distinctUntilChanged, map, switchMap } from 'rxjs/operators' 3import { catchError, distinctUntilChanged, map, switchMap } from 'rxjs/operators'
4import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core' 4import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core'
5import { ActivatedRoute } from '@angular/router' 5import { ActivatedRoute } from '@angular/router'
6import { AuthService, Notifier, RestExtractor, ScreenService } from '@app/core' 6import { AuthService, MarkdownService, Notifier, RestExtractor, ScreenService } from '@app/core'
7import { ListOverflowItem, VideoChannel, VideoChannelService } from '@app/shared/shared-main' 7import { ListOverflowItem, VideoChannel, VideoChannelService, VideoService } from '@app/shared/shared-main'
8import { SubscribeButtonComponent } from '@app/shared/shared-user-subscription' 8import { SubscribeButtonComponent } from '@app/shared/shared-user-subscription'
9import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' 9import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
10 10
@@ -20,6 +20,11 @@ export class VideoChannelsComponent implements OnInit, OnDestroy {
20 links: ListOverflowItem[] = [] 20 links: ListOverflowItem[] = []
21 isChannelManageable = false 21 isChannelManageable = false
22 22
23 channelVideosCount: number
24 ownerDescriptionHTML = ''
25 channelDescriptionHTML = ''
26 channelDescriptionExpanded = false
27
23 private routeSub: Subscription 28 private routeSub: Subscription
24 29
25 constructor ( 30 constructor (
@@ -27,9 +32,11 @@ export class VideoChannelsComponent implements OnInit, OnDestroy {
27 private notifier: Notifier, 32 private notifier: Notifier,
28 private authService: AuthService, 33 private authService: AuthService,
29 private videoChannelService: VideoChannelService, 34 private videoChannelService: VideoChannelService,
35 private videoService: VideoService,
30 private restExtractor: RestExtractor, 36 private restExtractor: RestExtractor,
31 private hotkeysService: HotkeysService, 37 private hotkeysService: HotkeysService,
32 private screenService: ScreenService 38 private screenService: ScreenService,
39 private markdown: MarkdownService
33 ) { } 40 ) { }
34 41
35 ngOnInit () { 42 ngOnInit () {
@@ -43,16 +50,14 @@ export class VideoChannelsComponent implements OnInit, OnDestroy {
43 HttpStatusCode.NOT_FOUND_404 50 HttpStatusCode.NOT_FOUND_404
44 ])) 51 ]))
45 ) 52 )
46 .subscribe(videoChannel => { 53 .subscribe(async videoChannel => {
54 this.channelDescriptionHTML = await this.markdown.textMarkdownToHTML(videoChannel.description)
55 this.ownerDescriptionHTML = await this.markdown.textMarkdownToHTML(videoChannel.ownerAccount.description)
56
57 // After the markdown renderer to avoid layout changes
47 this.videoChannel = videoChannel 58 this.videoChannel = videoChannel
48 59
49 if (this.authService.isLoggedIn()) { 60 this.loadChannelVideosCount()
50 this.authService.userInformationLoaded
51 .subscribe(() => {
52 const channelUserId = this.videoChannel.ownerAccount.userId
53 this.isChannelManageable = channelUserId && channelUserId === this.authService.getUser().id
54 })
55 }
56 }) 61 })
57 62
58 this.hotkeys = [ 63 this.hotkeys = [
@@ -67,8 +72,7 @@ export class VideoChannelsComponent implements OnInit, OnDestroy {
67 72
68 this.links = [ 73 this.links = [
69 { label: $localize`VIDEOS`, routerLink: 'videos' }, 74 { label: $localize`VIDEOS`, routerLink: 'videos' },
70 { label: $localize`VIDEO PLAYLISTS`, routerLink: 'video-playlists' }, 75 { label: $localize`VIDEO PLAYLISTS`, routerLink: 'video-playlists' }
71 { label: $localize`ABOUT`, routerLink: 'about' }
72 ] 76 ]
73 } 77 }
74 78
@@ -79,7 +83,7 @@ export class VideoChannelsComponent implements OnInit, OnDestroy {
79 if (this.isUserLoggedIn()) this.hotkeysService.remove(this.hotkeys) 83 if (this.isUserLoggedIn()) this.hotkeysService.remove(this.hotkeys)
80 } 84 }
81 85
82 get isInSmallView () { 86 isInSmallView () {
83 return this.screenService.isInSmallView() 87 return this.screenService.isInSmallView()
84 } 88 }
85 89
@@ -87,12 +91,24 @@ export class VideoChannelsComponent implements OnInit, OnDestroy {
87 return this.authService.isLoggedIn() 91 return this.authService.isLoggedIn()
88 } 92 }
89 93
90 get isManageable () { 94 isManageable () {
91 if (!this.isUserLoggedIn()) return false 95 if (!this.isUserLoggedIn()) return false
96
92 return this.videoChannel.ownerAccount.userId === this.authService.getUser().id 97 return this.videoChannel.ownerAccount.userId === this.authService.getUser().id
93 } 98 }
94 99
95 activateCopiedMessage () { 100 activateCopiedMessage () {
96 this.notifier.success($localize`Username copied`) 101 this.notifier.success($localize`Username copied`)
97 } 102 }
103
104 private loadChannelVideosCount () {
105 this.videoService.getVideoChannelVideos({
106 videoChannel: this.videoChannel,
107 videoPagination: {
108 currentPage: 1,
109 itemsPerPage: 0
110 },
111 sort: '-publishedAt'
112 }).subscribe(res => this.channelVideosCount = res.total)
113 }
98} 114}