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 --- .../app/shared/shared-main/account/account.model.ts | 6 ++++++ .../src/app/shared/shared-main/account/actor.model.ts | 2 -- .../shared-main/video-channel/video-channel.model.ts | 4 ++++ .../video-channel/video-channel.service.ts | 19 ++++++++++--------- 4 files changed, 20 insertions(+), 11 deletions(-) (limited to 'client/src/app/shared/shared-main') diff --git a/client/src/app/shared/shared-main/account/account.model.ts b/client/src/app/shared/shared-main/account/account.model.ts index 6d9f0ee65..7b5611f35 100644 --- a/client/src/app/shared/shared-main/account/account.model.ts +++ b/client/src/app/shared/shared-main/account/account.model.ts @@ -4,8 +4,12 @@ import { Actor } from './actor.model' export class Account extends Actor implements ServerAccount { displayName: string description: string + + updatedAt: Date | string + nameWithHost: string nameWithHostForced: string + mutedByUser: boolean mutedByInstance: boolean mutedServerByUser: boolean @@ -30,6 +34,8 @@ export class Account extends Actor implements ServerAccount { this.nameWithHost = Actor.CREATE_BY_STRING(this.name, this.host) this.nameWithHostForced = Actor.CREATE_BY_STRING(this.name, this.host, true) + if (hash.updatedAt) this.updatedAt = new Date(hash.updatedAt.toString()) + this.mutedByUser = false this.mutedByInstance = false this.mutedServerByUser = false diff --git a/client/src/app/shared/shared-main/account/actor.model.ts b/client/src/app/shared/shared-main/account/actor.model.ts index 6ba0bb09e..2fccc472a 100644 --- a/client/src/app/shared/shared-main/account/actor.model.ts +++ b/client/src/app/shared/shared-main/account/actor.model.ts @@ -12,7 +12,6 @@ export abstract class Actor implements ServerActor { followersCount: number createdAt: Date | string - updatedAt: Date | string avatar: ActorImage @@ -55,7 +54,6 @@ export abstract class Actor implements ServerActor { this.followersCount = hash.followersCount if (hash.createdAt) this.createdAt = new Date(hash.createdAt.toString()) - if (hash.updatedAt) this.updatedAt = new Date(hash.updatedAt.toString()) this.avatar = hash.avatar this.isLocal = Actor.IS_LOCAL(this.host) 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