mirror of
https://seed.radicle.dev/rad:z4D5UCArafTzTQpDZNQRuqswh3ury.git
synced 2026-10-27 23:40:32 +08:00
Fix repo listing not displaying all repos
`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.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
export type RepoCount = {
|
||||
total: number;
|
||||
contributor: number;
|
||||
delegate: number;
|
||||
private: number;
|
||||
seeding: number;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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"}
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user