Browse Source

feat(Issue): use `subject` tag for title

as discussed in this nip PR:
https://github.com/nostr-protocol/nips/pull/1505#issuecomment-2364171976
and this one:
https://github.com/nostr-protocol/nips/pull/1446
master
DanConwayDev 2 years ago
parent
commit
865f554920
No known key found for this signature in database
GPG Key ID: 68E15486D73F75E1
  1. 3
      src/lib/components/events/content/IssuePreview.svelte
  2. 6
      src/lib/components/events/content/utils.ts
  3. 2
      src/lib/stores/Issue.ts
  4. 2
      src/lib/stores/Issues.ts
  5. 4
      src/lib/wrappers/ComposeIssue.svelte

3
src/lib/components/events/content/IssuePreview.svelte

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
import { extractRepoAFromProposalEvent } from '$lib/stores/Proposals'
import type { NDKEvent } from '@nostr-dev-kit/ndk'
import { nip19 } from 'nostr-tools'
import { extractIssueTitle } from './utils'
export let event: NDKEvent
let nevent = nip19.neventEncode({
@ -17,5 +18,5 @@ @@ -17,5 +18,5 @@
<span>
Git Issue for <a class="opacity-50" href={`/e/${naddr}`}
>{pointer?.identifier}</a
>: <a href={`/e/${nevent}`}>{event.content?.split('\n')[0]}</a> by
>: <a href={`/e/${nevent}`}>{extractIssueTitle(event)}</a> by
</span>

6
src/lib/components/events/content/utils.ts

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
import type { NDKTag } from '@nostr-dev-kit/ndk'
import type { NDKEvent, NDKTag } from '@nostr-dev-kit/ndk'
import { nip19 } from 'nostr-tools'
import type { AddressPointer, EventPointer } from 'nostr-tools/nip19'
import last from 'ramda/src/last'
@ -307,8 +307,8 @@ export const extractPatchDescription = (s: string): string | undefined => { @@ -307,8 +307,8 @@ export const extractPatchDescription = (s: string): string | undefined => {
return msg.substring(i).trim()
}
export const extractIssueTitle = (s: string): string => {
return s.split('\n')[0] || ''
export const extractIssueTitle = (event: NDKEvent): string => {
return event.tagValue('subject') || event.content.split('\n')[0] || ''
}
export const extractIssueDescription = (s: string): string => {

2
src/lib/stores/Issue.ts

@ -80,7 +80,7 @@ export const ensureIssueFull = ( @@ -80,7 +80,7 @@ export const ensureIssueFull = (
issue_event: event,
summary: {
...full.summary,
title: extractIssueTitle(event.content),
title: extractIssueTitle(event),
descritpion: extractIssueDescription(event.content),
created_at: event.created_at,
comments: 0,

2
src/lib/stores/Issues.ts

@ -107,7 +107,7 @@ export const ensureIssueSummaries = async (repo_a: string | undefined) => { @@ -107,7 +107,7 @@ export const ensureIssueSummaries = async (repo_a: string | undefined) => {
id: event.id,
repo_a:
extractRepoIdentiferFromIssueEvent(event) || repo_a || '',
title: extractIssueTitle(event.content),
title: extractIssueTitle(event),
descritpion: extractIssueDescription(event.content),
created_at: event.created_at,
comments: 0,

4
src/lib/wrappers/ComposeIssue.svelte

@ -26,7 +26,7 @@ @@ -26,7 +26,7 @@
if (!$logged_in_user) return
let event = new NDKEvent(ndk)
event.kind = issue_kind
event.tags.push(['subject', title])
event.tags.push(['alt', `git repository issue: ${title}`])
if (repo_event.unique_commit) {
@ -39,7 +39,7 @@ @@ -39,7 +39,7 @@
'root',
])
repo_event.maintainers.forEach((m) => event.tags.push(['p', m]))
event.content = `${title}\n\n${content}`
event.content = `${content}`
submitting = true
let relays = [
...(repo_event.relays.length > 3

Loading…
Cancel
Save