Work on thread detail page

This commit is contained in:
Jon Staab
2024-10-23 14:20:24 -07:00
parent 8d0c016621
commit 09028b69a4
15 changed files with 300 additions and 134 deletions
+7 -24
View File
@@ -9,6 +9,7 @@
import ChannelMessage from "@app/components/ChannelMessage.svelte"
import ChannelCompose from "@app/components/ChannelCompose.svelte"
import {tagRoom, REPLY} from "@app/state"
import {publishReply} from "@app/commands"
export let url, room, event: TrustedEvent
@@ -19,30 +20,12 @@
})
const onSubmit = ({content, tags}: EventContent) => {
const seenRoots = new Set<string>()
for (const [raw, ...tag] of event.tags.filter(t => t[0].match(/^K|E|A|I$/i))) {
const T = raw.toUpperCase()
const t = raw.toLowerCase()
if (seenRoots.has(T)) {
tags.push([t, ...tag])
} else {
tags.push([T, ...tag])
seenRoots.add(T)
}
}
if (seenRoots.size === 0) {
tags.push(["K", String(event.kind)])
tags.push(["E", event.id])
} else {
tags.push(["k", String(event.kind)])
tags.push(["e", event.id])
}
const reply = createEvent(REPLY, {content, tags: append(tagRoom(room, url), tags)})
const thunk = publishThunk({event: reply, relays: [url]})
const thunk = publishReply({
event,
content,
tags: append(tagRoom(room, url), tags),
relays: [url],
})
thunks.update(assoc(thunk.event.id, thunk))
}