From 15beb866605a5ab4fd075aa3945f6aaed4447c12 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 29 Dec 2022 10:38:53 +0100 Subject: Reorder playlists when adding an element --- .../shared-video-miniature/video-miniature.component.ts | 2 +- .../video-add-to-playlist.component.ts | 4 ++-- .../shared-video-playlist/video-playlist.service.ts | 16 ++++++++++++---- 3 files changed, 15 insertions(+), 7 deletions(-) (limited to 'client/src') diff --git a/client/src/app/shared/shared-video-miniature/video-miniature.component.ts b/client/src/app/shared/shared-video-miniature/video-miniature.component.ts index 85c63c173..706227e66 100644 --- a/client/src/app/shared/shared-video-miniature/video-miniature.component.ts +++ b/client/src/app/shared/shared-video-miniature/video-miniature.component.ts @@ -314,6 +314,6 @@ export class VideoMiniatureComponent implements OnInit { this.cd.markForCheck() }) - this.videoPlaylistService.runPlaylistCheck(this.video.id) + this.videoPlaylistService.runVideoExistsInPlaylistCheck(this.video.id) } } diff --git a/client/src/app/shared/shared-video-playlist/video-add-to-playlist.component.ts b/client/src/app/shared/shared-video-playlist/video-add-to-playlist.component.ts index 2fc39fc75..f802416a4 100644 --- a/client/src/app/shared/shared-video-playlist/video-add-to-playlist.component.ts +++ b/client/src/app/shared/shared-video-playlist/video-add-to-playlist.component.ts @@ -81,7 +81,7 @@ export class VideoAddToPlaylistComponent extends FormReactive implements OnInit, .subscribe(result => { this.playlistsData = result.data - this.videoPlaylistService.runPlaylistCheck(this.video.id) + this.videoPlaylistService.runVideoExistsInPlaylistCheck(this.video.id) }) this.videoPlaylistSearchChanged @@ -129,7 +129,7 @@ export class VideoAddToPlaylistComponent extends FormReactive implements OnInit, .subscribe(playlistsResult => { this.playlistsData = playlistsResult.data - this.videoPlaylistService.runPlaylistCheck(this.video.id) + this.videoPlaylistService.runVideoExistsInPlaylistCheck(this.video.id) }) } diff --git a/client/src/app/shared/shared-video-playlist/video-playlist.service.ts b/client/src/app/shared/shared-video-playlist/video-playlist.service.ts index 330a51f91..bc9fb0d74 100644 --- a/client/src/app/shared/shared-video-playlist/video-playlist.service.ts +++ b/client/src/app/shared/shared-video-playlist/video-playlist.service.ts @@ -206,7 +206,15 @@ export class VideoPlaylistService { stopTimestamp: body.stopTimestamp }) - this.runPlaylistCheck(body.videoId) + this.runVideoExistsInPlaylistCheck(body.videoId) + + if (this.myAccountPlaylistCache) { + const playlist = this.myAccountPlaylistCache.data.find(p => p.id === playlistId) + if (!playlist) return + + const otherPlaylists = this.myAccountPlaylistCache.data.filter(p => p !== playlist) + this.myAccountPlaylistCache.data = [ playlist, ...otherPlaylists ] + } }), catchError(err => this.restExtractor.handleError(err)) ) @@ -225,7 +233,7 @@ export class VideoPlaylistService { elem.stopTimestamp = body.stopTimestamp } - this.runPlaylistCheck(videoId) + this.runVideoExistsInPlaylistCheck(videoId) }), catchError(err => this.restExtractor.handleError(err)) ) @@ -242,7 +250,7 @@ export class VideoPlaylistService { .filter(e => e.playlistElementId !== playlistElementId) } - this.runPlaylistCheck(videoId) + this.runVideoExistsInPlaylistCheck(videoId) }), catchError(err => this.restExtractor.handleError(err)) ) @@ -296,7 +304,7 @@ export class VideoPlaylistService { return obs } - runPlaylistCheck (videoId: number) { + runVideoExistsInPlaylistCheck (videoId: number) { debugLogger('Running playlist check.') if (this.videoExistsCache[videoId]) { -- cgit v1.2.3