Browse Source

fix(homepage): remove duplicate repo events

temporary solution to users who accidentally ran `ngit claim` on a repo
they didn't own

ngit will select the version listed in `maintainers.yaml` if present but
git together doesn't have a trusted copy of the underlying repo to find
the correct `maintainers.yaml`

presenting multiple options for the user combined with a staring /
following system linked with WoT is the long term plan
master
DanConwayDev 2 years ago
parent
commit
0e29374773
No known key found for this signature in database
GPG Key ID: 68E15486D73F75E1
  1. 2
      src/lib/components/RepoSummaryCard.svelte
  2. 21
      src/lib/wrappers/ReposRecent.svelte

2
src/lib/components/RepoSummaryCard.svelte

@ -4,12 +4,14 @@
description: string; description: string;
repo_id: string; repo_id: string;
loading?: boolean; loading?: boolean;
created_at: number;
} }
export const defaults: Args = { export const defaults: Args = {
name: "", name: "",
repo_id: "", repo_id: "",
description: "", description: "",
loading: false, loading: false,
created_at: 0,
}; };
</script> </script>

21
src/lib/wrappers/ReposRecent.svelte

@ -3,6 +3,7 @@
import ReposSummaryList from "$lib/components/ReposSummaryList.svelte"; import ReposSummaryList from "$lib/components/ReposSummaryList.svelte";
import { repo_kind } from "$lib/kinds"; import { repo_kind } from "$lib/kinds";
import { ndk } from "$lib/stores/ndk"; import { ndk } from "$lib/stores/ndk";
import type { NDKEvent } from "@nostr-dev-kit/ndk";
import { onDestroy } from "svelte"; import { onDestroy } from "svelte";
export let limit: number = 10; export let limit: number = 10;
@ -13,16 +14,30 @@
kinds: [repo_kind], kinds: [repo_kind],
limit, limit,
}); });
sub.on("event", (event) => { sub.on("event", (event: NDKEvent) => {
if (repos.length < limit) { if (repos.length < limit) {
try { try {
if (event.kind == repo_kind) if (
event.kind == repo_kind &&
!repos.some(
(r) =>
r.repo_id == event.replaceableDTag() &&
event.created_at &&
r.created_at > event.created_at,
)
)
repos = [ repos = [
...repos, ...repos.filter(
(r) =>
!event.created_at ||
r.repo_id !== event.replaceableDTag() ||
r.created_at > event.created_at,
),
{ {
name: event.tagValue("name") || "", name: event.tagValue("name") || "",
description: event.tagValue("description") || "", description: event.tagValue("description") || "",
repo_id: event.replaceableDTag(), repo_id: event.replaceableDTag(),
created_at: event.created_at || 0,
}, },
]; ];
} catch {} } catch {}

Loading…
Cancel
Save