From dc2b2938c293bae271a27a6c823f66496998b4d3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 10 May 2021 09:31:33 +0200 Subject: Sort channels by -updatedAt --- .../shared-main/video-channel/video-channel.model.ts | 4 ++++ .../video-channel/video-channel.service.ts | 19 ++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) (limited to 'client/src/app/shared/shared-main/video-channel') diff --git a/client/src/app/shared/shared-main/video-channel/video-channel.model.ts b/client/src/app/shared/shared-main/video-channel/video-channel.model.ts index c40dd5311..a9dcf2fa2 100644 --- a/client/src/app/shared/shared-main/video-channel/video-channel.model.ts +++ b/client/src/app/shared/shared-main/video-channel/video-channel.model.ts @@ -16,6 +16,8 @@ export class VideoChannel extends Actor implements ServerVideoChannel { banner: ActorImage bannerUrl: string + updatedAt: Date | string + ownerAccount?: ServerAccount ownerBy?: string @@ -59,6 +61,8 @@ export class VideoChannel extends Actor implements ServerVideoChannel { this.videosCount = hash.videosCount + if (hash.updatedAt) this.updatedAt = new Date(hash.updatedAt.toString()) + if (hash.viewsPerDay) { this.viewsPerDay = hash.viewsPerDay.map(v => ({ ...v, date: new Date(v.date) })) } diff --git a/client/src/app/shared/shared-main/video-channel/video-channel.service.ts b/client/src/app/shared/shared-main/video-channel/video-channel.service.ts index e65261763..a89f1065a 100644 --- a/client/src/app/shared/shared-main/video-channel/video-channel.service.ts +++ b/client/src/app/shared/shared-main/video-channel/video-channel.service.ts @@ -40,23 +40,24 @@ export class VideoChannelService { ) } - listAccountVideoChannels ( - account: Account, - componentPagination?: ComponentPaginationLight, - withStats = false, + listAccountVideoChannels (options: { + account: Account + componentPagination?: ComponentPaginationLight + withStats?: boolean + sort?: string search?: string - ): Observable> { + }): Observable> { + const { account, componentPagination, withStats = false, sort, search } = options + const pagination = componentPagination ? this.restService.componentPaginationToRestPagination(componentPagination) : { start: 0, count: 20 } let params = new HttpParams() - params = this.restService.addRestGetParams(params, pagination) + params = this.restService.addRestGetParams(params, pagination, sort) params = params.set('withStats', withStats + '') - if (search) { - params = params.set('search', search) - } + if (search) params = params.set('search', search) const url = AccountService.BASE_ACCOUNT_URL + account.nameWithHost + '/video-channels' return this.authHttp.get>(url, { params }) -- cgit v1.2.3