]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Support accountHandle and channelHandle
authorChocobozzz <me@florianbigard.com>
Thu, 1 Jul 2021 15:41:03 +0000 (17:41 +0200)
committerChocobozzz <me@florianbigard.com>
Thu, 1 Jul 2021 15:41:03 +0000 (17:41 +0200)
client/src/app/shared/shared-custom-markup/custom-markup.service.ts
client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts
client/src/app/shared/shared-main/video/video.service.ts
shared/models/custom-markup/custom-markup-data.model.ts

index 15da94709eccf7ae59a637ebb965e2accdca956f..231e52d0a57d8c74b96c78fdfbd14c4fbb8e2fd6 100644 (file)
@@ -188,6 +188,9 @@ export class CustomMarkupService {
       categoryOneOf: this.buildArrayNumber(data.categoryOneOf) ?? [],
       languageOneOf: this.buildArrayString(data.languageOneOf) ?? [],
 
+      accountHandle: data.accountHandle || undefined,
+      channelHandle: data.channelHandle || undefined,
+
       filter: this.buildBoolean(data.onlyLocal) ? 'local' as VideoFilter : undefined
     }
 
index afa4f47991b08784123baf551befd8f288535644..d9f77802b91e956ed55e9e38ad8d567336aef055 100644 (file)
@@ -23,6 +23,8 @@ export class VideosListMarkupComponent implements CustomMarkupComponent, OnInit
   @Input() onlyDisplayTitle: boolean
   @Input() filter: VideoFilter
   @Input() maxRows: number
+  @Input() channelHandle: string
+  @Input() accountHandle: string
 
   @Output() loaded = new EventEmitter<boolean>()
 
@@ -66,6 +68,16 @@ export class VideosListMarkupComponent implements CustomMarkupComponent, OnInit
       }
     }
 
+    return this.getVideosObservable()
+      .pipe(finalize(() => this.loaded.emit(true)))
+      .subscribe(
+        ({ data }) => this.videos = data,
+
+        err => this.notifier.error('Error in videos list component: ' + err.message)
+      )
+  }
+
+  getVideosObservable () {
     const options = {
       videoPagination: {
         currentPage: 1,
@@ -74,15 +86,14 @@ export class VideosListMarkupComponent implements CustomMarkupComponent, OnInit
       categoryOneOf: this.categoryOneOf,
       languageOneOf: this.languageOneOf,
       filter: this.filter,
-      sort: this.sort as VideoSortField
+      sort: this.sort as VideoSortField,
+      account: { nameWithHost: this.accountHandle },
+      videoChannel: { nameWithHost: this.channelHandle }
     }
 
-    this.videoService.getVideos(options)
-      .pipe(finalize(() => this.loaded.emit(true)))
-      .subscribe(
-        ({ data }) => this.videos = data,
+    if (this.channelHandle) return this.videoService.getVideoChannelVideos(options)
+    if (this.accountHandle) return this.videoService.getAccountVideos(options)
 
-        err => this.notifier.error('Error in videos list component: ' + err.message)
-      )
+    return this.videoService.getVideos(options)
   }
 }
index 1410edd18d32544b118c3e46821b498911361f9f..ac640c79186fc7ba0c9cc77a84e94023201b068a 100644 (file)
@@ -145,7 +145,7 @@ export class VideoService implements VideosProvider {
   }
 
   getAccountVideos (parameters: {
-    account: Account,
+    account: Pick<Account, 'nameWithHost'>,
     videoPagination: ComponentPaginationLight,
     sort: VideoSortField
     nsfwPolicy?: NSFWPolicyType
@@ -180,7 +180,7 @@ export class VideoService implements VideosProvider {
   }
 
   getVideoChannelVideos (parameters: {
-    videoChannel: VideoChannel,
+    videoChannel: Pick<VideoChannel, 'nameWithHost'>,
     videoPagination: ComponentPaginationLight,
     sort: VideoSortField,
     nsfwPolicy?: NSFWPolicyType
index c5649448524830e614d4388776aaf0f7fac30ebe..8cbe3cfa4731ea680f2500008350af4805f4f705 100644 (file)
@@ -30,9 +30,12 @@ export type VideosListMarkupData = {
   sort?: string
   count?: string // number
 
-  categoryOneOf?: string // coma separated values
+  categoryOneOf?: string // coma separated values, number[]
   languageOneOf?: string // coma separated values
 
+  channelHandle?: string
+  accountHandle?: string
+
   onlyLocal?: string // boolean
 }