Fix playlist observable cache
This commit is contained in:
parent
c4a1811ea8
commit
f44a284a3e
|
@ -42,7 +42,7 @@ export class VideoPlaylistService {
|
||||||
private videoExistsCache: { [ id: number ]: VideoExistInPlaylist[] } = {}
|
private videoExistsCache: { [ id: number ]: VideoExistInPlaylist[] } = {}
|
||||||
|
|
||||||
private myAccountPlaylistCache: ResultList<CachedPlaylist> = undefined
|
private myAccountPlaylistCache: ResultList<CachedPlaylist> = undefined
|
||||||
private myAccountPlaylistCacheRunning = false
|
private myAccountPlaylistCacheRunning: Observable<ResultList<CachedPlaylist>>
|
||||||
private myAccountPlaylistCacheSubject = new Subject<ResultList<CachedPlaylist>>()
|
private myAccountPlaylistCacheSubject = new Subject<ResultList<CachedPlaylist>>()
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
|
@ -80,21 +80,23 @@ export class VideoPlaylistService {
|
||||||
|
|
||||||
listMyPlaylistWithCache (user: AuthUser, search?: string) {
|
listMyPlaylistWithCache (user: AuthUser, search?: string) {
|
||||||
if (!search) {
|
if (!search) {
|
||||||
if (this.myAccountPlaylistCacheRunning) return
|
if (this.myAccountPlaylistCacheRunning) return this.myAccountPlaylistCacheRunning
|
||||||
if (this.myAccountPlaylistCache) return of(this.myAccountPlaylistCache)
|
if (this.myAccountPlaylistCache) return of(this.myAccountPlaylistCache)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.myAccountPlaylistCacheRunning = true
|
const obs = this.listAccountPlaylists(user.account, undefined, '-updatedAt', search)
|
||||||
|
|
||||||
return this.listAccountPlaylists(user.account, undefined, '-updatedAt', search)
|
|
||||||
.pipe(
|
.pipe(
|
||||||
tap(result => {
|
tap(result => {
|
||||||
if (!search) {
|
if (!search) {
|
||||||
this.myAccountPlaylistCacheRunning = false
|
this.myAccountPlaylistCacheRunning = undefined
|
||||||
this.myAccountPlaylistCache = result
|
this.myAccountPlaylistCache = result
|
||||||
}
|
}
|
||||||
})
|
}),
|
||||||
|
share()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (!search) this.myAccountPlaylistCacheRunning = obs
|
||||||
|
return obs
|
||||||
}
|
}
|
||||||
|
|
||||||
listAccountPlaylists (
|
listAccountPlaylists (
|
||||||
|
|
Loading…
Reference in New Issue