From 4ddca81f169456f80b2324df566903d0cab33765 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C5=ABdolfs=20O=C5=A1i=C5=86=C5=A1?= Date: Wed, 29 Apr 2026 12:03:14 +0200 Subject: [PATCH] Add "Sort by activity" toggle to repo list --- src/components/RepoCard.ts | 16 ++++++++++++++ src/views/nodes/ReposView.svelte | 38 ++++++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/src/components/RepoCard.ts b/src/components/RepoCard.ts index 4cdb98a8e..d2bf970b8 100644 --- a/src/components/RepoCard.ts +++ b/src/components/RepoCard.ts @@ -37,3 +37,19 @@ export async function fetchRepoInfos( }), })); } + +export async function sortRepoInfosByActivity( + repos: RepoInfo[], +): Promise { + const withActivity = await Promise.all( + repos.map(async r => ({ info: r, activity: await r.activity })), + ); + return withActivity + .sort((a, b) => { + if (a.activity.length === 0 && b.activity.length === 0) return 0; + if (a.activity.length === 0) return 1; + if (b.activity.length === 0) return -1; + return b.activity[0].time - a.activity[0].time; + }) + .map(x => x.info); +} diff --git a/src/views/nodes/ReposView.svelte b/src/views/nodes/ReposView.svelte index c28e9e2b5..f54f19b56 100644 --- a/src/views/nodes/ReposView.svelte +++ b/src/views/nodes/ReposView.svelte @@ -1,8 +1,12 @@