aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared')
-rw-r--r--client/src/app/shared/video/abstract-video-list.ts10
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