import * as debug from 'debug'
import { uniq } from 'lodash-es'
import { asyncScheduler, merge, Observable, of, ReplaySubject, Subject } from 'rxjs'
-import { bufferTime, catchError, filter, map, observeOn, share, switchMap, tap } from 'rxjs/operators'
+import { bufferTime, catchError, filter, map, observeOn, share, switchMap, tap, distinctUntilChanged } from 'rxjs/operators'
import { HttpClient, HttpParams } from '@angular/common/http'
import { Injectable, NgZone } from '@angular/core'
import { AuthUser, ComponentPaginationLight, RestExtractor, RestService, ServerService } from '@app/core'
) {
this.videoExistsInPlaylistObservable = merge(
this.videoExistsInPlaylistNotifier.pipe(
+ distinctUntilChanged(),
// We leave Angular zone so Protractor does not get stuck
bufferTime(500, leaveZone(this.ngZone, asyncScheduler)),
filter(videoIds => videoIds.length !== 0),
map(this.restExtractor.extractDataBool),
tap(() => {
const existsResult = this.videoExistsCache[videoId]
- const elem = existsResult.find(e => e.playlistElementId === playlistElementId)
- elem.startTimestamp = body.startTimestamp
- elem.stopTimestamp = body.stopTimestamp
+ if (existsResult) {
+ const elem = existsResult.find(e => e.playlistElementId === playlistElementId)
+
+ elem.startTimestamp = body.startTimestamp
+ elem.stopTimestamp = body.stopTimestamp
+ }
this.runPlaylistCheck(videoId)
}),