+ addToWatchLaterText = 'Add to watch later'
+ addedToWatchLaterText = 'Added to watch later'
+ addedToWatchLater: boolean
+
+ watchLaterPlaylist: any
+
+ constructor (
+ private screenService: ScreenService,
+ private authService: AuthService,
+ private videoPlaylistService: VideoPlaylistService,
+ private cd: ChangeDetectorRef
+ ) {}
+
+ load () {
+ if (this.addedToWatchLater !== undefined) return
+ if (!this.isUserLoggedIn()) return
+
+ this.videoPlaylistService.doesVideoExistInPlaylist(this.video.id)
+ .subscribe(
+ existResult => {
+ for (const playlist of this.authService.getUser().specialPlaylists) {
+ const existingPlaylist = existResult[ this.video.id ].find(p => p.playlistId === playlist.id)
+ this.addedToWatchLater = !!existingPlaylist
+
+ if (existingPlaylist) {
+ this.watchLaterPlaylist = {
+ playlistId: existingPlaylist.playlistId,
+ playlistElementId: existingPlaylist.playlistElementId
+ }
+ } else {
+ this.watchLaterPlaylist = {
+ playlistId: playlist.id
+ }
+ }
+
+ this.cd.markForCheck()
+ }
+ }
+ )
+ }