X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2F%2Bmy-library%2Fmy-video-playlists%2Fmy-video-playlists.component.ts;h=d90102693acab006a4dd542ef65a6124e1a45f14;hb=2e46eb97154da909b82d5efe1d336a3412594ff0;hp=f6d39492320b57d5a7d15ab9967463c2812bef3e;hpb=17119e4a546522468878cf115558b17949ab50d0;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/+my-library/my-video-playlists/my-video-playlists.component.ts b/client/src/app/+my-library/my-video-playlists/my-video-playlists.component.ts index f6d394923..d90102693 100644 --- a/client/src/app/+my-library/my-video-playlists/my-video-playlists.component.ts +++ b/client/src/app/+my-library/my-video-playlists/my-video-playlists.component.ts @@ -1,7 +1,7 @@ import { Subject } from 'rxjs' -import { debounceTime, mergeMap } from 'rxjs/operators' -import { Component, OnInit } from '@angular/core' -import { AuthService, ComponentPagination, ConfirmService, Notifier, User } from '@app/core' +import { mergeMap } from 'rxjs/operators' +import { Component } from '@angular/core' +import { AuthService, ComponentPagination, ConfirmService, Notifier } from '@app/core' import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist' import { VideoPlaylistType } from '@shared/models' @@ -9,10 +9,8 @@ import { VideoPlaylistType } from '@shared/models' templateUrl: './my-video-playlists.component.html', styleUrls: [ './my-video-playlists.component.scss' ] }) -export class MyVideoPlaylistsComponent implements OnInit { - videoPlaylistsSearch: string +export class MyVideoPlaylistsComponent { videoPlaylists: VideoPlaylist[] = [] - videoPlaylistSearchChanged = new Subject() pagination: ComponentPagination = { currentPage: 1, @@ -22,27 +20,14 @@ export class MyVideoPlaylistsComponent implements OnInit { onDataSubject = new Subject() - private user: User + search: string constructor ( private authService: AuthService, private notifier: Notifier, private confirmService: ConfirmService, private videoPlaylistService: VideoPlaylistService - ) {} - - ngOnInit () { - this.user = this.authService.getUser() - - this.loadVideoPlaylists() - - this.videoPlaylistSearchChanged - .pipe( - debounceTime(500)) - .subscribe(() => { - this.loadVideoPlaylists(true) - }) - } + ) {} async deleteVideoPlaylist (videoPlaylist: VideoPlaylist) { const res = await this.confirmService.confirm( @@ -76,22 +61,20 @@ export class MyVideoPlaylistsComponent implements OnInit { this.loadVideoPlaylists() } - resetSearch () { - this.videoPlaylistsSearch = '' - this.onVideoPlaylistSearchChanged() - } - - onVideoPlaylistSearchChanged () { - this.videoPlaylistSearchChanged.next() + onSearch (search: string) { + this.search = search + this.loadVideoPlaylists(true) } private loadVideoPlaylists (reset = false) { this.authService.userInformationLoaded .pipe(mergeMap(() => { - return this.videoPlaylistService.listAccountPlaylists(this.user.account, this.pagination, '-updatedAt', this.videoPlaylistsSearch) - })) - .subscribe(res => { + const user = this.authService.getUser() + + return this.videoPlaylistService.listAccountPlaylists(user.account, this.pagination, '-updatedAt', this.search) + })).subscribe(res => { if (reset) this.videoPlaylists = [] + this.videoPlaylists = this.videoPlaylists.concat(res.data) this.pagination.totalItems = res.total