Fix playlist cache error
authorChocobozzz <me@florianbigard.com>
Mon, 17 Feb 2020 10:47:47 +0000 (11:47 +0100)
committerChocobozzz <me@florianbigard.com>
Mon, 17 Feb 2020 10:47:47 +0000 (11:47 +0100)
client/src/app/shared/video-playlist/video-playlist.service.ts

index bae6f9e04f24c93f56ebc3eef5eae956962f7c29..38d915c6b626e23a34ce635d74e9e25c72a44966 100644 (file)
@@ -141,6 +141,8 @@ export class VideoPlaylistService {
     return this.authHttp.post<{ videoPlaylist: { id: number } }>(VideoPlaylistService.BASE_VIDEO_PLAYLIST_URL, data)
                .pipe(
                  tap(res => {
+                   if (!this.myAccountPlaylistCache) return
+
                    this.myAccountPlaylistCache.total++
 
                    this.myAccountPlaylistCache.data.push({
@@ -161,6 +163,8 @@ export class VideoPlaylistService {
                .pipe(
                  map(this.restExtractor.extractDataBool),
                  tap(() => {
+                   if (!this.myAccountPlaylistCache) return
+
                    const playlist = this.myAccountPlaylistCache.data.find(p => p.id === videoPlaylist.id)
                    playlist.displayName = body.displayName
 
@@ -175,6 +179,8 @@ export class VideoPlaylistService {
                .pipe(
                  map(this.restExtractor.extractDataBool),
                  tap(() => {
+                   if (!this.myAccountPlaylistCache) return
+
                    this.myAccountPlaylistCache.total--
                    this.myAccountPlaylistCache.data = this.myAccountPlaylistCache.data
                                                           .filter(p => p.id !== videoPlaylist.id)