From 38a3ccc7f8ad0ea94362b58c732af7c387ab46be Mon Sep 17 00:00:00 2001 From: kontrollanten <6680299+kontrollanten@users.noreply.github.com> Date: Mon, 24 Oct 2022 14:48:03 +0200 Subject: feat: show contained playlists under My videos (#5125) * feat: show contained playlists under My videos closes #4769 * refactor(server): remove unused types * fixes after code review * fix(client/video-miniature): add to playlist * fix(server/user/me): shortUUID response * Revert "fix(client/video-miniature): add to playlist" This reverts commit f1a0412391c7e2370b87df2594c9fe3f39a40ddc. * fix(client/PlaylistService): caching * Revert "fix(server/user/me): shortUUID response" This reverts commit e3f1ee4e335739b895bced938540c003df24af73. * Fix fetching playlists Co-authored-by: Chocobozzz --- .../+my-library/my-videos/my-videos.component.html | 1 + .../+my-library/my-videos/my-videos.component.ts | 28 ++++++++++++++++------ 2 files changed, 22 insertions(+), 7 deletions(-) (limited to 'client/src/app/+my-library') diff --git a/client/src/app/+my-library/my-videos/my-videos.component.html b/client/src/app/+my-library/my-videos/my-videos.component.html index 146dcf41e..995f6b75b 100644 --- a/client/src/app/+my-library/my-videos/my-videos.component.html +++ b/client/src/app/+my-library/my-videos/my-videos.component.html @@ -34,6 +34,7 @@ this.pagination.totalItems = res.total) - ) + }).pipe( + tap(res => this.pagination.totalItems = res.total), + tap(({ data }) => this.fetchVideosContainedInPlaylists(data)) + ) + } + + private fetchVideosContainedInPlaylists (videos: Video[]) { + this.playlistService.doVideosExistInPlaylist(videos.map(v => v.id)) + .subscribe(result => { + this.videosContainedInPlaylists = Object.keys(result).reduce((acc, videoId) => ({ + ...acc, + [videoId]: uniqBy(result[videoId], (p: VideoExistInPlaylist) => p.playlistId) + }), this.videosContainedInPlaylists) + }) } async deleteSelectedVideos () { -- cgit v1.2.3