Add support for kind 30023

This commit is contained in:
Jonathan Staab 2023-06-19 05:46:14 -07:00
parent 41a08f7167
commit d2b82ec418
10 changed files with 71 additions and 11 deletions

1
.nvmrc Normal file
View File

@ -0,0 +1 @@
lts/hydrogen

View File

@ -1,5 +1,12 @@
# Changelog
# 0.2.33
- [x] Add rendering support for kind 1985 (labels and reviews)
- [x] Add rendering support for kind 9802 (highlights)
- [x] Add rendering support for kind 1063 (image header)
- [x] Add rendering support for kind 30023 (long form content)
# 0.2.32
- [x] Add note preview when composing

View File

@ -45,8 +45,10 @@
"fuse.js": "^6.6.2",
"hurdak": "github:ConsignCloud/hurdak",
"husky": "^8.0.3",
"insane": "^2.6.2",
"lokijs": "^1.5.12",
"lru-cache": "^7.18.3",
"marked": "^5.1.0",
"nostr-tools": "^1.7.4",
"npm-run-all": "^4.1.5",
"paravel": "^0.1.15",

View File

@ -4,7 +4,7 @@
import {pluck, omit, objOf} from "ramda"
import {debounce} from "throttle-debounce"
import {createLocalDate, formatTimestampAsDate} from "src/util/misc"
import {displayPerson} from "src/util/nostr"
import {displayPerson, noteKinds} from "src/util/nostr"
import Chip from "src/partials/Chip.svelte"
import Input from "src/partials/Input.svelte"
import Anchor from "src/partials/Anchor.svelte"
@ -66,7 +66,7 @@
}
const applyFilter = () => {
const newFilter = {} as DynamicFilter
const newFilter = {kinds: noteKinds} as DynamicFilter
if (_filter.since) {
newFilter.since = createLocalDate(_filter.since).setHours(23, 59, 59, 0) / 1000
@ -155,10 +155,10 @@
<slot name="controls" />
</div>
{#if parts.length > 0}
<div class="mr-2 mb-2 inline-block py-1">Showing notes:</div>
<div class="mb-2 mr-2 inline-block py-1">Showing notes:</div>
{/if}
{#each parts as { keys, label }}
<Chip class="mr-2 mb-2 inline-block" onClick={keys ? () => removePart(keys) : null}
<Chip class="mb-2 mr-2 inline-block" onClick={keys ? () => removePart(keys) : null}
>{label}</Chip>
{/each}
</div>

View File

@ -3,6 +3,7 @@
import NoteContentKind1985 from "src/app/shared/NoteContentKind1985.svelte"
import NoteContentKind9802 from "src/app/shared/NoteContentKind9802.svelte"
import NoteContentKind1063 from "src/app/shared/NoteContentKind1063.svelte"
import NoteContentKind30023 from "src/app/shared/NoteContentKind30023.svelte"
import user from "src/agent/user"
export let note
@ -18,6 +19,8 @@
<NoteContentKind9802 {note} {anchorId} {maxLength} {showEntire} {showMedia} />
{:else if note.kind === 1063}
<NoteContentKind1063 {note} {showMedia} />
{:else if note.kind === 30023}
<NoteContentKind30023 {note} {showEntire} {showMedia} />
{:else}
<NoteContentKind1 {note} {anchorId} {maxLength} {showEntire} {showMedia} />
{/if}

View File

@ -0,0 +1,44 @@
<script lang="ts">
import {marked} from 'marked'
import insane from 'insane'
import {Tags} from 'src/util/nostr'
import {canDisplayUrl} from 'src/util/notes'
import {modal} from "src/partials/state"
import Chip from 'src/partials/Chip.svelte'
import NoteContentLink from "src/app/shared/NoteContentLink.svelte"
export let note, showEntire
export let showMedia = false
const tags = Tags.from(note)
const {title, summary, image} = tags.asMeta()
const openTopic = topic => {
modal.push({type: "topic/feed", topic})
}
</script>
<div class="flex flex-col gap-2 overflow-hidden text-ellipsis">
<h3 class="text-2xl staatliches">{title}</h3>
{#if summary && !showEntire}
<p>{summary}</p>
{/if}
{#if showMedia && image && canDisplayUrl(image)}
<NoteContentLink value={{url: image, canDisplay: true}} showMedia />
{/if}
<div>
{#each tags.topics() as topic}
<Chip
class="mr-2 mb-2 inline-block cursor-pointer"
on:click={() => openTopic(topic)}>
#{topic}
</Chip>
{/each}
</div>
</div>
{#if showEntire}
<div class="flex flex-col gap-4 leading-6">
{@html insane(marked.parse(note.content))}
</div>
{/if}

View File

@ -10,7 +10,7 @@
})
</script>
<div class={className}>
<div class={className} on:click>
<div class="flex items-center gap-2 whitespace-nowrap">
{#if onClick}
<i class="fa fa-times cursor-pointer" on:click|preventDefault={onClick} />

View File

@ -5,8 +5,7 @@ import {ensurePlural, ellipsize, first} from "hurdak/lib/hurdak"
import {tryJson, avg} from "src/util/misc"
import {invoiceAmount} from "src/util/lightning"
export const noteKinds = [1, 1985, 30023, 30018, 10001, 1063, 9802]
// export const noteKinds = [1063]
export const noteKinds = [1, 1985, 30023, 1063, 9802]
export const personKinds = [0, 2, 3, 10001, 10002]
export const userKinds = personKinds.concat([10000, 30001, 30078])
export const appDataKeys = [
@ -47,6 +46,12 @@ export class Tags {
relays() {
return uniq(flatten(this.tags).filter(isShareableRelay)).map(objOf("url"))
}
topics() {
return this.type("t")
.values()
.all()
.map(t => t.replace(/^#/, ""))
}
pubkeys() {
return this.type("p").values().all()
}

View File

@ -1,4 +1,4 @@
import type {Event, Filter} from "nostr-tools"
import type {Event} from "nostr-tools"
export type Relay = {
url: string
@ -38,6 +38,4 @@ export type Room = {
picture?: string
}
export type DynamicFilter = Filter & {
authors?: string | string[]
} & Record<string, any>
export type DynamicFilter = Record<string, any>

BIN
yarn.lock Normal file

Binary file not shown.