diff options
author | Chocobozzz <me@florianbigard.com> | 2020-01-08 14:40:08 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-01-08 14:40:08 +0100 |
commit | 440d39c52d4efb878b6a2e21584d6b8f52072f27 (patch) | |
tree | 19ffd2dd545e125daf89c230e33d15f7827d10f7 /client | |
parent | fe98765624cdd6695739bda719fcb726b71c2b2a (diff) | |
download | PeerTube-440d39c52d4efb878b6a2e21584d6b8f52072f27.tar.gz PeerTube-440d39c52d4efb878b6a2e21584d6b8f52072f27.tar.zst PeerTube-440d39c52d4efb878b6a2e21584d6b8f52072f27.zip |
Skip videos count on client if we don't use it
Diffstat (limited to 'client')
20 files changed, 75 insertions, 60 deletions
diff --git a/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts b/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts index 29d2991fd..5572064c1 100644 --- a/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts +++ b/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts | |||
@@ -25,12 +25,14 @@ export class AccountVideoChannelsComponent implements OnInit, OnDestroy { | |||
25 | 25 | ||
26 | channelPagination: ComponentPagination = { | 26 | channelPagination: ComponentPagination = { |
27 | currentPage: 1, | 27 | currentPage: 1, |
28 | itemsPerPage: 2 | 28 | itemsPerPage: 2, |
29 | totalItems: null | ||
29 | } | 30 | } |
30 | 31 | ||
31 | videosPagination: ComponentPagination = { | 32 | videosPagination: ComponentPagination = { |
32 | currentPage: 1, | 33 | currentPage: 1, |
33 | itemsPerPage: 12 | 34 | itemsPerPage: 12, |
35 | totalItems: null | ||
34 | } | 36 | } |
35 | videosSort: VideoSortField = '-publishedAt' | 37 | videosSort: VideoSortField = '-publishedAt' |
36 | 38 | ||
diff --git a/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts b/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts index b30b136bd..f18c2e6ca 100644 --- a/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts +++ b/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts | |||
@@ -25,7 +25,8 @@ export class PluginListInstalledComponent implements OnInit { | |||
25 | 25 | ||
26 | pagination: ComponentPagination = { | 26 | pagination: ComponentPagination = { |
27 | currentPage: 1, | 27 | currentPage: 1, |
28 | itemsPerPage: 10 | 28 | itemsPerPage: 10, |
29 | totalItems: null | ||
29 | } | 30 | } |
30 | sort = 'name' | 31 | sort = 'name' |
31 | 32 | ||
diff --git a/client/src/app/+admin/plugins/plugin-search/plugin-search.component.ts b/client/src/app/+admin/plugins/plugin-search/plugin-search.component.ts index 65566ab79..e08ded3f1 100644 --- a/client/src/app/+admin/plugins/plugin-search/plugin-search.component.ts +++ b/client/src/app/+admin/plugins/plugin-search/plugin-search.component.ts | |||
@@ -25,7 +25,8 @@ export class PluginSearchComponent implements OnInit { | |||
25 | 25 | ||
26 | pagination: ComponentPagination = { | 26 | pagination: ComponentPagination = { |
27 | currentPage: 1, | 27 | currentPage: 1, |
28 | itemsPerPage: 10 | 28 | itemsPerPage: 10, |
29 | totalItems: null | ||
29 | } | 30 | } |
30 | sort = '-popularity' | 31 | sort = '-popularity' |
31 | 32 | ||
diff --git a/client/src/app/search/search.service.ts b/client/src/app/search/search.service.ts index bb5532757..7610fee8c 100644 --- a/client/src/app/search/search.service.ts +++ b/client/src/app/search/search.service.ts | |||
@@ -2,7 +2,7 @@ import { catchError, map, switchMap } from 'rxjs/operators' | |||
2 | import { HttpClient, HttpParams } from '@angular/common/http' | 2 | import { HttpClient, HttpParams } from '@angular/common/http' |
3 | import { Injectable } from '@angular/core' | 3 | import { Injectable } from '@angular/core' |
4 | import { Observable } from 'rxjs' | 4 | import { Observable } from 'rxjs' |
5 | import { ComponentPagination } from '@app/shared/rest/component-pagination.model' | 5 | import { ComponentPaginationLight } from '@app/shared/rest/component-pagination.model' |
6 | import { VideoService } from '@app/shared/video/video.service' | 6 | import { VideoService } from '@app/shared/video/video.service' |
7 | import { RestExtractor, RestService } from '@app/shared' | 7 | import { RestExtractor, RestService } from '@app/shared' |
8 | import { environment } from '../../environments/environment' | 8 | import { environment } from '../../environments/environment' |
@@ -25,7 +25,7 @@ export class SearchService { | |||
25 | 25 | ||
26 | searchVideos (parameters: { | 26 | searchVideos (parameters: { |
27 | search: string, | 27 | search: string, |
28 | componentPagination: ComponentPagination, | 28 | componentPagination: ComponentPaginationLight, |
29 | advancedSearch: AdvancedSearch | 29 | advancedSearch: AdvancedSearch |
30 | }): Observable<ResultList<Video>> { | 30 | }): Observable<ResultList<Video>> { |
31 | const { search, componentPagination, advancedSearch } = parameters | 31 | const { search, componentPagination, advancedSearch } = parameters |
@@ -51,7 +51,7 @@ export class SearchService { | |||
51 | 51 | ||
52 | searchVideoChannels (parameters: { | 52 | searchVideoChannels (parameters: { |
53 | search: string, | 53 | search: string, |
54 | componentPagination: ComponentPagination | 54 | componentPagination: ComponentPaginationLight |
55 | }): Observable<ResultList<VideoChannel>> { | 55 | }): Observable<ResultList<VideoChannel>> { |
56 | const { search, componentPagination } = parameters | 56 | const { search, componentPagination } = parameters |
57 | 57 | ||
diff --git a/client/src/app/shared/rest/component-pagination.model.ts b/client/src/app/shared/rest/component-pagination.model.ts index 85160d445..bcb73ed0f 100644 --- a/client/src/app/shared/rest/component-pagination.model.ts +++ b/client/src/app/shared/rest/component-pagination.model.ts | |||
@@ -1,9 +1,11 @@ | |||
1 | export interface ComponentPagination { | 1 | export interface ComponentPagination { |
2 | currentPage: number | 2 | currentPage: number |
3 | itemsPerPage: number | 3 | itemsPerPage: number |
4 | totalItems?: number | 4 | totalItems: number |
5 | } | 5 | } |
6 | 6 | ||
7 | export type ComponentPaginationLight = Omit<ComponentPagination, 'totalItems'> | ||
8 | |||
7 | export function hasMoreItems (componentPagination: ComponentPagination) { | 9 | export function hasMoreItems (componentPagination: ComponentPagination) { |
8 | // No results | 10 | // No results |
9 | if (componentPagination.totalItems === 0) return false | 11 | if (componentPagination.totalItems === 0) return false |
diff --git a/client/src/app/shared/rest/rest.service.ts b/client/src/app/shared/rest/rest.service.ts index e6d4e6e5e..16bb6d82c 100644 --- a/client/src/app/shared/rest/rest.service.ts +++ b/client/src/app/shared/rest/rest.service.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { Injectable } from '@angular/core' | 1 | import { Injectable } from '@angular/core' |
2 | import { HttpParams } from '@angular/common/http' | 2 | import { HttpParams } from '@angular/common/http' |
3 | import { SortMeta } from 'primeng/components/common/sortmeta' | 3 | import { SortMeta } from 'primeng/components/common/sortmeta' |
4 | import { ComponentPagination } from './component-pagination.model' | 4 | import { ComponentPagination, ComponentPaginationLight } from './component-pagination.model' |
5 | 5 | ||
6 | import { RestPagination } from './rest-pagination' | 6 | import { RestPagination } from './rest-pagination' |
7 | 7 | ||
@@ -47,7 +47,7 @@ export class RestService { | |||
47 | return params | 47 | return params |
48 | } | 48 | } |
49 | 49 | ||
50 | componentPaginationToRestPagination (componentPagination: ComponentPagination): RestPagination { | 50 | componentPaginationToRestPagination (componentPagination: ComponentPaginationLight): RestPagination { |
51 | const start: number = (componentPagination.currentPage - 1) * componentPagination.itemsPerPage | 51 | const start: number = (componentPagination.currentPage - 1) * componentPagination.itemsPerPage |
52 | const count: number = componentPagination.itemsPerPage | 52 | const count: number = componentPagination.itemsPerPage |
53 | 53 | ||
diff --git a/client/src/app/shared/user-subscription/user-subscription.service.ts b/client/src/app/shared/user-subscription/user-subscription.service.ts index cfd5b100f..83df40a43 100644 --- a/client/src/app/shared/user-subscription/user-subscription.service.ts +++ b/client/src/app/shared/user-subscription/user-subscription.service.ts | |||
@@ -8,7 +8,7 @@ import { Observable, ReplaySubject, Subject } from 'rxjs' | |||
8 | import { VideoChannel } from '@app/shared/video-channel/video-channel.model' | 8 | import { VideoChannel } from '@app/shared/video-channel/video-channel.model' |
9 | import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' | 9 | import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' |
10 | import { VideoChannel as VideoChannelServer } from '../../../../../shared/models/videos' | 10 | import { VideoChannel as VideoChannelServer } from '../../../../../shared/models/videos' |
11 | import { ComponentPagination } from '@app/shared/rest/component-pagination.model' | 11 | import { ComponentPaginationLight } from '@app/shared/rest/component-pagination.model' |
12 | 12 | ||
13 | type SubscriptionExistResult = { [ uri: string ]: boolean } | 13 | type SubscriptionExistResult = { [ uri: string ]: boolean } |
14 | 14 | ||
@@ -54,7 +54,7 @@ export class UserSubscriptionService { | |||
54 | ) | 54 | ) |
55 | } | 55 | } |
56 | 56 | ||
57 | listSubscriptions (componentPagination: ComponentPagination): Observable<ResultList<VideoChannel>> { | 57 | listSubscriptions (componentPagination: ComponentPaginationLight): Observable<ResultList<VideoChannel>> { |
58 | const url = UserSubscriptionService.BASE_USER_SUBSCRIPTIONS_URL | 58 | const url = UserSubscriptionService.BASE_USER_SUBSCRIPTIONS_URL |
59 | 59 | ||
60 | const pagination = this.restService.componentPaginationToRestPagination(componentPagination) | 60 | const pagination = this.restService.componentPaginationToRestPagination(componentPagination) |
diff --git a/client/src/app/shared/users/user-history.service.ts b/client/src/app/shared/users/user-history.service.ts index 9ed25bfc7..b358cdf20 100644 --- a/client/src/app/shared/users/user-history.service.ts +++ b/client/src/app/shared/users/user-history.service.ts | |||
@@ -5,7 +5,7 @@ import { RestExtractor } from '../rest/rest-extractor.service' | |||
5 | import { RestService } from '../rest/rest.service' | 5 | import { RestService } from '../rest/rest.service' |
6 | import { Video } from '../video/video.model' | 6 | import { Video } from '../video/video.model' |
7 | import { catchError, map, switchMap } from 'rxjs/operators' | 7 | import { catchError, map, switchMap } from 'rxjs/operators' |
8 | import { ComponentPagination } from '@app/shared/rest/component-pagination.model' | 8 | import { ComponentPaginationLight } from '@app/shared/rest/component-pagination.model' |
9 | import { VideoService } from '@app/shared/video/video.service' | 9 | import { VideoService } from '@app/shared/video/video.service' |
10 | import { ResultList } from '../../../../../shared' | 10 | import { ResultList } from '../../../../../shared' |
11 | 11 | ||
@@ -20,7 +20,7 @@ export class UserHistoryService { | |||
20 | private videoService: VideoService | 20 | private videoService: VideoService |
21 | ) {} | 21 | ) {} |
22 | 22 | ||
23 | getUserVideosHistory (historyPagination: ComponentPagination) { | 23 | getUserVideosHistory (historyPagination: ComponentPaginationLight) { |
24 | const pagination = this.restService.componentPaginationToRestPagination(historyPagination) | 24 | const pagination = this.restService.componentPaginationToRestPagination(historyPagination) |
25 | 25 | ||
26 | let params = new HttpParams() | 26 | let params = new HttpParams() |
diff --git a/client/src/app/shared/users/user-notification.service.ts b/client/src/app/shared/users/user-notification.service.ts index ae0bc9cb1..e525a1d58 100644 --- a/client/src/app/shared/users/user-notification.service.ts +++ b/client/src/app/shared/users/user-notification.service.ts | |||
@@ -6,7 +6,7 @@ import { environment } from '../../../environments/environment' | |||
6 | import { ResultList, UserNotification as UserNotificationServer, UserNotificationSetting } from '../../../../../shared' | 6 | import { ResultList, UserNotification as UserNotificationServer, UserNotificationSetting } from '../../../../../shared' |
7 | import { UserNotification } from './user-notification.model' | 7 | import { UserNotification } from './user-notification.model' |
8 | import { AuthService } from '../../core' | 8 | import { AuthService } from '../../core' |
9 | import { ComponentPagination } from '../rest/component-pagination.model' | 9 | import { ComponentPaginationLight } from '../rest/component-pagination.model' |
10 | import { User } from '../users/user.model' | 10 | import { User } from '../users/user.model' |
11 | import { UserNotificationSocket } from '@app/core/notification/user-notification-socket.service' | 11 | import { UserNotificationSocket } from '@app/core/notification/user-notification-socket.service' |
12 | 12 | ||
@@ -23,7 +23,7 @@ export class UserNotificationService { | |||
23 | private userNotificationSocket: UserNotificationSocket | 23 | private userNotificationSocket: UserNotificationSocket |
24 | ) {} | 24 | ) {} |
25 | 25 | ||
26 | listMyNotifications (pagination: ComponentPagination, unread?: boolean, ignoreLoadingBar = false) { | 26 | listMyNotifications (pagination: ComponentPaginationLight, unread?: boolean, ignoreLoadingBar = false) { |
27 | let params = new HttpParams() | 27 | let params = new HttpParams() |
28 | params = this.restService.addRestGetParams(params, this.restService.componentPaginationToRestPagination(pagination)) | 28 | params = this.restService.addRestGetParams(params, this.restService.componentPaginationToRestPagination(pagination)) |
29 | 29 | ||
diff --git a/client/src/app/shared/video-blacklist/video-blacklist.service.ts b/client/src/app/shared/video-blacklist/video-blacklist.service.ts index d65da85fe..491fa698b 100644 --- a/client/src/app/shared/video-blacklist/video-blacklist.service.ts +++ b/client/src/app/shared/video-blacklist/video-blacklist.service.ts | |||
@@ -7,7 +7,7 @@ import { VideoBlacklist, VideoBlacklistType, ResultList } from '../../../../../s | |||
7 | import { Video } from '../video/video.model' | 7 | import { Video } from '../video/video.model' |
8 | import { environment } from '../../../environments/environment' | 8 | import { environment } from '../../../environments/environment' |
9 | import { RestExtractor, RestPagination, RestService } from '../rest' | 9 | import { RestExtractor, RestPagination, RestService } from '../rest' |
10 | import { ComponentPagination } from '../rest/component-pagination.model' | 10 | import { ComponentPaginationLight } from '../rest/component-pagination.model' |
11 | 11 | ||
12 | @Injectable() | 12 | @Injectable() |
13 | export class VideoBlacklistService { | 13 | export class VideoBlacklistService { |
@@ -34,7 +34,7 @@ export class VideoBlacklistService { | |||
34 | ) | 34 | ) |
35 | } | 35 | } |
36 | 36 | ||
37 | getAutoBlacklistedAsVideoList (videoPagination: ComponentPagination): Observable<ResultList<Video>> { | 37 | getAutoBlacklistedAsVideoList (videoPagination: ComponentPaginationLight): Observable<ResultList<Video>> { |
38 | const pagination = this.restService.componentPaginationToRestPagination(videoPagination) | 38 | const pagination = this.restService.componentPaginationToRestPagination(videoPagination) |
39 | 39 | ||
40 | // prioritize first created since waiting longest | 40 | // prioritize first created since waiting longest |
diff --git a/client/src/app/shared/video-channel/video-channel.service.ts b/client/src/app/shared/video-channel/video-channel.service.ts index 0168d37d9..adb4f4819 100644 --- a/client/src/app/shared/video-channel/video-channel.service.ts +++ b/client/src/app/shared/video-channel/video-channel.service.ts | |||
@@ -10,7 +10,7 @@ import { VideoChannel } from './video-channel.model' | |||
10 | import { environment } from '../../../environments/environment' | 10 | import { environment } from '../../../environments/environment' |
11 | import { Account } from '@app/shared/account/account.model' | 11 | import { Account } from '@app/shared/account/account.model' |
12 | import { Avatar } from '../../../../../shared/models/avatars/avatar.model' | 12 | import { Avatar } from '../../../../../shared/models/avatars/avatar.model' |
13 | import { ComponentPagination } from '@app/shared/rest/component-pagination.model' | 13 | import { ComponentPaginationLight } from '@app/shared/rest/component-pagination.model' |
14 | import { RestService } from '@app/shared/rest' | 14 | import { RestService } from '@app/shared/rest' |
15 | 15 | ||
16 | @Injectable() | 16 | @Injectable() |
@@ -44,7 +44,7 @@ export class VideoChannelService { | |||
44 | ) | 44 | ) |
45 | } | 45 | } |
46 | 46 | ||
47 | listAccountVideoChannels (account: Account, componentPagination?: ComponentPagination): Observable<ResultList<VideoChannel>> { | 47 | listAccountVideoChannels (account: Account, componentPagination?: ComponentPaginationLight): Observable<ResultList<VideoChannel>> { |
48 | const pagination = componentPagination | 48 | const pagination = componentPagination |
49 | ? this.restService.componentPaginationToRestPagination(componentPagination) | 49 | ? this.restService.componentPaginationToRestPagination(componentPagination) |
50 | : { start: 0, count: 20 } | 50 | : { start: 0, count: 20 } |
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 7eddf81e1..1ec9315ef 100644 --- a/client/src/app/shared/video-playlist/video-playlist.service.ts +++ b/client/src/app/shared/video-playlist/video-playlist.service.ts | |||
@@ -18,7 +18,7 @@ import { Account } from '@app/shared/account/account.model' | |||
18 | import { RestService } from '@app/shared/rest' | 18 | import { RestService } from '@app/shared/rest' |
19 | import { VideoExistInPlaylist, VideosExistInPlaylists } from '@shared/models/videos/playlist/video-exist-in-playlist.model' | 19 | import { VideoExistInPlaylist, VideosExistInPlaylists } from '@shared/models/videos/playlist/video-exist-in-playlist.model' |
20 | import { VideoPlaylistReorder } from '@shared/models/videos/playlist/video-playlist-reorder.model' | 20 | import { VideoPlaylistReorder } from '@shared/models/videos/playlist/video-playlist-reorder.model' |
21 | import { ComponentPagination } from '@app/shared/rest/component-pagination.model' | 21 | import { ComponentPaginationLight } from '@app/shared/rest/component-pagination.model' |
22 | import { VideoPlaylistElement as ServerVideoPlaylistElement } from '@shared/models/videos/playlist/video-playlist-element.model' | 22 | import { VideoPlaylistElement as ServerVideoPlaylistElement } from '@shared/models/videos/playlist/video-playlist-element.model' |
23 | import { VideoPlaylistElement } from '@app/shared/video-playlist/video-playlist-element.model' | 23 | import { VideoPlaylistElement } from '@app/shared/video-playlist/video-playlist-element.model' |
24 | import { uniq } from 'lodash-es' | 24 | import { uniq } from 'lodash-es' |
@@ -63,7 +63,7 @@ export class VideoPlaylistService { | |||
63 | ) | 63 | ) |
64 | } | 64 | } |
65 | 65 | ||
66 | listChannelPlaylists (videoChannel: VideoChannel, componentPagination: ComponentPagination): Observable<ResultList<VideoPlaylist>> { | 66 | listChannelPlaylists (videoChannel: VideoChannel, componentPagination: ComponentPaginationLight): Observable<ResultList<VideoPlaylist>> { |
67 | const url = VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannel.nameWithHost + '/video-playlists' | 67 | const url = VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannel.nameWithHost + '/video-playlists' |
68 | const pagination = this.restService.componentPaginationToRestPagination(componentPagination) | 68 | const pagination = this.restService.componentPaginationToRestPagination(componentPagination) |
69 | 69 | ||
@@ -90,7 +90,7 @@ export class VideoPlaylistService { | |||
90 | 90 | ||
91 | listAccountPlaylists ( | 91 | listAccountPlaylists ( |
92 | account: Account, | 92 | account: Account, |
93 | componentPagination: ComponentPagination, | 93 | componentPagination: ComponentPaginationLight, |
94 | sort: string, | 94 | sort: string, |
95 | search?: string | 95 | search?: string |
96 | ): Observable<ResultList<VideoPlaylist>> { | 96 | ): Observable<ResultList<VideoPlaylist>> { |
@@ -236,7 +236,7 @@ export class VideoPlaylistService { | |||
236 | 236 | ||
237 | getPlaylistVideos ( | 237 | getPlaylistVideos ( |
238 | videoPlaylistId: number | string, | 238 | videoPlaylistId: number | string, |
239 | componentPagination: ComponentPagination | 239 | componentPagination: ComponentPaginationLight |
240 | ): Observable<ResultList<VideoPlaylistElement>> { | 240 | ): Observable<ResultList<VideoPlaylistElement>> { |
241 | const path = VideoPlaylistService.BASE_VIDEO_PLAYLIST_URL + videoPlaylistId + '/videos' | 241 | const path = VideoPlaylistService.BASE_VIDEO_PLAYLIST_URL + videoPlaylistId + '/videos' |
242 | const pagination = this.restService.componentPaginationToRestPagination(componentPagination) | 242 | const pagination = this.restService.componentPaginationToRestPagination(componentPagination) |
diff --git a/client/src/app/shared/video/abstract-video-list.ts b/client/src/app/shared/video/abstract-video-list.ts index 06d4ed43d..c2fe6f754 100644 --- a/client/src/app/shared/video/abstract-video-list.ts +++ b/client/src/app/shared/video/abstract-video-list.ts | |||
@@ -3,7 +3,7 @@ import { OnDestroy, OnInit } from '@angular/core' | |||
3 | import { ActivatedRoute, Router } from '@angular/router' | 3 | import { ActivatedRoute, Router } from '@angular/router' |
4 | import { fromEvent, Observable, of, Subject, Subscription } from 'rxjs' | 4 | import { fromEvent, Observable, of, Subject, Subscription } from 'rxjs' |
5 | import { AuthService } from '../../core/auth' | 5 | import { AuthService } from '../../core/auth' |
6 | import { ComponentPagination } from '../rest/component-pagination.model' | 6 | import { ComponentPaginationLight } from '../rest/component-pagination.model' |
7 | import { VideoSortField } from './sort-field.type' | 7 | import { VideoSortField } from './sort-field.type' |
8 | import { Video } from './video.model' | 8 | import { Video } from './video.model' |
9 | import { ScreenService } from '@app/shared/misc/screen.service' | 9 | import { ScreenService } from '@app/shared/misc/screen.service' |
@@ -13,7 +13,7 @@ import { Notifier, ServerService } from '@app/core' | |||
13 | import { DisableForReuseHook } from '@app/core/routing/disable-for-reuse-hook' | 13 | import { DisableForReuseHook } from '@app/core/routing/disable-for-reuse-hook' |
14 | import { I18n } from '@ngx-translate/i18n-polyfill' | 14 | import { I18n } from '@ngx-translate/i18n-polyfill' |
15 | import { isLastMonth, isLastWeek, isToday, isYesterday } from '@shared/core-utils/miscs/date' | 15 | import { isLastMonth, isLastWeek, isToday, isYesterday } from '@shared/core-utils/miscs/date' |
16 | import { ResultList, ServerConfig } from '@shared/models' | 16 | import { ServerConfig } from '@shared/models' |
17 | 17 | ||
18 | enum GroupDate { | 18 | enum GroupDate { |
19 | UNKNOWN = 0, | 19 | UNKNOWN = 0, |
@@ -25,10 +25,9 @@ enum GroupDate { | |||
25 | } | 25 | } |
26 | 26 | ||
27 | export abstract class AbstractVideoList implements OnInit, OnDestroy, DisableForReuseHook { | 27 | export abstract class AbstractVideoList implements OnInit, OnDestroy, DisableForReuseHook { |
28 | pagination: ComponentPagination = { | 28 | pagination: ComponentPaginationLight = { |
29 | currentPage: 1, | 29 | currentPage: 1, |
30 | itemsPerPage: 25, | 30 | itemsPerPage: 25 |
31 | totalItems: null | ||
32 | } | 31 | } |
33 | sort: VideoSortField = '-publishedAt' | 32 | sort: VideoSortField = '-publishedAt' |
34 | 33 | ||
@@ -47,6 +46,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, DisableFor | |||
47 | groupByDate = false | 46 | groupByDate = false |
48 | 47 | ||
49 | videos: Video[] = [] | 48 | videos: Video[] = [] |
49 | hasDoneFirstQuery = false | ||
50 | disabled = false | 50 | disabled = false |
51 | 51 | ||
52 | displayOptions: MiniatureDisplayOptions = { | 52 | displayOptions: MiniatureDisplayOptions = { |
@@ -84,7 +84,9 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, DisableFor | |||
84 | private groupedDateLabels: { [id in GroupDate]: string } | 84 | private groupedDateLabels: { [id in GroupDate]: string } |
85 | private groupedDates: { [id: number]: GroupDate } = {} | 85 | private groupedDates: { [id: number]: GroupDate } = {} |
86 | 86 | ||
87 | abstract getVideosObservable (page: number): Observable<ResultList<Video>> | 87 | private lastQueryLength: number |
88 | |||
89 | abstract getVideosObservable (page: number): Observable<{ data: Video[] }> | ||
88 | 90 | ||
89 | abstract generateSyndicationList (): void | 91 | abstract generateSyndicationList (): void |
90 | 92 | ||
@@ -142,8 +144,8 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, DisableFor | |||
142 | onNearOfBottom () { | 144 | onNearOfBottom () { |
143 | if (this.disabled) return | 145 | if (this.disabled) return |
144 | 146 | ||
145 | // Last page | 147 | // No more results |
146 | if (this.pagination.totalItems <= (this.pagination.currentPage * this.pagination.itemsPerPage)) return | 148 | if (this.lastQueryLength !== undefined && this.lastQueryLength < this.pagination.itemsPerPage) return |
147 | 149 | ||
148 | this.pagination.currentPage += 1 | 150 | this.pagination.currentPage += 1 |
149 | 151 | ||
@@ -154,8 +156,10 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, DisableFor | |||
154 | 156 | ||
155 | loadMoreVideos (reset = false) { | 157 | loadMoreVideos (reset = false) { |
156 | this.getVideosObservable(this.pagination.currentPage).subscribe( | 158 | this.getVideosObservable(this.pagination.currentPage).subscribe( |
157 | ({ data, total }) => { | 159 | ({ data }) => { |
158 | this.pagination.totalItems = total | 160 | this.hasDoneFirstQuery = true |
161 | this.lastQueryLength = data.length | ||
162 | |||
159 | if (reset) this.videos = [] | 163 | if (reset) this.videos = [] |
160 | this.videos = this.videos.concat(data) | 164 | this.videos = this.videos.concat(data) |
161 | 165 | ||
diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts index 2dd47d74e..996202154 100644 --- a/client/src/app/shared/video/video.service.ts +++ b/client/src/app/shared/video/video.service.ts | |||
@@ -15,7 +15,7 @@ import { | |||
15 | } from '../../../../../shared/models/videos' | 15 | } from '../../../../../shared/models/videos' |
16 | import { FeedFormat } from '../../../../../shared/models/feeds/feed-format.enum' | 16 | import { FeedFormat } from '../../../../../shared/models/feeds/feed-format.enum' |
17 | import { environment } from '../../../environments/environment' | 17 | import { environment } from '../../../environments/environment' |
18 | import { ComponentPagination } from '../rest/component-pagination.model' | 18 | import { ComponentPaginationLight } from '../rest/component-pagination.model' |
19 | import { RestExtractor } from '../rest/rest-extractor.service' | 19 | import { RestExtractor } from '../rest/rest-extractor.service' |
20 | import { RestService } from '../rest/rest.service' | 20 | import { RestService } from '../rest/rest.service' |
21 | import { UserService } from '../users/user.service' | 21 | import { UserService } from '../users/user.service' |
@@ -34,7 +34,7 @@ import { I18n } from '@ngx-translate/i18n-polyfill' | |||
34 | 34 | ||
35 | export interface VideosProvider { | 35 | export interface VideosProvider { |
36 | getVideos (parameters: { | 36 | getVideos (parameters: { |
37 | videoPagination: ComponentPagination, | 37 | videoPagination: ComponentPaginationLight, |
38 | sort: VideoSortField, | 38 | sort: VideoSortField, |
39 | filter?: VideoFilter, | 39 | filter?: VideoFilter, |
40 | categoryOneOf?: number, | 40 | categoryOneOf?: number, |
@@ -121,7 +121,7 @@ export class VideoService implements VideosProvider { | |||
121 | .pipe(catchError(err => this.restExtractor.handleError(err))) | 121 | .pipe(catchError(err => this.restExtractor.handleError(err))) |
122 | } | 122 | } |
123 | 123 | ||
124 | getMyVideos (videoPagination: ComponentPagination, sort: VideoSortField, search?: string): Observable<ResultList<Video>> { | 124 | getMyVideos (videoPagination: ComponentPaginationLight, sort: VideoSortField, search?: string): Observable<ResultList<Video>> { |
125 | const pagination = this.restService.componentPaginationToRestPagination(videoPagination) | 125 | const pagination = this.restService.componentPaginationToRestPagination(videoPagination) |
126 | 126 | ||
127 | let params = new HttpParams() | 127 | let params = new HttpParams() |
@@ -138,7 +138,7 @@ export class VideoService implements VideosProvider { | |||
138 | 138 | ||
139 | getAccountVideos ( | 139 | getAccountVideos ( |
140 | account: Account, | 140 | account: Account, |
141 | videoPagination: ComponentPagination, | 141 | videoPagination: ComponentPaginationLight, |
142 | sort: VideoSortField | 142 | sort: VideoSortField |
143 | ): Observable<ResultList<Video>> { | 143 | ): Observable<ResultList<Video>> { |
144 | const pagination = this.restService.componentPaginationToRestPagination(videoPagination) | 144 | const pagination = this.restService.componentPaginationToRestPagination(videoPagination) |
@@ -156,7 +156,7 @@ export class VideoService implements VideosProvider { | |||
156 | 156 | ||
157 | getVideoChannelVideos ( | 157 | getVideoChannelVideos ( |
158 | videoChannel: VideoChannel, | 158 | videoChannel: VideoChannel, |
159 | videoPagination: ComponentPagination, | 159 | videoPagination: ComponentPaginationLight, |
160 | sort: VideoSortField | 160 | sort: VideoSortField |
161 | ): Observable<ResultList<Video>> { | 161 | ): Observable<ResultList<Video>> { |
162 | const pagination = this.restService.componentPaginationToRestPagination(videoPagination) | 162 | const pagination = this.restService.componentPaginationToRestPagination(videoPagination) |
@@ -173,15 +173,18 @@ export class VideoService implements VideosProvider { | |||
173 | } | 173 | } |
174 | 174 | ||
175 | getUserSubscriptionVideos (parameters: { | 175 | getUserSubscriptionVideos (parameters: { |
176 | videoPagination: ComponentPagination, | 176 | videoPagination: ComponentPaginationLight, |
177 | sort: VideoSortField | 177 | sort: VideoSortField, |
178 | skipCount?: boolean | ||
178 | }): Observable<ResultList<Video>> { | 179 | }): Observable<ResultList<Video>> { |
179 | const { videoPagination, sort } = parameters | 180 | const { videoPagination, sort, skipCount } = parameters |
180 | const pagination = this.restService.componentPaginationToRestPagination(videoPagination) | 181 | const pagination = this.restService.componentPaginationToRestPagination(videoPagination) |
181 | 182 | ||
182 | let params = new HttpParams() | 183 | let params = new HttpParams() |
183 | params = this.restService.addRestGetParams(params, pagination, sort) | 184 | params = this.restService.addRestGetParams(params, pagination, sort) |
184 | 185 | ||
186 | if (skipCount) params = params.set('skipCount', skipCount + '') | ||
187 | |||
185 | return this.authHttp | 188 | return this.authHttp |
186 | .get<ResultList<Video>>(UserSubscriptionService.BASE_USER_SUBSCRIPTIONS_URL + '/videos', { params }) | 189 | .get<ResultList<Video>>(UserSubscriptionService.BASE_USER_SUBSCRIPTIONS_URL + '/videos', { params }) |
187 | .pipe( | 190 | .pipe( |
@@ -191,26 +194,23 @@ export class VideoService implements VideosProvider { | |||
191 | } | 194 | } |
192 | 195 | ||
193 | getVideos (parameters: { | 196 | getVideos (parameters: { |
194 | videoPagination: ComponentPagination, | 197 | videoPagination: ComponentPaginationLight, |
195 | sort: VideoSortField, | 198 | sort: VideoSortField, |
196 | filter?: VideoFilter, | 199 | filter?: VideoFilter, |
197 | categoryOneOf?: number, | 200 | categoryOneOf?: number, |
198 | languageOneOf?: string[] | 201 | languageOneOf?: string[], |
202 | skipCount?: boolean | ||
199 | }): Observable<ResultList<Video>> { | 203 | }): Observable<ResultList<Video>> { |
200 | const { videoPagination, sort, filter, categoryOneOf, languageOneOf } = parameters | 204 | const { videoPagination, sort, filter, categoryOneOf, languageOneOf, skipCount } = parameters |
201 | 205 | ||
202 | const pagination = this.restService.componentPaginationToRestPagination(videoPagination) | 206 | const pagination = this.restService.componentPaginationToRestPagination(videoPagination) |
203 | 207 | ||
204 | let params = new HttpParams() | 208 | let params = new HttpParams() |
205 | params = this.restService.addRestGetParams(params, pagination, sort) | 209 | params = this.restService.addRestGetParams(params, pagination, sort) |
206 | 210 | ||
207 | if (filter) { | 211 | if (filter) params = params.set('filter', filter) |
208 | params = params.set('filter', filter) | 212 | if (categoryOneOf) params = params.set('categoryOneOf', categoryOneOf + '') |
209 | } | 213 | if (skipCount) params = params.set('skipCount', skipCount + '') |
210 | |||
211 | if (categoryOneOf) { | ||
212 | params = params.set('categoryOneOf', categoryOneOf + '') | ||
213 | } | ||
214 | 214 | ||
215 | if (languageOneOf) { | 215 | if (languageOneOf) { |
216 | for (const l of languageOneOf) { | 216 | for (const l of languageOneOf) { |
diff --git a/client/src/app/videos/+video-watch/comment/video-comment.service.ts b/client/src/app/videos/+video-watch/comment/video-comment.service.ts index 72fbf5d25..a81e5236a 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment.service.ts +++ b/client/src/app/videos/+video-watch/comment/video-comment.service.ts | |||
@@ -3,7 +3,7 @@ import { HttpClient, HttpParams } from '@angular/common/http' | |||
3 | import { Injectable } from '@angular/core' | 3 | import { Injectable } from '@angular/core' |
4 | import { objectLineFeedToHtml } from '@app/shared/misc/utils' | 4 | import { objectLineFeedToHtml } from '@app/shared/misc/utils' |
5 | import { Observable } from 'rxjs' | 5 | import { Observable } from 'rxjs' |
6 | import { ResultList, FeedFormat } from '../../../../../../shared/models' | 6 | import { FeedFormat, ResultList } from '../../../../../../shared/models' |
7 | import { | 7 | import { |
8 | VideoComment as VideoCommentServerModel, | 8 | VideoComment as VideoCommentServerModel, |
9 | VideoCommentCreate, | 9 | VideoCommentCreate, |
@@ -11,7 +11,7 @@ import { | |||
11 | } from '../../../../../../shared/models/videos/video-comment.model' | 11 | } from '../../../../../../shared/models/videos/video-comment.model' |
12 | import { environment } from '../../../../environments/environment' | 12 | import { environment } from '../../../../environments/environment' |
13 | import { RestExtractor, RestService } from '../../../shared/rest' | 13 | import { RestExtractor, RestService } from '../../../shared/rest' |
14 | import { ComponentPagination } from '../../../shared/rest/component-pagination.model' | 14 | import { ComponentPaginationLight } from '../../../shared/rest/component-pagination.model' |
15 | import { CommentSortField } from '../../../shared/video/sort-field.type' | 15 | import { CommentSortField } from '../../../shared/video/sort-field.type' |
16 | import { VideoComment } from './video-comment.model' | 16 | import { VideoComment } from './video-comment.model' |
17 | 17 | ||
@@ -50,7 +50,7 @@ export class VideoCommentService { | |||
50 | 50 | ||
51 | getVideoCommentThreads (parameters: { | 51 | getVideoCommentThreads (parameters: { |
52 | videoId: number | string, | 52 | videoId: number | string, |
53 | componentPagination: ComponentPagination, | 53 | componentPagination: ComponentPaginationLight, |
54 | sort: CommentSortField | 54 | sort: CommentSortField |
55 | }): Observable<ResultList<VideoComment>> { | 55 | }): Observable<ResultList<VideoComment>> { |
56 | const { videoId, componentPagination, sort } = parameters | 56 | const { videoId, componentPagination, sort } = parameters |
diff --git a/client/src/app/videos/video-list/video-local.component.ts b/client/src/app/videos/video-list/video-local.component.ts index b96e46e6a..59f65f95c 100644 --- a/client/src/app/videos/video-list/video-local.component.ts +++ b/client/src/app/videos/video-list/video-local.component.ts | |||
@@ -62,7 +62,8 @@ export class VideoLocalComponent extends AbstractVideoList implements OnInit, On | |||
62 | sort: this.sort, | 62 | sort: this.sort, |
63 | filter: this.filter, | 63 | filter: this.filter, |
64 | categoryOneOf: this.categoryOneOf, | 64 | categoryOneOf: this.categoryOneOf, |
65 | languageOneOf: this.languageOneOf | 65 | languageOneOf: this.languageOneOf, |
66 | skipCount: true | ||
66 | } | 67 | } |
67 | 68 | ||
68 | return this.hooks.wrapObsFun( | 69 | return this.hooks.wrapObsFun( |
diff --git a/client/src/app/videos/video-list/video-most-liked.component.ts b/client/src/app/videos/video-list/video-most-liked.component.ts index f94a7da04..6ff7a1e0e 100644 --- a/client/src/app/videos/video-list/video-most-liked.component.ts +++ b/client/src/app/videos/video-list/video-most-liked.component.ts | |||
@@ -50,7 +50,8 @@ export class VideoMostLikedComponent extends AbstractVideoList implements OnInit | |||
50 | videoPagination: newPagination, | 50 | videoPagination: newPagination, |
51 | sort: this.sort, | 51 | sort: this.sort, |
52 | categoryOneOf: this.categoryOneOf, | 52 | categoryOneOf: this.categoryOneOf, |
53 | languageOneOf: this.languageOneOf | 53 | languageOneOf: this.languageOneOf, |
54 | skipCount: true | ||
54 | } | 55 | } |
55 | 56 | ||
56 | return this.hooks.wrapObsFun( | 57 | return this.hooks.wrapObsFun( |
diff --git a/client/src/app/videos/video-list/video-recently-added.component.ts b/client/src/app/videos/video-list/video-recently-added.component.ts index 5c50fd396..7568f4536 100644 --- a/client/src/app/videos/video-list/video-recently-added.component.ts +++ b/client/src/app/videos/video-list/video-recently-added.component.ts | |||
@@ -54,7 +54,8 @@ export class VideoRecentlyAddedComponent extends AbstractVideoList implements On | |||
54 | videoPagination: newPagination, | 54 | videoPagination: newPagination, |
55 | sort: this.sort, | 55 | sort: this.sort, |
56 | categoryOneOf: this.categoryOneOf, | 56 | categoryOneOf: this.categoryOneOf, |
57 | languageOneOf: this.languageOneOf | 57 | languageOneOf: this.languageOneOf, |
58 | skipCount: true | ||
58 | } | 59 | } |
59 | 60 | ||
60 | return this.hooks.wrapObsFun( | 61 | return this.hooks.wrapObsFun( |
diff --git a/client/src/app/videos/video-list/video-trending.component.ts b/client/src/app/videos/video-list/video-trending.component.ts index bc88679fa..e29830b5b 100644 --- a/client/src/app/videos/video-list/video-trending.component.ts +++ b/client/src/app/videos/video-list/video-trending.component.ts | |||
@@ -67,7 +67,8 @@ export class VideoTrendingComponent extends AbstractVideoList implements OnInit, | |||
67 | videoPagination: newPagination, | 67 | videoPagination: newPagination, |
68 | sort: this.sort, | 68 | sort: this.sort, |
69 | categoryOneOf: this.categoryOneOf, | 69 | categoryOneOf: this.categoryOneOf, |
70 | languageOneOf: this.languageOneOf | 70 | languageOneOf: this.languageOneOf, |
71 | skipCount: true | ||
71 | } | 72 | } |
72 | 73 | ||
73 | return this.hooks.wrapObsFun( | 74 | return this.hooks.wrapObsFun( |
diff --git a/client/src/app/videos/video-list/video-user-subscriptions.component.ts b/client/src/app/videos/video-list/video-user-subscriptions.component.ts index 0cd67db29..cf0b15054 100644 --- a/client/src/app/videos/video-list/video-user-subscriptions.component.ts +++ b/client/src/app/videos/video-list/video-user-subscriptions.component.ts | |||
@@ -55,7 +55,8 @@ export class VideoUserSubscriptionsComponent extends AbstractVideoList implement | |||
55 | const newPagination = immutableAssign(this.pagination, { currentPage: page }) | 55 | const newPagination = immutableAssign(this.pagination, { currentPage: page }) |
56 | const params = { | 56 | const params = { |
57 | videoPagination: newPagination, | 57 | videoPagination: newPagination, |
58 | sort: this.sort | 58 | sort: this.sort, |
59 | skipCount: true | ||
59 | } | 60 | } |
60 | 61 | ||
61 | return this.hooks.wrapObsFun( | 62 | return this.hooks.wrapObsFun( |