cli: Stabilize sort order of inbox repos

Sort repositories before displaying them.
This commit is contained in:
cloudhead 2024-02-12 12:01:54 +01:00
parent 9576a6496b
commit b477864b83
No known key found for this signature in database
2 changed files with 13 additions and 10 deletions

View File

@ -28,17 +28,17 @@ $ rad inbox --sort-by id
``` ~alice
$ rad inbox --all --sort-by id
╭──────────────────────────────────────────────────────────╮
│ radicle-git │
├──────────────────────────────────────────────────────────┤
│ 3 ● patch Copyright fixes [ ... ] opened now │
╰──────────────────────────────────────────────────────────╯
╭──────────────────────────────────────────────────────────────╮
│ heartwood │
├──────────────────────────────────────────────────────────────┤
│ 1 ● issue No license file [ .. ] opened now │
│ 2 ● branch Change copyright bob/copy created now │
╰──────────────────────────────────────────────────────────────╯
╭──────────────────────────────────────────────────────────╮
│ radicle-git │
├──────────────────────────────────────────────────────────┤
│ 3 ● patch Copyright fixes [ ... ] opened now │
╰──────────────────────────────────────────────────────────╯
```
``` ~alice

View File

@ -201,12 +201,15 @@ fn list_all<'a>(
notifs: &notifications::StoreReader,
storage: &Storage,
) -> anyhow::Result<Vec<term::VStack<'a>>> {
let mut repos = Vec::new();
for repo in storage.repositories()? {
let repo = list_repo(repo.rid, sort_by, notifs, storage)?;
repos.extend(repo.into_iter());
let mut repos = storage.repositories()?;
repos.sort_by_key(|r| r.rid);
let mut vstacks = Vec::new();
for repo in repos {
let vstack = list_repo(repo.rid, sort_by, notifs, storage)?;
vstacks.extend(vstack.into_iter());
}
Ok(repos)
Ok(vstacks)
}
fn list_repo<'a, R: ReadStorage>(