diff options
author | Chocobozzz <me@florianbigard.com> | 2018-05-16 10:20:56 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-05-16 10:51:01 +0200 |
commit | 5f73f5da1df684c4bf4cb2d680d9601090e5bca2 (patch) | |
tree | c71d6f8b86f440ba322cb02a575a5b663ae94c63 /client | |
parent | ac235c37e2d7112efbc182e0179cb27e75ef09a1 (diff) | |
download | PeerTube-5f73f5da1df684c4bf4cb2d680d9601090e5bca2.tar.gz PeerTube-5f73f5da1df684c4bf4cb2d680d9601090e5bca2.tar.zst PeerTube-5f73f5da1df684c4bf4cb2d680d9601090e5bca2.zip |
Fix concurrent requests in videos list
Diffstat (limited to 'client')
-rw-r--r-- | client/src/app/shared/video/abstract-video-list.ts | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/client/src/app/shared/video/abstract-video-list.ts b/client/src/app/shared/video/abstract-video-list.ts index d47df4da4..100cbff8d 100644 --- a/client/src/app/shared/video/abstract-video-list.ts +++ b/client/src/app/shared/video/abstract-video-list.ts | |||
@@ -45,6 +45,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy { | |||
45 | abstract titlePage: string | 45 | abstract titlePage: string |
46 | 46 | ||
47 | protected loadedPages: { [ id: number ]: Video[] } = {} | 47 | protected loadedPages: { [ id: number ]: Video[] } = {} |
48 | protected loadingPage: { [ id: number ]: boolean } = {} | ||
48 | protected otherRouteParams = {} | 49 | protected otherRouteParams = {} |
49 | 50 | ||
50 | private resizeSubscription: Subscription | 51 | private resizeSubscription: Subscription |
@@ -95,11 +96,15 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy { | |||
95 | 96 | ||
96 | loadMoreVideos (page: number) { | 97 | loadMoreVideos (page: number) { |
97 | if (this.loadedPages[page] !== undefined) return | 98 | if (this.loadedPages[page] !== undefined) return |
99 | if (this.loadingPage[page] === true) return | ||
98 | 100 | ||
101 | this.loadingPage[page] = true | ||
99 | const observable = this.getVideosObservable(page) | 102 | const observable = this.getVideosObservable(page) |
100 | 103 | ||
101 | observable.subscribe( | 104 | observable.subscribe( |
102 | ({ videos, totalVideos }) => { | 105 | ({ videos, totalVideos }) => { |
106 | this.loadingPage[page] = false | ||
107 | |||
103 | // Paging is too high, return to the first one | 108 | // Paging is too high, return to the first one |
104 | if (this.pagination.currentPage > 1 && totalVideos <= ((this.pagination.currentPage - 1) * this.pagination.itemsPerPage)) { | 109 | if (this.pagination.currentPage > 1 && totalVideos <= ((this.pagination.currentPage - 1) * this.pagination.itemsPerPage)) { |
105 | this.pagination.currentPage = 1 | 110 | this.pagination.currentPage = 1 |
@@ -117,7 +122,10 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy { | |||
117 | setTimeout(() => this.infiniteScroller.initialize(), 500) | 122 | setTimeout(() => this.infiniteScroller.initialize(), 500) |
118 | } | 123 | } |
119 | }, | 124 | }, |
120 | error => this.notificationsService.error('Error', error.message) | 125 | error => { |
126 | this.loadingPage[page] = false | ||
127 | this.notificationsService.error('Error', error.message) | ||
128 | } | ||
121 | ) | 129 | ) |
122 | } | 130 | } |
123 | 131 | ||