]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
hooks filter:api.my-lib.playlist-elems.get.* (#5098)
authorkontrollanten <6680299+kontrollanten@users.noreply.github.com>
Fri, 8 Jul 2022 08:50:10 +0000 (10:50 +0200)
committerGitHub <noreply@github.com>
Fri, 8 Jul 2022 08:50:10 +0000 (10:50 +0200)
* hooks filter:api.my-lib.playlist-elems.get.*

closes #4776

* Introduce my-library plugin scope

Co-authored-by: Chocobozzz <me@florianbigard.com>
client/src/app/+my-library/my-video-playlists/my-video-playlist-elements.component.ts
client/src/root-helpers/plugins-manager.ts
shared/models/plugins/client/client-hook.model.ts
shared/models/plugins/client/plugin-client-scope.type.ts

index 8fba423c3d101d1a4fffe82d74bd1e686df4a601..c9739b6ccb5ae011dabe460d06509903b104dc86 100644 (file)
@@ -2,7 +2,7 @@ import { Subject, Subscription } from 'rxjs'
 import { CdkDragDrop } from '@angular/cdk/drag-drop'
 import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core'
 import { ActivatedRoute, Router } from '@angular/router'
-import { ComponentPagination, ConfirmService, Notifier, ScreenService } from '@app/core'
+import { ComponentPagination, ConfirmService, HooksService, Notifier, ScreenService } from '@app/core'
 import { DropdownAction } from '@app/shared/shared-main'
 import { VideoShareComponent } from '@app/shared/shared-share-modal'
 import { VideoPlaylist, VideoPlaylistElement, VideoPlaylistService } from '@app/shared/shared-video-playlist'
@@ -32,6 +32,7 @@ export class MyVideoPlaylistElementsComponent implements OnInit, OnDestroy {
   private paramsSub: Subscription
 
   constructor (
+    private hooks: HooksService,
     private notifier: Notifier,
     private router: Router,
     private confirmService: ConfirmService,
@@ -155,7 +156,13 @@ export class MyVideoPlaylistElementsComponent implements OnInit, OnDestroy {
   }
 
   private loadElements () {
-    this.videoPlaylistService.getPlaylistVideos({ videoPlaylistId: this.videoPlaylistId, componentPagination: this.pagination })
+    this.hooks.wrapObsFun(
+      this.videoPlaylistService.getPlaylistVideos.bind(this.videoPlaylistService),
+      { videoPlaylistId: this.videoPlaylistId, componentPagination: this.pagination },
+      'my-library',
+      'filter:api.my-library.video-playlist-elements.list.params',
+      'filter:api.my-library.video-playlist-elements.list.result'
+    )
         .subscribe(({ total, data }) => {
           this.playlistElements = this.playlistElements.concat(data)
           this.pagination.totalItems = total
index 61731032ad7f8cbed25bddd558370b246fdc01f2..49a19781b7be970e87e4451f707d9eb128b248c5 100644 (file)
@@ -67,7 +67,8 @@ class PluginsManager {
     signup: new ReplaySubject<boolean>(1),
     login: new ReplaySubject<boolean>(1),
     'video-edit': new ReplaySubject<boolean>(1),
-    embed: new ReplaySubject<boolean>(1)
+    embed: new ReplaySubject<boolean>(1),
+    'my-library': new ReplaySubject<boolean>(1)
   }
 
   private readonly peertubeHelpersFactory: PeertubeHelpersFactory
index 04d42d591898ccc7beb6b10cc7866f3221309459..466be89466e24f6908538f7c21f29a1956a7a4eb 100644 (file)
@@ -51,6 +51,10 @@ export const clientFilterHookObject = {
   // Filter form
   'filter:api.signup.registration.create.params': true,
 
+  // Filter params/result of the function that fetch video playlist elements of the my-library page
+  'filter:api.my-library.video-playlist-elements.list.params': true,
+  'filter:api.my-library.video-playlist-elements.list.result': true,
+
   // Filter the options to create our player
   'filter:internal.video-watch.player.build-options.params': true,
   'filter:internal.video-watch.player.build-options.result': true,
index 8cc234ff22d6494ce0d7a0ceae0694e48662f968..92734533df83e3ef4464730cbf782c1494b3f54f 100644 (file)
@@ -6,4 +6,5 @@ export type PluginClientScope =
   'login' |
   'embed' |
   'video-edit' |
-  'admin-plugin'
+  'admin-plugin' |
+  'my-library'