ActivityPub-federated video streaming platform using P2P directly in your web browser
Use pagination for my videos
Chocobozzzea55c052fce9
diff --git a/client/src/app/+my-library/my-videos/my-videos.component.html b/client/src/app/+my-library/my-videos/my-videos.component.htmlindex 042c796826..9c88e8ece9 100644--- a/client/src/app/+my-library/my-videos/my-videos.component.html+++ b/client/src/app/+my-library/my-videos/my-videos.component.html@@ -34,7 +34,10 @@<div class="d-flex align-items-center"><label class="label-inline d-none d-inline-block-mw" for="table-search" i18n>Search</label>- <my-advanced-input-filter inputId="table-search" icon="true" i18n-placeholder placeholder="Search your videos" (search)="onSearch($event)"></my-advanced-input-filter>+ <my-advanced-input-filter+ inputId="table-search" icon="true" emitOnInit="false" i18n-placeholder placeholder="Search your videos"+ (search)="onSearch($event)"+ ></my-advanced-input-filter></div><div class="d-flex align-items-center">diff --git a/client/src/app/+my-library/my-videos/my-videos.component.ts b/client/src/app/+my-library/my-videos/my-videos.component.tsindex fe7855e75f..9bbe15bb4c 100644--- a/client/src/app/+my-library/my-videos/my-videos.component.ts+++ b/client/src/app/+my-library/my-videos/my-videos.component.ts@@ -31,9 +31,10 @@ import {VideosExistInPlaylists} from '@peertube/peertube-models'import { logger } from '@root-helpers/logger'+import debug from 'debug'import uniqBy from 'lodash-es/uniqBy'import { SharedModule, SortMeta } from 'primeng/api'-import { TableModule } from 'primeng/table'+import { TableLazyLoadEvent, TableModule } from 'primeng/table'import { finalize } from 'rxjs/operators'import { SelectOptionsItem } from 'src/types'import { AdvancedInputFilterComponent } from '../../shared/shared-forms/advanced-input-filter.component'@@ -52,8 +53,20 @@ import { VideoPrivacyBadgeComponent } from '../../shared/shared-video/video-privimport { VideoStateBadgeComponent } from '../../shared/shared-video/video-state-badge.component'import { VideoChangeOwnershipComponent } from './modals/video-change-ownership.component'+const debugLogger = debug('peertube:my-videos')+type Column = 'duration' | 'name' | 'privacy' | 'sensitive' | 'playlists' | 'insights' | 'published' | 'state' | 'comments'type CommonFilter = 'live' | 'vod' | 'private' | 'internal' | 'unlisted' | 'password-protected' | 'public'+type QueryParams = {+ channelNameOneOf?: string[]+ privacyOneOf?: string[]+ isLive?: string+ start?: number+ count?: number+ sortOrder?: number+ sortField?: string+ search?: string+}@Component({selector: 'my-videos',@@ -192,7 +205,7 @@ export class MyVideosComponent extends RestTable<Video> implements OnInit, OnDes}]- this.parseQueryParams()+ this.subscribeToQueryChanges()this.buildActions()this.loadSelectedColumns()}@@ -201,12 +214,14 @@ export class MyVideosComponent extends RestTable<Video> implements OnInit, OnDesthis.headerService.setSearchHidden(false)}- private parseQueryParams () {- const queryParams = this.route.snapshot.queryParams as {- channelNameOneOf?: string[]- privacyOneOf?: string[]- isLive: string- }+ private subscribeToQueryChanges () {+ this.route.queryParams.subscribe(queryParams => {+ this.parseQueryParams(queryParams)+ })+ }++ private parseQueryParams (queryParams: QueryParams) {+ debugLogger('Parse query params', { queryParams }){const enabledChannels = queryParams.channelNameOneOf@@ -222,6 +237,8 @@ export class MyVideosComponent extends RestTable<Video> implements OnInit, OnDes}{+ this.selectedFilterItems = []+if (queryParams.isLive === 'true') this.selectedFilterItems.push('live')if (queryParams.isLive === 'false') this.selectedFilterItems.push('vod')@@ -235,6 +252,21 @@ export class MyVideosComponent extends RestTable<Video> implements OnInit, OnDesif (enabledPrivacies.has(VideoPrivacy.PASSWORD_PROTECTED)) this.selectedFilterItems.push('password-protected')if (enabledPrivacies.has(VideoPrivacy.PRIVATE)) this.selectedFilterItems.push('private')}++ if (queryParams.start !== undefined) this.pagination.start = +queryParams.start+ if (queryParams.count !== undefined) this.pagination.count = +queryParams.count+ if (queryParams.sortOrder !== undefined) this.sort.order = +queryParams.sortOrder+ if (queryParams.sortField !== undefined) this.sort.field = queryParams.sortField+ if (queryParams.search !== undefined) this.search = queryParams.search++ this.reloadData()+ }++ loadLazy (event: TableLazyLoadEvent) {+ if (this.parseLazy(event)) {+ this.updateUrl()+ this.saveSort()+ }}getIdentifier () {@@ -272,18 +304,37 @@ export class MyVideosComponent extends RestTable<Video> implements OnInit, OnDesthis.peertubeLocalStorage.setItem(MyVideosComponent.LS_SELECTED_COLUMNS_KEY, JSON.stringify(enabled))}+ // ---------------------------------------------------------------------------++ // Override REST table method+ onSearch (search: string) {+ this.search = search++ this.onFilter()+ }+onFilter () {+ this.resetPagination()+ this.updateUrl()+ }++ private updateUrl () {const channelNameOneOf = this.channels.filter(c => c.selected).map(c => c.name)- const newParams = {+ const newParams: Record<keyof QueryParams, any> = {...this.route.snapshot.queryParams,+...this.buildCommonVideoFilters(),- channelNameOneOf+ search: this.search,+ channelNameOneOf,+ start: this.pagination.start,+ count: this.pagination.count,+ sortOrder: this.sort.order,+ sortField: this.sort.field}this.peertubeRouter.silentNavigate([ '.' ], newParams, this.route)- this.resetAndReload()}private buildCommonVideoFilters () {diff --git a/client/src/app/core/menu/menu.service.ts b/client/src/app/core/menu/menu.service.tsindex fec7a24c3f..b1e73733fd 100644--- a/client/src/app/core/menu/menu.service.ts+++ b/client/src/app/core/menu/menu.service.ts@@ -46,7 +46,6 @@ export class MenuService {}private hasMenuCollapsedByUrl (url: string) {- console.log(url)const collapsedBaseUrls = [ '/videos/publish', '/videos/manage/' ]for (const collapsedBaseUrl of collapsedBaseUrls) {diff --git a/client/src/app/core/rest/rest-table.ts b/client/src/app/core/rest/rest-table.tsindex 0c1ee40e66..9c4228b67a 100644--- a/client/src/app/core/rest/rest-table.ts+++ b/client/src/app/core/rest/rest-table.ts@@ -55,7 +55,7 @@ export abstract class RestTable<T = unknown> {peertubeLocalStorage.setItem(this.getSortLocalStorageKey(), JSON.stringify(this.sort))}- loadLazy (event: TableLazyLoadEvent) {+ protected parseLazy (event: TableLazyLoadEvent) {debugLogger('Load lazy %o.', event)if (this.lastLazyLoadEvent) {@@ -66,7 +66,7 @@ export abstract class RestTable<T = unknown> {this.lastLazyLoadEvent.rows === event.rows &&this.lastLazyLoadEvent.sortField === event.sortField &&this.lastLazyLoadEvent.sortOrder === event.sortOrder- ) return+ ) return false}this.lastLazyLoadEvent = event@@ -85,23 +85,28 @@ export abstract class RestTable<T = unknown> {this.expandedRows = {}- this.reloadData()- this.saveSort()+ return true+ }++ loadLazy (event: TableLazyLoadEvent) {+ if (this.parseLazy(event)) {+ this.reloadData()+ this.saveSort()+ }}onSearch (search: string) {this.search = search- this.resetAndReload()+ this.resetPagination()+ this.reloadData()}- protected resetAndReload () {+ resetPagination () {this.pagination = {start: 0,count: this.rowsPerPage}-- this.reloadData()}isInSelectionMode () {