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 --- client/src/app/helpers/utils.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'client/src/app/helpers') diff --git a/client/src/app/helpers/utils.ts b/client/src/app/helpers/utils.ts index a1747af3c..17eb5effc 100644 --- a/client/src/app/helpers/utils.ts +++ b/client/src/app/helpers/utils.ts @@ -30,12 +30,18 @@ function listUserChannels (authService: AuthService) { const videoChannels = user.videoChannels if (Array.isArray(videoChannels) === false) return undefined - return videoChannels.map(c => ({ - id: c.id, - label: c.displayName, - support: c.support, - avatarPath: c.avatar?.path - }) as SelectChannelItem) + return videoChannels + .sort((a, b) => { + if (a.updatedAt < b.updatedAt) return 1 + if (a.updatedAt > b.updatedAt) return -1 + return 0 + }) + .map(c => ({ + id: c.id, + label: c.displayName, + support: c.support, + avatarPath: c.avatar?.path + }) as SelectChannelItem) })) } -- cgit v1.2.3