aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-01-09 14:06:29 +0100
committerChocobozzz <me@florianbigard.com>2020-01-09 14:06:29 +0100
commitf44a284a3e863cac144d1675208a38422ac0fc8c (patch)
tree8fa9ac9c95a58fe3cdeaeb08cd5c42ffc02d3189 /client/src/app
parentc4a1811ea888fa98fe7cd6932d82b3d63d366f28 (diff)
downloadPeerTube-f44a284a3e863cac144d1675208a38422ac0fc8c.tar.gz
PeerTube-f44a284a3e863cac144d1675208a38422ac0fc8c.tar.zst
PeerTube-f44a284a3e863cac144d1675208a38422ac0fc8c.zip
Fix playlist observable cache
Diffstat (limited to 'client/src/app')
-rw-r--r--client/src/app/shared/video-playlist/video-playlist.service.ts16
1 files changed, 9 insertions, 7 deletions
diff --git a/client/src/app/shared/video-playlist/video-playlist.service.ts b/client/src/app/shared/video-playlist/video-playlist.service.ts
index 078bcc5d7..fc5eb5337 100644
--- a/client/src/app/shared/video-playlist/video-playlist.service.ts
+++ b/client/src/app/shared/video-playlist/video-playlist.service.ts
@@ -42,7 +42,7 @@ export class VideoPlaylistService {
42 private videoExistsCache: { [ id: number ]: VideoExistInPlaylist[] } = {} 42 private videoExistsCache: { [ id: number ]: VideoExistInPlaylist[] } = {}
43 43
44 private myAccountPlaylistCache: ResultList<CachedPlaylist> = undefined 44 private myAccountPlaylistCache: ResultList<CachedPlaylist> = undefined
45 private myAccountPlaylistCacheRunning = false 45 private myAccountPlaylistCacheRunning: Observable<ResultList<CachedPlaylist>>
46 private myAccountPlaylistCacheSubject = new Subject<ResultList<CachedPlaylist>>() 46 private myAccountPlaylistCacheSubject = new Subject<ResultList<CachedPlaylist>>()
47 47
48 constructor ( 48 constructor (
@@ -80,21 +80,23 @@ export class VideoPlaylistService {
80 80
81 listMyPlaylistWithCache (user: AuthUser, search?: string) { 81 listMyPlaylistWithCache (user: AuthUser, search?: string) {
82 if (!search) { 82 if (!search) {
83 if (this.myAccountPlaylistCacheRunning) return 83 if (this.myAccountPlaylistCacheRunning) return this.myAccountPlaylistCacheRunning
84 if (this.myAccountPlaylistCache) return of(this.myAccountPlaylistCache) 84 if (this.myAccountPlaylistCache) return of(this.myAccountPlaylistCache)
85 } 85 }
86 86
87 this.myAccountPlaylistCacheRunning = true 87 const obs = this.listAccountPlaylists(user.account, undefined, '-updatedAt', search)
88
89 return this.listAccountPlaylists(user.account, undefined, '-updatedAt', search)
90 .pipe( 88 .pipe(
91 tap(result => { 89 tap(result => {
92 if (!search) { 90 if (!search) {
93 this.myAccountPlaylistCacheRunning = false 91 this.myAccountPlaylistCacheRunning = undefined
94 this.myAccountPlaylistCache = result 92 this.myAccountPlaylistCache = result
95 } 93 }
96 }) 94 }),
95 share()
97 ) 96 )
97
98 if (!search) this.myAccountPlaylistCacheRunning = obs
99 return obs
98 } 100 }
99 101
100 listAccountPlaylists ( 102 listAccountPlaylists (