Browse Source

fix: repo preview page crash

issue:
nostr:note10kkr6mnj0wulfpenqeq02rzraxfj6yttk8lnfkz6lau9w7jeqldsjjwfla

this adds robustness to previous commit

ensureRepo always returns with writable that includes identifier and
author before any events are fetched
master
DanConwayDev 2 years ago
parent
commit
a63ad345aa
No known key found for this signature in database
GPG Key ID: 68E15486D73F75E1
  1. 10
      src/lib/stores/repos.ts

10
src/lib/stores/repos.ts

@ -39,14 +39,18 @@ export const ensureRepo = (a: string | NDKEvent): Writable<RepoEvent> => { @@ -39,14 +39,18 @@ export const ensureRepo = (a: string | NDKEvent): Writable<RepoEvent> => {
...event_defaults,
}
repos[a] = writable(base)
const a_ref = extractAReference(a)
if (!a_ref) return repos[a]
if (!a_ref) return writable(base)
const { pubkey, identifier } = a_ref
repos[a] = writable({
...base,
identifier,
author: pubkey,
})
const sub = ndk.subscribe(
{ kinds: [repo_kind], '#d': [identifier], authors: [pubkey] },
{

Loading…
Cancel
Save