aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-01-09 09:26:59 +0100
committerChocobozzz <me@florianbigard.com>2020-01-09 09:27:21 +0100
commit6b0c3c7ca917ad09a011c2821f5bd1a2485aebca (patch)
treea660791ddc78c95fe69469bd7c33e0e719fba871 /client/src/app/shared
parent119b16e5acffff1901f23c7a0188c78272453e7d (diff)
downloadPeerTube-6b0c3c7ca917ad09a011c2821f5bd1a2485aebca.tar.gz
PeerTube-6b0c3c7ca917ad09a011c2821f5bd1a2485aebca.tar.zst
PeerTube-6b0c3c7ca917ad09a011c2821f5bd1a2485aebca.zip
Optimize list my playlists SQL query
Diffstat (limited to 'client/src/app/shared')
-rw-r--r--client/src/app/shared/video-playlist/video-playlist.service.ts13
1 files changed, 11 insertions, 2 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 1ec9315ef..078bcc5d7 100644
--- a/client/src/app/shared/video-playlist/video-playlist.service.ts
+++ b/client/src/app/shared/video-playlist/video-playlist.service.ts
@@ -42,6 +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 myAccountPlaylistCacheSubject = new Subject<ResultList<CachedPlaylist>>() 46 private myAccountPlaylistCacheSubject = new Subject<ResultList<CachedPlaylist>>()
46 47
47 constructor ( 48 constructor (
@@ -78,12 +79,20 @@ export class VideoPlaylistService {
78 } 79 }
79 80
80 listMyPlaylistWithCache (user: AuthUser, search?: string) { 81 listMyPlaylistWithCache (user: AuthUser, search?: string) {
81 if (!search && this.myAccountPlaylistCache) return of(this.myAccountPlaylistCache) 82 if (!search) {
83 if (this.myAccountPlaylistCacheRunning) return
84 if (this.myAccountPlaylistCache) return of(this.myAccountPlaylistCache)
85 }
86
87 this.myAccountPlaylistCacheRunning = true
82 88
83 return this.listAccountPlaylists(user.account, undefined, '-updatedAt', search) 89 return this.listAccountPlaylists(user.account, undefined, '-updatedAt', search)
84 .pipe( 90 .pipe(
85 tap(result => { 91 tap(result => {
86 if (!search) this.myAccountPlaylistCache = result 92 if (!search) {
93 this.myAccountPlaylistCacheRunning = false
94 this.myAccountPlaylistCache = result
95 }
87 }) 96 })
88 ) 97 )
89 } 98 }