diff options
Diffstat (limited to 'client/src/app/shared/video')
-rw-r--r-- | client/src/app/shared/video/video-miniature.component.ts | 49 | ||||
-rw-r--r-- | client/src/app/shared/video/video-thumbnail.component.html | 2 |
2 files changed, 25 insertions, 26 deletions
diff --git a/client/src/app/shared/video/video-miniature.component.ts b/client/src/app/shared/video/video-miniature.component.ts index a603f87e5..598a7a983 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' | |||
17 | import { VideoActionsDisplayType } from '@app/shared/video/video-actions-dropdown.component' | 17 | import { VideoActionsDisplayType } from '@app/shared/video/video-actions-dropdown.component' |
18 | import { ScreenService } from '@app/shared/misc/screen.service' | 18 | import { ScreenService } from '@app/shared/misc/screen.service' |
19 | import { VideoPlaylistService } from '@app/shared/video-playlist/video-playlist.service' | 19 | import { VideoPlaylistService } from '@app/shared/video-playlist/video-playlist.service' |
20 | import { forkJoin } from 'rxjs' | 20 | import { switchMap } from 'rxjs/operators' |
21 | import { first } from 'rxjs/operators' | ||
22 | 21 | ||
23 | export type OwnerDisplayType = 'account' | 'videoChannel' | 'auto' | 22 | export type OwnerDisplayType = 'account' | 'videoChannel' | 'auto' |
24 | export type MiniatureDisplayOptions = { | 23 | export type MiniatureDisplayOptions = { |
@@ -193,7 +192,7 @@ export class VideoMiniatureComponent implements OnInit { | |||
193 | } | 192 | } |
194 | 193 | ||
195 | removeFromWatchLater () { | 194 | removeFromWatchLater () { |
196 | this.videoPlaylistService.removeVideoFromPlaylist(this.watchLaterPlaylist.id, this.watchLaterPlaylist.playlistElementId) | 195 | this.videoPlaylistService.removeVideoFromPlaylist(this.watchLaterPlaylist.id, this.watchLaterPlaylist.playlistElementId, this.video.id) |
197 | .subscribe( | 196 | .subscribe( |
198 | _ => { /* empty */ } | 197 | _ => { /* empty */ } |
199 | ) | 198 | ) |
@@ -222,27 +221,27 @@ export class VideoMiniatureComponent implements OnInit { | |||
222 | } | 221 | } |
223 | 222 | ||
224 | private loadWatchLater () { | 223 | private loadWatchLater () { |
225 | if (!this.isUserLoggedIn()) return | 224 | if (!this.isUserLoggedIn() || this.inWatchLaterPlaylist !== undefined) return |
226 | 225 | ||
227 | forkJoin([ | 226 | this.authService.userInformationLoaded |
228 | this.videoPlaylistService.doesVideoExistInPlaylist(this.video.id), | 227 | .pipe(switchMap(() => this.videoPlaylistService.listenToVideoPlaylistChange(this.video.id))) |
229 | this.authService.userInformationLoaded.pipe(first()) | 228 | .subscribe(existResult => { |
230 | ]).subscribe( | 229 | const watchLaterPlaylist = this.authService.getUser().specialPlaylists.find(p => p.type === VideoPlaylistType.WATCH_LATER) |
231 | ([ existResult ]) => { | 230 | const existsInWatchLater = existResult.find(r => r.playlistId === watchLaterPlaylist.id) |
232 | const watchLaterPlaylist = this.authService.getUser().specialPlaylists.find(p => p.type === VideoPlaylistType.WATCH_LATER) | 231 | this.inWatchLaterPlaylist = false |
233 | const existsInWatchLater = existResult[ this.video.id ].find(r => r.playlistId === watchLaterPlaylist.id) | 232 | |
234 | this.inWatchLaterPlaylist = false | 233 | this.watchLaterPlaylist = { |
235 | 234 | id: watchLaterPlaylist.id | |
236 | this.watchLaterPlaylist = { | 235 | } |
237 | id: watchLaterPlaylist.id | 236 | |
238 | } | 237 | if (existsInWatchLater) { |
239 | 238 | this.inWatchLaterPlaylist = true | |
240 | if (existsInWatchLater) { | 239 | this.watchLaterPlaylist.playlistElementId = existsInWatchLater.playlistElementId |
241 | this.inWatchLaterPlaylist = true | 240 | } |
242 | this.watchLaterPlaylist.playlistElementId = existsInWatchLater.playlistElementId | 241 | |
243 | } | 242 | this.cd.markForCheck() |
244 | 243 | }) | |
245 | this.cd.markForCheck() | 244 | |
246 | }) | 245 | this.videoPlaylistService.runPlaylistCheck(this.video.id) |
247 | } | 246 | } |
248 | } | 247 | } |
diff --git a/client/src/app/shared/video/video-thumbnail.component.html b/client/src/app/shared/video/video-thumbnail.component.html index c30a43557..7e71a390b 100644 --- a/client/src/app/shared/video/video-thumbnail.component.html +++ b/client/src/app/shared/video/video-thumbnail.component.html | |||
@@ -2,7 +2,7 @@ | |||
2 | [routerLink]="getVideoRouterLink()" [queryParams]="queryParams" [attr.title]="video.name" | 2 | [routerLink]="getVideoRouterLink()" [queryParams]="queryParams" [attr.title]="video.name" |
3 | class="video-thumbnail" | 3 | class="video-thumbnail" |
4 | > | 4 | > |
5 | <img alt="" [attr.aria-labelledby]="video.name" [attr.src]="getImageUrl()" [ngClass]="{ 'blur-filter': nsfw }" loading="lazy" /> | 5 | <img alt="" [attr.aria-labelledby]="video.name" [attr.src]="getImageUrl()" [ngClass]="{ 'blur-filter': nsfw }" /> |
6 | 6 | ||
7 | <div *ngIf="displayWatchLaterPlaylist" class="video-thumbnail-actions-overlay"> | 7 | <div *ngIf="displayWatchLaterPlaylist" class="video-thumbnail-actions-overlay"> |
8 | <ng-container *ngIf="inWatchLaterPlaylist !== true"> | 8 | <ng-container *ngIf="inWatchLaterPlaylist !== true"> |