|
|
|
@ -6,12 +6,17 @@ import { |
|
|
|
} from '@nostr-dev-kit/ndk' |
|
|
|
} from '@nostr-dev-kit/ndk' |
|
|
|
import { writable, type Unsubscriber, type Writable } from 'svelte/store' |
|
|
|
import { writable, type Unsubscriber, type Writable } from 'svelte/store' |
|
|
|
import { ndk } from './ndk' |
|
|
|
import { ndk } from './ndk' |
|
|
|
import { isPRStatus, summary_defaults } from '$lib/components/prs/type' |
|
|
|
import { summary_defaults } from '$lib/components/prs/type' |
|
|
|
import type { User } from '$lib/components/users/type' |
|
|
|
import type { User } from '$lib/components/users/type' |
|
|
|
import { ensureUser } from './users' |
|
|
|
import { ensureUser } from './users' |
|
|
|
import type { PRStatus, PRSummaries } from '$lib/components/prs/type' |
|
|
|
import type { PRSummaries } from '$lib/components/prs/type' |
|
|
|
import { ensureSelectedRepo } from './repo' |
|
|
|
import { ensureSelectedRepo } from './repo' |
|
|
|
import { patch_kind, pr_status_kind, repo_kind } from '$lib/kinds' |
|
|
|
import { |
|
|
|
|
|
|
|
patch_kind, |
|
|
|
|
|
|
|
pr_status_kinds, |
|
|
|
|
|
|
|
proposal_status_open, |
|
|
|
|
|
|
|
repo_kind, |
|
|
|
|
|
|
|
} from '$lib/kinds' |
|
|
|
import type { Repo } from '$lib/components/repo/type' |
|
|
|
import type { Repo } from '$lib/components/repo/type' |
|
|
|
import { extractPatchMessage } from '$lib/components/events/content/utils' |
|
|
|
import { extractPatchMessage } from '$lib/components/events/content/utils' |
|
|
|
|
|
|
|
|
|
|
|
@ -138,7 +143,7 @@ function getAndUpdatePRStatus(prs: PRSummaries, repo: Repo): void { |
|
|
|
if (sub_statuses) sub_statuses.stop() |
|
|
|
if (sub_statuses) sub_statuses.stop() |
|
|
|
sub_statuses = ndk.subscribe( |
|
|
|
sub_statuses = ndk.subscribe( |
|
|
|
{ |
|
|
|
{ |
|
|
|
kinds: [pr_status_kind], |
|
|
|
kinds: pr_status_kinds, |
|
|
|
'#e': prs.summaries.map((pr) => pr.id), |
|
|
|
'#e': prs.summaries.map((pr) => pr.id), |
|
|
|
'#r': [`r-${prs.id}`], |
|
|
|
'#r': [`r-${prs.id}`], |
|
|
|
}, |
|
|
|
}, |
|
|
|
@ -150,36 +155,31 @@ function getAndUpdatePRStatus(prs: PRSummaries, repo: Repo): void { |
|
|
|
sub_statuses.on('event', (event: NDKEvent) => { |
|
|
|
sub_statuses.on('event', (event: NDKEvent) => { |
|
|
|
const tagged_pr_event = event.tagValue('e') |
|
|
|
const tagged_pr_event = event.tagValue('e') |
|
|
|
if ( |
|
|
|
if ( |
|
|
|
event.kind == pr_status_kind && |
|
|
|
event.kind && |
|
|
|
|
|
|
|
pr_status_kinds.includes(event.kind) && |
|
|
|
tagged_pr_event && |
|
|
|
tagged_pr_event && |
|
|
|
event.created_at && |
|
|
|
event.created_at |
|
|
|
event.getMatchingTags('l').length === 1 && |
|
|
|
|
|
|
|
event.getMatchingTags('l')[0].length > 1 |
|
|
|
|
|
|
|
) { |
|
|
|
) { |
|
|
|
const potential_status = event.getMatchingTags('l')[0][1] |
|
|
|
pr_summaries.update((prs) => { |
|
|
|
|
|
|
|
return { |
|
|
|
if (isPRStatus(potential_status)) { |
|
|
|
...prs, |
|
|
|
pr_summaries.update((prs) => { |
|
|
|
summaries: prs.summaries.map((o) => { |
|
|
|
return { |
|
|
|
if ( |
|
|
|
...prs, |
|
|
|
o.id === tagged_pr_event && |
|
|
|
summaries: prs.summaries.map((o) => { |
|
|
|
event.created_at && |
|
|
|
if ( |
|
|
|
o.status_date < event.created_at |
|
|
|
o.id === tagged_pr_event && |
|
|
|
) { |
|
|
|
event.created_at && |
|
|
|
return { |
|
|
|
o.status_date < event.created_at |
|
|
|
...o, |
|
|
|
) { |
|
|
|
status: event.kind as number, |
|
|
|
return { |
|
|
|
status_date: event.created_at, |
|
|
|
...o, |
|
|
|
|
|
|
|
status: potential_status as PRStatus, |
|
|
|
|
|
|
|
status_date: event.created_at, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return o |
|
|
|
return o |
|
|
|
}), |
|
|
|
}), |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
@ -189,12 +189,9 @@ function getAndUpdatePRStatus(prs: PRSummaries, repo: Repo): void { |
|
|
|
...prs, |
|
|
|
...prs, |
|
|
|
summaries: prs.summaries.map((o) => ({ |
|
|
|
summaries: prs.summaries.map((o) => ({ |
|
|
|
...o, |
|
|
|
...o, |
|
|
|
status: o.status || 'Open', |
|
|
|
status: o.status || proposal_status_open, |
|
|
|
})), |
|
|
|
})), |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
function extractTagContent(arg0: string): string { |
|
|
|
|
|
|
|
throw new Error('Function not implemented.') |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|