Radish alpha
r
rad:z4D5UCArafTzTQpDZNQRuqswh3ury
Radicle desktop app
Radicle
Git
Fix repo listing not displaying all repos
Merged did:key:z6MkkfM3...sVz5 opened 1 year ago

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.

5 files changed +27 -3 9235f186 19fdd17f
modified crates/radicle-types/bindings/repo/RepoCount.ts
@@ -2,6 +2,7 @@

export type RepoCount = {
  total: number;
+
  contributor: number;
  delegate: number;
  private: number;
  seeding: number;
modified crates/radicle-types/src/repo.rs
@@ -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,
modified crates/radicle-types/src/traits/repo.rs
@@ -21,6 +21,7 @@ use crate::traits::Profile;
pub enum Show {
    Delegate,
    All,
+
    Contributor,
    Seeded,
    Private,
}
@@ -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;
            }

@@ -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;
            }
@@ -85,12 +88,13 @@ pub trait Repo: Profile {
            }

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

        Ok::<_, Error>(RepoCount {
            total,
+
            contributor,
            seeding,
            private,
            delegate,
modified src/components/HomeSidebar.svelte
@@ -153,6 +153,22 @@
        <!-- 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"}
          onclick={() =>
            router.push({
modified src/lib/router/definitions.ts
@@ -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;
@@ -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";
      }