X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fvideo%2Fvideo-miniature.component.ts;h=1dfb3eec7ad706b53e258b460555bfed06c63fb2;hb=d5692d4088cdd9fde3be6ff34be8ce2816dab0cf;hp=a603f87e5b59b5ff451ec606c8723954ac2774da;hpb=b7819090de8ced71e5f9c5773c575ab627a148e4;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/shared/video/video-miniature.component.ts b/client/src/app/shared/video/video-miniature.component.ts index a603f87e5..1dfb3eec7 100644 --- a/client/src/app/shared/video/video-miniature.component.ts +++ b/client/src/app/shared/video/video-miniature.component.ts @@ -17,8 +17,7 @@ import { I18n } from '@ngx-translate/i18n-polyfill' import { VideoActionsDisplayType } from '@app/shared/video/video-actions-dropdown.component' import { ScreenService } from '@app/shared/misc/screen.service' import { VideoPlaylistService } from '@app/shared/video-playlist/video-playlist.service' -import { forkJoin } from 'rxjs' -import { first } from 'rxjs/operators' +import { switchMap } from 'rxjs/operators' export type OwnerDisplayType = 'account' | 'videoChannel' | 'auto' export type MiniatureDisplayOptions = { @@ -65,7 +64,8 @@ export class VideoMiniatureComponent implements OnInit { update: true, blacklist: true, delete: true, - report: true + report: true, + duplicate: false } showActions = false serverConfig: ServerConfig @@ -193,7 +193,7 @@ export class VideoMiniatureComponent implements OnInit { } removeFromWatchLater () { - this.videoPlaylistService.removeVideoFromPlaylist(this.watchLaterPlaylist.id, this.watchLaterPlaylist.playlistElementId) + this.videoPlaylistService.removeVideoFromPlaylist(this.watchLaterPlaylist.id, this.watchLaterPlaylist.playlistElementId, this.video.id) .subscribe( _ => { /* empty */ } ) @@ -222,27 +222,27 @@ export class VideoMiniatureComponent implements OnInit { } private loadWatchLater () { - if (!this.isUserLoggedIn()) return - - forkJoin([ - this.videoPlaylistService.doesVideoExistInPlaylist(this.video.id), - this.authService.userInformationLoaded.pipe(first()) - ]).subscribe( - ([ existResult ]) => { - const watchLaterPlaylist = this.authService.getUser().specialPlaylists.find(p => p.type === VideoPlaylistType.WATCH_LATER) - const existsInWatchLater = existResult[ this.video.id ].find(r => r.playlistId === watchLaterPlaylist.id) - this.inWatchLaterPlaylist = false - - this.watchLaterPlaylist = { - id: watchLaterPlaylist.id - } - - if (existsInWatchLater) { - this.inWatchLaterPlaylist = true - this.watchLaterPlaylist.playlistElementId = existsInWatchLater.playlistElementId - } - - this.cd.markForCheck() - }) + if (!this.isUserLoggedIn() || this.inWatchLaterPlaylist !== undefined) return + + this.authService.userInformationLoaded + .pipe(switchMap(() => this.videoPlaylistService.listenToVideoPlaylistChange(this.video.id))) + .subscribe(existResult => { + const watchLaterPlaylist = this.authService.getUser().specialPlaylists.find(p => p.type === VideoPlaylistType.WATCH_LATER) + const existsInWatchLater = existResult.find(r => r.playlistId === watchLaterPlaylist.id) + this.inWatchLaterPlaylist = false + + this.watchLaterPlaylist = { + id: watchLaterPlaylist.id + } + + if (existsInWatchLater) { + this.inWatchLaterPlaylist = true + this.watchLaterPlaylist.playlistElementId = existsInWatchLater.playlistElementId + } + + this.cd.markForCheck() + }) + + this.videoPlaylistService.runPlaylistCheck(this.video.id) } }