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 @@