diff options
author | Chocobozzz <me@florianbigard.com> | 2021-06-09 10:31:27 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-06-09 10:31:27 +0200 |
commit | 61cbafc1f80a33a895b54b15751a42e0d78af231 (patch) | |
tree | 4ecbd18133550053afe0d12441030f8a1c257511 /client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts | |
parent | 9105634f16e5dfc66df198f23dbfae77dff2d821 (diff) | |
download | PeerTube-61cbafc1f80a33a895b54b15751a42e0d78af231.tar.gz PeerTube-61cbafc1f80a33a895b54b15751a42e0d78af231.tar.zst PeerTube-61cbafc1f80a33a895b54b15751a42e0d78af231.zip |
Improve channel card custom markup
Diffstat (limited to 'client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts')
-rw-r--r-- | client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts index 25deafb80..87caec8a5 100644 --- a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts | |||
@@ -1,5 +1,8 @@ | |||
1 | import { map, switchMap } from 'rxjs/operators' | ||
1 | import { Component, Input, OnInit } from '@angular/core' | 2 | import { Component, Input, OnInit } from '@angular/core' |
2 | import { VideoChannel, VideoChannelService } from '../../shared-main' | 3 | import { MarkdownService, UserService } from '@app/core' |
4 | import { Video, VideoSortField } from '@shared/models/videos' | ||
5 | import { VideoChannel, VideoChannelService, VideoService } from '../../shared-main' | ||
3 | 6 | ||
4 | /* | 7 | /* |
5 | * Markup component that creates a channel miniature only | 8 | * Markup component that creates a channel miniature only |
@@ -12,15 +15,55 @@ import { VideoChannel, VideoChannelService } from '../../shared-main' | |||
12 | }) | 15 | }) |
13 | export class ChannelMiniatureMarkupComponent implements OnInit { | 16 | export class ChannelMiniatureMarkupComponent implements OnInit { |
14 | @Input() name: string | 17 | @Input() name: string |
18 | @Input() displayLatestVideo: boolean | ||
19 | @Input() displayDescription: boolean | ||
15 | 20 | ||
16 | channel: VideoChannel | 21 | channel: VideoChannel |
22 | descriptionHTML: string | ||
23 | totalVideos: number | ||
24 | video: Video | ||
17 | 25 | ||
18 | constructor ( | 26 | constructor ( |
19 | private channelService: VideoChannelService | 27 | private markdown: MarkdownService, |
28 | private channelService: VideoChannelService, | ||
29 | private videoService: VideoService, | ||
30 | private userService: UserService | ||
20 | ) { } | 31 | ) { } |
21 | 32 | ||
22 | ngOnInit () { | 33 | ngOnInit () { |
23 | this.channelService.getVideoChannel(this.name) | 34 | this.channelService.getVideoChannel(this.name) |
24 | .subscribe(channel => this.channel = channel) | 35 | .subscribe(async channel => { |
36 | this.channel = channel | ||
37 | |||
38 | this.descriptionHTML = await this.markdown.textMarkdownToHTML(channel.description) | ||
39 | |||
40 | this.loadVideos() | ||
41 | }) | ||
42 | } | ||
43 | |||
44 | getVideoChannelLink () { | ||
45 | return [ '/c', this.channel.nameWithHost ] | ||
46 | } | ||
47 | |||
48 | private loadVideos () { | ||
49 | const videoOptions = { | ||
50 | videoChannel: this.channel, | ||
51 | videoPagination: { | ||
52 | currentPage: 1, | ||
53 | itemsPerPage: 1 | ||
54 | }, | ||
55 | sort: '-publishedAt' as VideoSortField, | ||
56 | count: 1 | ||
57 | } | ||
58 | |||
59 | this.userService.getAnonymousOrLoggedUser() | ||
60 | .pipe( | ||
61 | map(user => user.nsfwPolicy), | ||
62 | switchMap(nsfwPolicy => this.videoService.getVideoChannelVideos({ ...videoOptions, nsfwPolicy })) | ||
63 | ) | ||
64 | .subscribe(({ total, data }) => { | ||
65 | this.totalVideos = total | ||
66 | this.video = data[0] | ||
67 | }) | ||
25 | } | 68 | } |
26 | } | 69 | } |