diff options
author | kontrollanten <6680299+kontrollanten@users.noreply.github.com> | 2022-10-24 14:48:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-24 14:48:03 +0200 |
commit | 38a3ccc7f8ad0ea94362b58c732af7c387ab46be (patch) | |
tree | ccbd200c4b95d0fcfa56b7d5fc3c9490887187b1 /client/src/app/+my-library | |
parent | 01a3c07a7913891d4830797403b3865d53f0af61 (diff) | |
download | PeerTube-38a3ccc7f8ad0ea94362b58c732af7c387ab46be.tar.gz PeerTube-38a3ccc7f8ad0ea94362b58c732af7c387ab46be.tar.zst PeerTube-38a3ccc7f8ad0ea94362b58c732af7c387ab46be.zip |
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 <me@florianbigard.com>
Diffstat (limited to 'client/src/app/+my-library')
-rw-r--r-- | client/src/app/+my-library/my-videos/my-videos.component.html | 1 | ||||
-rw-r--r-- | client/src/app/+my-library/my-videos/my-videos.component.ts | 28 |
2 files changed, 22 insertions, 7 deletions
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 @@ | |||
34 | </div> | 34 | </div> |
35 | 35 | ||
36 | <my-videos-selection | 36 | <my-videos-selection |
37 | [videosContainedInPlaylists]="videosContainedInPlaylists" | ||
37 | [pagination]="pagination" | 38 | [pagination]="pagination" |
38 | [(selection)]="selection" | 39 | [(selection)]="selection" |
39 | [(videosModel)]="videos" | 40 | [(videosModel)]="videos" |
diff --git a/client/src/app/+my-library/my-videos/my-videos.component.ts b/client/src/app/+my-library/my-videos/my-videos.component.ts index 3ff0ee248..f5262da86 100644 --- a/client/src/app/+my-library/my-videos/my-videos.component.ts +++ b/client/src/app/+my-library/my-videos/my-videos.component.ts | |||
@@ -1,10 +1,11 @@ | |||
1 | import { uniqBy } from 'lodash' | ||
1 | import { concat, Observable } from 'rxjs' | 2 | import { concat, Observable } from 'rxjs' |
2 | import { tap, toArray } from 'rxjs/operators' | 3 | import { tap, toArray } from 'rxjs/operators' |
3 | import { Component, OnInit, ViewChild } from '@angular/core' | 4 | import { Component, OnInit, ViewChild } from '@angular/core' |
4 | import { ActivatedRoute, Router } from '@angular/router' | 5 | import { ActivatedRoute, Router } from '@angular/router' |
5 | import { AuthService, ComponentPagination, ConfirmService, Notifier, ScreenService, ServerService, User } from '@app/core' | 6 | import { AuthService, ComponentPagination, ConfirmService, Notifier, ScreenService, ServerService, User } from '@app/core' |
6 | import { DisableForReuseHook } from '@app/core/routing/disable-for-reuse-hook' | 7 | import { DisableForReuseHook } from '@app/core/routing/disable-for-reuse-hook' |
7 | import { prepareIcu, immutableAssign } from '@app/helpers' | 8 | import { immutableAssign, prepareIcu } from '@app/helpers' |
8 | import { AdvancedInputFilter } from '@app/shared/shared-forms' | 9 | import { AdvancedInputFilter } from '@app/shared/shared-forms' |
9 | import { DropdownAction, Video, VideoService } from '@app/shared/shared-main' | 10 | import { DropdownAction, Video, VideoService } from '@app/shared/shared-main' |
10 | import { LiveStreamInformationComponent } from '@app/shared/shared-video-live' | 11 | import { LiveStreamInformationComponent } from '@app/shared/shared-video-live' |
@@ -14,7 +15,8 @@ import { | |||
14 | VideoActionsDisplayType, | 15 | VideoActionsDisplayType, |
15 | VideosSelectionComponent | 16 | VideosSelectionComponent |
16 | } from '@app/shared/shared-video-miniature' | 17 | } from '@app/shared/shared-video-miniature' |
17 | import { VideoChannel, VideoSortField } from '@shared/models' | 18 | import { VideoPlaylistService } from '@app/shared/shared-video-playlist' |
19 | import { VideoChannel, VideoExistInPlaylist, VideosExistInPlaylists, VideoSortField } from '@shared/models' | ||
18 | import { VideoChangeOwnershipComponent } from './modals/video-change-ownership.component' | 20 | import { VideoChangeOwnershipComponent } from './modals/video-change-ownership.component' |
19 | 21 | ||
20 | @Component({ | 22 | @Component({ |
@@ -26,6 +28,7 @@ export class MyVideosComponent implements OnInit, DisableForReuseHook { | |||
26 | @ViewChild('videoChangeOwnershipModal', { static: true }) videoChangeOwnershipModal: VideoChangeOwnershipComponent | 28 | @ViewChild('videoChangeOwnershipModal', { static: true }) videoChangeOwnershipModal: VideoChangeOwnershipComponent |
27 | @ViewChild('liveStreamInformationModal', { static: true }) liveStreamInformationModal: LiveStreamInformationComponent | 29 | @ViewChild('liveStreamInformationModal', { static: true }) liveStreamInformationModal: LiveStreamInformationComponent |
28 | 30 | ||
31 | videosContainedInPlaylists: VideosExistInPlaylists = {} | ||
29 | titlePage: string | 32 | titlePage: string |
30 | selection: SelectionType = {} | 33 | selection: SelectionType = {} |
31 | pagination: ComponentPagination = { | 34 | pagination: ComponentPagination = { |
@@ -83,7 +86,8 @@ export class MyVideosComponent implements OnInit, DisableForReuseHook { | |||
83 | protected notifier: Notifier, | 86 | protected notifier: Notifier, |
84 | protected screenService: ScreenService, | 87 | protected screenService: ScreenService, |
85 | private confirmService: ConfirmService, | 88 | private confirmService: ConfirmService, |
86 | private videoService: VideoService | 89 | private videoService: VideoService, |
90 | private playlistService: VideoPlaylistService | ||
87 | ) { | 91 | ) { |
88 | this.titlePage = $localize`My videos` | 92 | this.titlePage = $localize`My videos` |
89 | } | 93 | } |
@@ -156,10 +160,20 @@ export class MyVideosComponent implements OnInit, DisableForReuseHook { | |||
156 | sort: this.sort, | 160 | sort: this.sort, |
157 | userChannels: this.userChannels, | 161 | userChannels: this.userChannels, |
158 | search: this.search | 162 | search: this.search |
159 | }) | 163 | }).pipe( |
160 | .pipe( | 164 | tap(res => this.pagination.totalItems = res.total), |
161 | tap(res => this.pagination.totalItems = res.total) | 165 | tap(({ data }) => this.fetchVideosContainedInPlaylists(data)) |
162 | ) | 166 | ) |
167 | } | ||
168 | |||
169 | private fetchVideosContainedInPlaylists (videos: Video[]) { | ||
170 | this.playlistService.doVideosExistInPlaylist(videos.map(v => v.id)) | ||
171 | .subscribe(result => { | ||
172 | this.videosContainedInPlaylists = Object.keys(result).reduce((acc, videoId) => ({ | ||
173 | ...acc, | ||
174 | [videoId]: uniqBy(result[videoId], (p: VideoExistInPlaylist) => p.playlistId) | ||
175 | }), this.videosContainedInPlaylists) | ||
176 | }) | ||
163 | } | 177 | } |
164 | 178 | ||
165 | async deleteSelectedVideos () { | 179 | async deleteSelectedVideos () { |