Skip to content

Commit

Permalink
Fix repo listing not displaying all repos
Browse files Browse the repository at this point in the history
`Show::All` which is the default value should return all values obtained
from `storage.repositories()`.
This commit adds a `Show::Contributor` enum variant to only get repos
that the user has forked, initialized or contributed in some way.
  • Loading branch information
sebastinez committed Jan 27, 2025
1 parent 9235f18 commit 19fdd17
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions crates/radicle-types/bindings/repo/RepoCount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

export type RepoCount = {
total: number;
contributor: number;
delegate: number;
private: number;
seeding: number;
Expand Down
1 change: 1 addition & 0 deletions crates/radicle-types/src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use crate::error;
#[ts(export_to = "repo/")]
pub struct RepoCount {
pub total: usize,
pub contributor: usize,
pub delegate: usize,
pub private: usize,
pub seeding: usize,
Expand Down
8 changes: 6 additions & 2 deletions crates/radicle-types/src/traits/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use crate::traits::Profile;
pub enum Show {
Delegate,
All,
Contributor,
Seeded,
Private,
}
Expand All @@ -34,7 +35,7 @@ pub trait Repo: Profile {
let mut entries = Vec::new();

for RepositoryInfo { rid, doc, refs, .. } in repos {
if refs.is_none() && show == Show::All {
if refs.is_none() && show == Show::Contributor {
continue;
}

Expand Down Expand Up @@ -69,9 +70,11 @@ pub trait Repo: Profile {
let mut total = 0;
let mut delegate = 0;
let mut private = 0;
let mut contributor = 0;
let mut seeding = 0;

for RepositoryInfo { rid, doc, refs, .. } in repos {
total += 1;
if policies.is_seeding(&rid)? {
seeding += 1;
}
Expand All @@ -85,12 +88,13 @@ pub trait Repo: Profile {
}

if refs.is_some() {
total += 1;
contributor += 1;
}
}

Ok::<_, Error>(RepoCount {
total,
contributor,
seeding,
private,
delegate,
Expand Down
16 changes: 16 additions & 0 deletions src/components/HomeSidebar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,22 @@
</div>
<!-- svelte-ignore a11y_click_events_have_key_events -->
<!-- svelte-ignore a11y_no_static_element_interactions -->
<div
class="tab"
class:active={activeTab.filter === "contributor"}
onclick={() =>
router.push({
resource: "home",
activeTab: "contributor",
})}>
<div class="global-flex">
<Icon name="user" />
<div>Contributor</div>
</div>
<div class="global-counter">{repoCount.contributor}</div>
</div>
<!-- svelte-ignore a11y_click_events_have_key_events -->
<!-- svelte-ignore a11y_no_static_element_interactions -->
<div
class="tab"
class:active={activeTab.filter === "private"}
Expand Down
4 changes: 3 additions & 1 deletion src/lib/router/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
loadPatches,
} from "@app/views/repo/router";

export type HomeReposTab = "delegate" | "private";
export type HomeReposTab = "delegate" | "private" | "contributor";

export interface HomeInboxTab {
rid: string;
Expand Down Expand Up @@ -106,6 +106,8 @@ export async function loadRoute(
if (route.resource === "home") {
if (route.activeTab === "delegate") {
show = "delegate";
} else if (route.activeTab === "contributor") {
show = "contributor";
} else if (route.activeTab === "private") {
show = "private";
}
Expand Down

0 comments on commit 19fdd17

Please sign in to comment.