Browse Source

fix: lists issue summaries error

error preventing issue summaries from being counted introduced in
33d35dcac8
master
DanConwayDev 2 years ago
parent
commit
5628d0d723
No known key found for this signature in database
GPG Key ID: 68E15486D73F75E1
  1. 32
      src/lib/stores/Issues.ts

32
src/lib/stores/Issues.ts

@ -4,10 +4,8 @@ import {
NDKSubscription, NDKSubscription,
type NDKFilter, type NDKFilter,
} from '@nostr-dev-kit/ndk' } from '@nostr-dev-kit/ndk'
import { writable, type Unsubscriber, type Writable } from 'svelte/store' import { writable, type Writable } from 'svelte/store'
import { base_relays, ndk } from './ndk' import { base_relays, ndk } from './ndk'
import type { User } from '$lib/components/users/type'
import { ensureUser } from './users'
import { awaitSelectedRepoCollection } from './repo' import { awaitSelectedRepoCollection } from './repo'
import { import {
issue_kind, issue_kind,
@ -33,8 +31,6 @@ export const issue_summaries: Writable<IssueSummaries> = writable({
let selected_repo_id: string | undefined = '' let selected_repo_id: string | undefined = ''
let authors_unsubscribers: Unsubscriber[] = []
let sub: NDKSubscription let sub: NDKSubscription
export const ensureIssueSummaries = async (repo_id: string | undefined) => { export const ensureIssueSummaries = async (repo_id: string | undefined) => {
@ -47,8 +43,6 @@ export const ensureIssueSummaries = async (repo_id: string | undefined) => {
if (sub) sub.stop() if (sub) sub.stop()
if (sub_statuses) sub_statuses.stop() if (sub_statuses) sub_statuses.stop()
authors_unsubscribers.forEach((u) => u())
authors_unsubscribers = []
selected_repo_id = repo_id selected_repo_id = repo_id
@ -83,9 +77,7 @@ export const ensureIssueSummaries = async (repo_id: string | undefined) => {
filter = { filter = {
kinds: [issue_kind], kinds: [issue_kind],
'#a': repo.maintainers.map( '#a': repo.maintainers.map((m) => `${repo_kind}:${m}:${repo.identifier}`),
(m) => `${repo_kind}:${m.hexpubkey}:${repo.identifier}`
),
limit: 100, limit: 100,
} }
} }
@ -119,31 +111,13 @@ export const ensureIssueSummaries = async (repo_id: string | undefined) => {
descritpion: extractIssueDescription(event.content), descritpion: extractIssueDescription(event.content),
created_at: event.created_at, created_at: event.created_at,
comments: 0, comments: 0,
author: { author: event.pubkey,
hexpubkey: event.pubkey,
loading: true,
npub: '',
},
loading: false, loading: false,
}, },
], ],
} }
}) })
} }
authors_unsubscribers.push(
ensureUser(event.pubkey).subscribe((u: User) => {
issue_summaries.update((issues) => {
return {
...issues,
summaries: issues.summaries.map((o) => ({
...o,
author: event.pubkey === o.author.hexpubkey ? u : o.author,
})),
}
})
})
)
} catch {} } catch {}
}) })
sub.on('eose', () => { sub.on('eose', () => {

Loading…
Cancel
Save