X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2F%2Bmy-library%2Fmy-videos%2Fmy-videos.component.ts;h=72d28ced7385d25e7ae9d1bd0b312558a474c252;hb=dd24f1bb0a4b252e5342b251ba36853364da7b8e;hp=f9c1b32b036b53e9c90ddb3d5225c201033e3649;hpb=1fd61899eaea245a5844e33e21f04b2562f16e5e;p=github%2FChocobozzz%2FPeerTube.git 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.ts index f9c1b32b0..72d28ced7 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 @@ -1,8 +1,8 @@ import { concat, Observable } from 'rxjs' import { tap, toArray } from 'rxjs/operators' -import { AfterViewInit, Component, OnInit, ViewChild } from '@angular/core' +import { Component, OnInit, ViewChild } from '@angular/core' import { ActivatedRoute, Router } from '@angular/router' -import { AuthService, ComponentPagination, ConfirmService, Notifier, RouteFilter, ScreenService, ServerService, User } from '@app/core' +import { AuthService, ComponentPagination, ConfirmService, Notifier, ScreenService, ServerService, User } from '@app/core' import { DisableForReuseHook } from '@app/core/routing/disable-for-reuse-hook' import { immutableAssign } from '@app/helpers' import { AdvancedInputFilter } from '@app/shared/shared-forms' @@ -16,7 +16,7 @@ import { VideoChangeOwnershipComponent } from './modals/video-change-ownership.c templateUrl: './my-videos.component.html', styleUrls: [ './my-videos.component.scss' ] }) -export class MyVideosComponent extends RouteFilter implements OnInit, AfterViewInit, DisableForReuseHook { +export class MyVideosComponent implements OnInit, DisableForReuseHook { @ViewChild('videosSelection', { static: true }) videosSelection: VideosSelectionComponent @ViewChild('videoChangeOwnershipModal', { static: true }) videoChangeOwnershipModal: VideoChangeOwnershipComponent @ViewChild('liveStreamInformationModal', { static: true }) liveStreamInformationModal: LiveStreamInformationComponent @@ -42,17 +42,22 @@ export class MyVideosComponent extends RouteFilter implements OnInit, AfterViewI videos: Video[] = [] getVideosObservableFunction = this.getVideosObservable.bind(this) + sort: VideoSortField = '-publishedAt' user: User inputFilters: AdvancedInputFilter[] = [ { - queryParams: { 'search': 'isLive:true' }, + queryParams: { search: 'isLive:true' }, label: $localize`Only live videos` } ] + disabled = false + + private search: string + constructor ( protected router: Router, protected serverService: ServerService, @@ -63,8 +68,6 @@ export class MyVideosComponent extends RouteFilter implements OnInit, AfterViewI private confirmService: ConfirmService, private videoService: VideoService ) { - super() - this.titlePage = $localize`My videos` } @@ -72,16 +75,14 @@ export class MyVideosComponent extends RouteFilter implements OnInit, AfterViewI this.buildActions() this.user = this.authService.getUser() - - this.initSearch() - this.listenToSearchChange() } - ngAfterViewInit () { - if (this.search) this.setTableFilter(this.search, false) + onSearch (search: string) { + this.search = search + this.reloadData() } - loadData () { + reloadData () { this.videosSelection.reloadVideos() } @@ -90,11 +91,11 @@ export class MyVideosComponent extends RouteFilter implements OnInit, AfterViewI } disableForReuse () { - this.videosSelection.disableForReuse() + this.disabled = true } enabledForReuse () { - this.videosSelection.enabledForReuse() + this.disabled = false } getVideosObservable (page: number) { @@ -108,7 +109,7 @@ export class MyVideosComponent extends RouteFilter implements OnInit, AfterViewI async deleteSelectedVideos () { const toDeleteVideosIds = Object.keys(this.selection) - .filter(k => this.selection[ k ] === true) + .filter(k => this.selection[k] === true) .map(k => parseInt(k, 10)) const res = await this.confirmService.confirm( @@ -127,14 +128,14 @@ export class MyVideosComponent extends RouteFilter implements OnInit, AfterViewI concat(...observables) .pipe(toArray()) - .subscribe( - () => { + .subscribe({ + next: () => { this.notifier.success($localize`${toDeleteVideosIds.length} videos deleted.`) this.selection = {} }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } async deleteVideo (video: Video) { @@ -145,14 +146,14 @@ export class MyVideosComponent extends RouteFilter implements OnInit, AfterViewI if (res === false) return this.videoService.removeVideo(video.id) - .subscribe( - () => { + .subscribe({ + next: () => { this.notifier.success($localize`Video ${video.name} deleted.`) this.removeVideoFromArray(video.id) }, - error => this.notifier.error(error.message) - ) + error: err => this.notifier.error(err.message) + }) } changeOwnership (video: Video) {