channelPagination: ComponentPagination = {
currentPage: 1,
- itemsPerPage: 2
+ itemsPerPage: 2,
+ totalItems: null
}
videosPagination: ComponentPagination = {
currentPage: 1,
- itemsPerPage: 12
+ itemsPerPage: 12,
+ totalItems: null
}
videosSort: VideoSortField = '-publishedAt'
pagination: ComponentPagination = {
currentPage: 1,
- itemsPerPage: 10
+ itemsPerPage: 10,
+ totalItems: null
}
sort = 'name'
pagination: ComponentPagination = {
currentPage: 1,
- itemsPerPage: 10
+ itemsPerPage: 10,
+ totalItems: null
}
sort = '-popularity'
import { HttpClient, HttpParams } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { Observable } from 'rxjs'
-import { ComponentPagination } from '@app/shared/rest/component-pagination.model'
+import { ComponentPaginationLight } from '@app/shared/rest/component-pagination.model'
import { VideoService } from '@app/shared/video/video.service'
import { RestExtractor, RestService } from '@app/shared'
import { environment } from '../../environments/environment'
searchVideos (parameters: {
search: string,
- componentPagination: ComponentPagination,
+ componentPagination: ComponentPaginationLight,
advancedSearch: AdvancedSearch
}): Observable<ResultList<Video>> {
const { search, componentPagination, advancedSearch } = parameters
searchVideoChannels (parameters: {
search: string,
- componentPagination: ComponentPagination
+ componentPagination: ComponentPaginationLight
}): Observable<ResultList<VideoChannel>> {
const { search, componentPagination } = parameters
export interface ComponentPagination {
currentPage: number
itemsPerPage: number
- totalItems?: number
+ totalItems: number
}
+export type ComponentPaginationLight = Omit<ComponentPagination, 'totalItems'>
+
export function hasMoreItems (componentPagination: ComponentPagination) {
// No results
if (componentPagination.totalItems === 0) return false
import { Injectable } from '@angular/core'
import { HttpParams } from '@angular/common/http'
import { SortMeta } from 'primeng/components/common/sortmeta'
-import { ComponentPagination } from './component-pagination.model'
+import { ComponentPagination, ComponentPaginationLight } from './component-pagination.model'
import { RestPagination } from './rest-pagination'
return params
}
- componentPaginationToRestPagination (componentPagination: ComponentPagination): RestPagination {
+ componentPaginationToRestPagination (componentPagination: ComponentPaginationLight): RestPagination {
const start: number = (componentPagination.currentPage - 1) * componentPagination.itemsPerPage
const count: number = componentPagination.itemsPerPage
import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
import { VideoChannel as VideoChannelServer } from '../../../../../shared/models/videos'
-import { ComponentPagination } from '@app/shared/rest/component-pagination.model'
+import { ComponentPaginationLight } from '@app/shared/rest/component-pagination.model'
type SubscriptionExistResult = { [ uri: string ]: boolean }
)
}
- listSubscriptions (componentPagination: ComponentPagination): Observable<ResultList<VideoChannel>> {
+ listSubscriptions (componentPagination: ComponentPaginationLight): Observable<ResultList<VideoChannel>> {
const url = UserSubscriptionService.BASE_USER_SUBSCRIPTIONS_URL
const pagination = this.restService.componentPaginationToRestPagination(componentPagination)
import { RestService } from '../rest/rest.service'
import { Video } from '../video/video.model'
import { catchError, map, switchMap } from 'rxjs/operators'
-import { ComponentPagination } from '@app/shared/rest/component-pagination.model'
+import { ComponentPaginationLight } from '@app/shared/rest/component-pagination.model'
import { VideoService } from '@app/shared/video/video.service'
import { ResultList } from '../../../../../shared'
private videoService: VideoService
) {}
- getUserVideosHistory (historyPagination: ComponentPagination) {
+ getUserVideosHistory (historyPagination: ComponentPaginationLight) {
const pagination = this.restService.componentPaginationToRestPagination(historyPagination)
let params = new HttpParams()
import { ResultList, UserNotification as UserNotificationServer, UserNotificationSetting } from '../../../../../shared'
import { UserNotification } from './user-notification.model'
import { AuthService } from '../../core'
-import { ComponentPagination } from '../rest/component-pagination.model'
+import { ComponentPaginationLight } from '../rest/component-pagination.model'
import { User } from '../users/user.model'
import { UserNotificationSocket } from '@app/core/notification/user-notification-socket.service'
private userNotificationSocket: UserNotificationSocket
) {}
- listMyNotifications (pagination: ComponentPagination, unread?: boolean, ignoreLoadingBar = false) {
+ listMyNotifications (pagination: ComponentPaginationLight, unread?: boolean, ignoreLoadingBar = false) {
let params = new HttpParams()
params = this.restService.addRestGetParams(params, this.restService.componentPaginationToRestPagination(pagination))
import { Video } from '../video/video.model'
import { environment } from '../../../environments/environment'
import { RestExtractor, RestPagination, RestService } from '../rest'
-import { ComponentPagination } from '../rest/component-pagination.model'
+import { ComponentPaginationLight } from '../rest/component-pagination.model'
@Injectable()
export class VideoBlacklistService {
)
}
- getAutoBlacklistedAsVideoList (videoPagination: ComponentPagination): Observable<ResultList<Video>> {
+ getAutoBlacklistedAsVideoList (videoPagination: ComponentPaginationLight): Observable<ResultList<Video>> {
const pagination = this.restService.componentPaginationToRestPagination(videoPagination)
// prioritize first created since waiting longest
import { environment } from '../../../environments/environment'
import { Account } from '@app/shared/account/account.model'
import { Avatar } from '../../../../../shared/models/avatars/avatar.model'
-import { ComponentPagination } from '@app/shared/rest/component-pagination.model'
+import { ComponentPaginationLight } from '@app/shared/rest/component-pagination.model'
import { RestService } from '@app/shared/rest'
@Injectable()
)
}
- listAccountVideoChannels (account: Account, componentPagination?: ComponentPagination): Observable<ResultList<VideoChannel>> {
+ listAccountVideoChannels (account: Account, componentPagination?: ComponentPaginationLight): Observable<ResultList<VideoChannel>> {
const pagination = componentPagination
? this.restService.componentPaginationToRestPagination(componentPagination)
: { start: 0, count: 20 }
import { RestService } from '@app/shared/rest'
import { VideoExistInPlaylist, VideosExistInPlaylists } from '@shared/models/videos/playlist/video-exist-in-playlist.model'
import { VideoPlaylistReorder } from '@shared/models/videos/playlist/video-playlist-reorder.model'
-import { ComponentPagination } from '@app/shared/rest/component-pagination.model'
+import { ComponentPaginationLight } from '@app/shared/rest/component-pagination.model'
import { VideoPlaylistElement as ServerVideoPlaylistElement } from '@shared/models/videos/playlist/video-playlist-element.model'
import { VideoPlaylistElement } from '@app/shared/video-playlist/video-playlist-element.model'
import { uniq } from 'lodash-es'
)
}
- listChannelPlaylists (videoChannel: VideoChannel, componentPagination: ComponentPagination): Observable<ResultList<VideoPlaylist>> {
+ listChannelPlaylists (videoChannel: VideoChannel, componentPagination: ComponentPaginationLight): Observable<ResultList<VideoPlaylist>> {
const url = VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannel.nameWithHost + '/video-playlists'
const pagination = this.restService.componentPaginationToRestPagination(componentPagination)
listAccountPlaylists (
account: Account,
- componentPagination: ComponentPagination,
+ componentPagination: ComponentPaginationLight,
sort: string,
search?: string
): Observable<ResultList<VideoPlaylist>> {
getPlaylistVideos (
videoPlaylistId: number | string,
- componentPagination: ComponentPagination
+ componentPagination: ComponentPaginationLight
): Observable<ResultList<VideoPlaylistElement>> {
const path = VideoPlaylistService.BASE_VIDEO_PLAYLIST_URL + videoPlaylistId + '/videos'
const pagination = this.restService.componentPaginationToRestPagination(componentPagination)
import { ActivatedRoute, Router } from '@angular/router'
import { fromEvent, Observable, of, Subject, Subscription } from 'rxjs'
import { AuthService } from '../../core/auth'
-import { ComponentPagination } from '../rest/component-pagination.model'
+import { ComponentPaginationLight } from '../rest/component-pagination.model'
import { VideoSortField } from './sort-field.type'
import { Video } from './video.model'
import { ScreenService } from '@app/shared/misc/screen.service'
import { DisableForReuseHook } from '@app/core/routing/disable-for-reuse-hook'
import { I18n } from '@ngx-translate/i18n-polyfill'
import { isLastMonth, isLastWeek, isToday, isYesterday } from '@shared/core-utils/miscs/date'
-import { ResultList, ServerConfig } from '@shared/models'
+import { ServerConfig } from '@shared/models'
enum GroupDate {
UNKNOWN = 0,
}
export abstract class AbstractVideoList implements OnInit, OnDestroy, DisableForReuseHook {
- pagination: ComponentPagination = {
+ pagination: ComponentPaginationLight = {
currentPage: 1,
- itemsPerPage: 25,
- totalItems: null
+ itemsPerPage: 25
}
sort: VideoSortField = '-publishedAt'
groupByDate = false
videos: Video[] = []
+ hasDoneFirstQuery = false
disabled = false
displayOptions: MiniatureDisplayOptions = {
private groupedDateLabels: { [id in GroupDate]: string }
private groupedDates: { [id: number]: GroupDate } = {}
- abstract getVideosObservable (page: number): Observable<ResultList<Video>>
+ private lastQueryLength: number
+
+ abstract getVideosObservable (page: number): Observable<{ data: Video[] }>
abstract generateSyndicationList (): void
onNearOfBottom () {
if (this.disabled) return
- // Last page
- if (this.pagination.totalItems <= (this.pagination.currentPage * this.pagination.itemsPerPage)) return
+ // No more results
+ if (this.lastQueryLength !== undefined && this.lastQueryLength < this.pagination.itemsPerPage) return
this.pagination.currentPage += 1
loadMoreVideos (reset = false) {
this.getVideosObservable(this.pagination.currentPage).subscribe(
- ({ data, total }) => {
- this.pagination.totalItems = total
+ ({ data }) => {
+ this.hasDoneFirstQuery = true
+ this.lastQueryLength = data.length
+
if (reset) this.videos = []
this.videos = this.videos.concat(data)
} from '../../../../../shared/models/videos'
import { FeedFormat } from '../../../../../shared/models/feeds/feed-format.enum'
import { environment } from '../../../environments/environment'
-import { ComponentPagination } from '../rest/component-pagination.model'
+import { ComponentPaginationLight } from '../rest/component-pagination.model'
import { RestExtractor } from '../rest/rest-extractor.service'
import { RestService } from '../rest/rest.service'
import { UserService } from '../users/user.service'
export interface VideosProvider {
getVideos (parameters: {
- videoPagination: ComponentPagination,
+ videoPagination: ComponentPaginationLight,
sort: VideoSortField,
filter?: VideoFilter,
categoryOneOf?: number,
.pipe(catchError(err => this.restExtractor.handleError(err)))
}
- getMyVideos (videoPagination: ComponentPagination, sort: VideoSortField, search?: string): Observable<ResultList<Video>> {
+ getMyVideos (videoPagination: ComponentPaginationLight, sort: VideoSortField, search?: string): Observable<ResultList<Video>> {
const pagination = this.restService.componentPaginationToRestPagination(videoPagination)
let params = new HttpParams()
getAccountVideos (
account: Account,
- videoPagination: ComponentPagination,
+ videoPagination: ComponentPaginationLight,
sort: VideoSortField
): Observable<ResultList<Video>> {
const pagination = this.restService.componentPaginationToRestPagination(videoPagination)
getVideoChannelVideos (
videoChannel: VideoChannel,
- videoPagination: ComponentPagination,
+ videoPagination: ComponentPaginationLight,
sort: VideoSortField
): Observable<ResultList<Video>> {
const pagination = this.restService.componentPaginationToRestPagination(videoPagination)
}
getUserSubscriptionVideos (parameters: {
- videoPagination: ComponentPagination,
- sort: VideoSortField
+ videoPagination: ComponentPaginationLight,
+ sort: VideoSortField,
+ skipCount?: boolean
}): Observable<ResultList<Video>> {
- const { videoPagination, sort } = parameters
+ const { videoPagination, sort, skipCount } = parameters
const pagination = this.restService.componentPaginationToRestPagination(videoPagination)
let params = new HttpParams()
params = this.restService.addRestGetParams(params, pagination, sort)
+ if (skipCount) params = params.set('skipCount', skipCount + '')
+
return this.authHttp
.get<ResultList<Video>>(UserSubscriptionService.BASE_USER_SUBSCRIPTIONS_URL + '/videos', { params })
.pipe(
}
getVideos (parameters: {
- videoPagination: ComponentPagination,
+ videoPagination: ComponentPaginationLight,
sort: VideoSortField,
filter?: VideoFilter,
categoryOneOf?: number,
- languageOneOf?: string[]
+ languageOneOf?: string[],
+ skipCount?: boolean
}): Observable<ResultList<Video>> {
- const { videoPagination, sort, filter, categoryOneOf, languageOneOf } = parameters
+ const { videoPagination, sort, filter, categoryOneOf, languageOneOf, skipCount } = parameters
const pagination = this.restService.componentPaginationToRestPagination(videoPagination)
let params = new HttpParams()
params = this.restService.addRestGetParams(params, pagination, sort)
- if (filter) {
- params = params.set('filter', filter)
- }
-
- if (categoryOneOf) {
- params = params.set('categoryOneOf', categoryOneOf + '')
- }
+ if (filter) params = params.set('filter', filter)
+ if (categoryOneOf) params = params.set('categoryOneOf', categoryOneOf + '')
+ if (skipCount) params = params.set('skipCount', skipCount + '')
if (languageOneOf) {
for (const l of languageOneOf) {
import { Injectable } from '@angular/core'
import { objectLineFeedToHtml } from '@app/shared/misc/utils'
import { Observable } from 'rxjs'
-import { ResultList, FeedFormat } from '../../../../../../shared/models'
+import { FeedFormat, ResultList } from '../../../../../../shared/models'
import {
VideoComment as VideoCommentServerModel,
VideoCommentCreate,
} from '../../../../../../shared/models/videos/video-comment.model'
import { environment } from '../../../../environments/environment'
import { RestExtractor, RestService } from '../../../shared/rest'
-import { ComponentPagination } from '../../../shared/rest/component-pagination.model'
+import { ComponentPaginationLight } from '../../../shared/rest/component-pagination.model'
import { CommentSortField } from '../../../shared/video/sort-field.type'
import { VideoComment } from './video-comment.model'
getVideoCommentThreads (parameters: {
videoId: number | string,
- componentPagination: ComponentPagination,
+ componentPagination: ComponentPaginationLight,
sort: CommentSortField
}): Observable<ResultList<VideoComment>> {
const { videoId, componentPagination, sort } = parameters
sort: this.sort,
filter: this.filter,
categoryOneOf: this.categoryOneOf,
- languageOneOf: this.languageOneOf
+ languageOneOf: this.languageOneOf,
+ skipCount: true
}
return this.hooks.wrapObsFun(
videoPagination: newPagination,
sort: this.sort,
categoryOneOf: this.categoryOneOf,
- languageOneOf: this.languageOneOf
+ languageOneOf: this.languageOneOf,
+ skipCount: true
}
return this.hooks.wrapObsFun(
videoPagination: newPagination,
sort: this.sort,
categoryOneOf: this.categoryOneOf,
- languageOneOf: this.languageOneOf
+ languageOneOf: this.languageOneOf,
+ skipCount: true
}
return this.hooks.wrapObsFun(
videoPagination: newPagination,
sort: this.sort,
categoryOneOf: this.categoryOneOf,
- languageOneOf: this.languageOneOf
+ languageOneOf: this.languageOneOf,
+ skipCount: true
}
return this.hooks.wrapObsFun(
const newPagination = immutableAssign(this.pagination, { currentPage: page })
const params = {
videoPagination: newPagination,
- sort: this.sort
+ sort: this.sort,
+ skipCount: true
}
return this.hooks.wrapObsFun(