aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-01 17:41:03 +0200
committerChocobozzz <me@florianbigard.com>2021-07-01 17:41:03 +0200
commit674d903b0e993b3a67836f3dabba80282d9900ab (patch)
tree0318fb7e89827a63a5257ebb250f2915be085a5b
parent8b61dcaf23a66d508c05641c9c09747bf03cdb48 (diff)
downloadPeerTube-674d903b0e993b3a67836f3dabba80282d9900ab.tar.gz
PeerTube-674d903b0e993b3a67836f3dabba80282d9900ab.tar.zst
PeerTube-674d903b0e993b3a67836f3dabba80282d9900ab.zip
Support accountHandle and channelHandle
-rw-r--r--client/src/app/shared/shared-custom-markup/custom-markup.service.ts3
-rw-r--r--client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts25
-rw-r--r--client/src/app/shared/shared-main/video/video.service.ts4
-rw-r--r--shared/models/custom-markup/custom-markup-data.model.ts5
4 files changed, 27 insertions, 10 deletions
diff --git a/client/src/app/shared/shared-custom-markup/custom-markup.service.ts b/client/src/app/shared/shared-custom-markup/custom-markup.service.ts
index 15da94709..231e52d0a 100644
--- a/client/src/app/shared/shared-custom-markup/custom-markup.service.ts
+++ b/client/src/app/shared/shared-custom-markup/custom-markup.service.ts
@@ -188,6 +188,9 @@ export class CustomMarkupService {
188 categoryOneOf: this.buildArrayNumber(data.categoryOneOf) ?? [], 188 categoryOneOf: this.buildArrayNumber(data.categoryOneOf) ?? [],
189 languageOneOf: this.buildArrayString(data.languageOneOf) ?? [], 189 languageOneOf: this.buildArrayString(data.languageOneOf) ?? [],
190 190
191 accountHandle: data.accountHandle || undefined,
192 channelHandle: data.channelHandle || undefined,
193
191 filter: this.buildBoolean(data.onlyLocal) ? 'local' as VideoFilter : undefined 194 filter: this.buildBoolean(data.onlyLocal) ? 'local' as VideoFilter : undefined
192 } 195 }
193 196
diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts
index afa4f4799..d9f77802b 100644
--- a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts
+++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts
@@ -23,6 +23,8 @@ export class VideosListMarkupComponent implements CustomMarkupComponent, OnInit
23 @Input() onlyDisplayTitle: boolean 23 @Input() onlyDisplayTitle: boolean
24 @Input() filter: VideoFilter 24 @Input() filter: VideoFilter
25 @Input() maxRows: number 25 @Input() maxRows: number
26 @Input() channelHandle: string
27 @Input() accountHandle: string
26 28
27 @Output() loaded = new EventEmitter<boolean>() 29 @Output() loaded = new EventEmitter<boolean>()
28 30
@@ -66,6 +68,16 @@ export class VideosListMarkupComponent implements CustomMarkupComponent, OnInit
66 } 68 }
67 } 69 }
68 70
71 return this.getVideosObservable()
72 .pipe(finalize(() => this.loaded.emit(true)))
73 .subscribe(
74 ({ data }) => this.videos = data,
75
76 err => this.notifier.error('Error in videos list component: ' + err.message)
77 )
78 }
79
80 getVideosObservable () {
69 const options = { 81 const options = {
70 videoPagination: { 82 videoPagination: {
71 currentPage: 1, 83 currentPage: 1,
@@ -74,15 +86,14 @@ export class VideosListMarkupComponent implements CustomMarkupComponent, OnInit
74 categoryOneOf: this.categoryOneOf, 86 categoryOneOf: this.categoryOneOf,
75 languageOneOf: this.languageOneOf, 87 languageOneOf: this.languageOneOf,
76 filter: this.filter, 88 filter: this.filter,
77 sort: this.sort as VideoSortField 89 sort: this.sort as VideoSortField,
90 account: { nameWithHost: this.accountHandle },
91 videoChannel: { nameWithHost: this.channelHandle }
78 } 92 }
79 93
80 this.videoService.getVideos(options) 94 if (this.channelHandle) return this.videoService.getVideoChannelVideos(options)
81 .pipe(finalize(() => this.loaded.emit(true))) 95 if (this.accountHandle) return this.videoService.getAccountVideos(options)
82 .subscribe(
83 ({ data }) => this.videos = data,
84 96
85 err => this.notifier.error('Error in videos list component: ' + err.message) 97 return this.videoService.getVideos(options)
86 )
87 } 98 }
88} 99}
diff --git a/client/src/app/shared/shared-main/video/video.service.ts b/client/src/app/shared/shared-main/video/video.service.ts
index 1410edd18..ac640c791 100644
--- a/client/src/app/shared/shared-main/video/video.service.ts
+++ b/client/src/app/shared/shared-main/video/video.service.ts
@@ -145,7 +145,7 @@ export class VideoService implements VideosProvider {
145 } 145 }
146 146
147 getAccountVideos (parameters: { 147 getAccountVideos (parameters: {
148 account: Account, 148 account: Pick<Account, 'nameWithHost'>,
149 videoPagination: ComponentPaginationLight, 149 videoPagination: ComponentPaginationLight,
150 sort: VideoSortField 150 sort: VideoSortField
151 nsfwPolicy?: NSFWPolicyType 151 nsfwPolicy?: NSFWPolicyType
@@ -180,7 +180,7 @@ export class VideoService implements VideosProvider {
180 } 180 }
181 181
182 getVideoChannelVideos (parameters: { 182 getVideoChannelVideos (parameters: {
183 videoChannel: VideoChannel, 183 videoChannel: Pick<VideoChannel, 'nameWithHost'>,
184 videoPagination: ComponentPaginationLight, 184 videoPagination: ComponentPaginationLight,
185 sort: VideoSortField, 185 sort: VideoSortField,
186 nsfwPolicy?: NSFWPolicyType 186 nsfwPolicy?: NSFWPolicyType
diff --git a/shared/models/custom-markup/custom-markup-data.model.ts b/shared/models/custom-markup/custom-markup-data.model.ts
index c56494485..8cbe3cfa4 100644
--- a/shared/models/custom-markup/custom-markup-data.model.ts
+++ b/shared/models/custom-markup/custom-markup-data.model.ts
@@ -30,9 +30,12 @@ export type VideosListMarkupData = {
30 sort?: string 30 sort?: string
31 count?: string // number 31 count?: string // number
32 32
33 categoryOneOf?: string // coma separated values 33 categoryOneOf?: string // coma separated values, number[]
34 languageOneOf?: string // coma separated values 34 languageOneOf?: string // coma separated values
35 35
36 channelHandle?: string
37 accountHandle?: string
38
36 onlyLocal?: string // boolean 39 onlyLocal?: string // boolean
37} 40}
38 41