render nip19 nevent (#309)

This commit is contained in:
Bullish Bear 2023-11-20 17:19:17 +08:00 committed by GitHub
parent 6969b847bd
commit 9367d2ba5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,6 +27,7 @@ import { SelectConversation } from "./search_model.ts";
import { AboutIcon } from "./icons/about-icon.tsx"; import { AboutIcon } from "./icons/about-icon.tsx";
import { CloseIcon } from "./icons/close-icon.tsx"; import { CloseIcon } from "./icons/close-icon.tsx";
import { LeftArrowIcon } from "./icons/left-arrow-icon.tsx"; import { LeftArrowIcon } from "./icons/left-arrow-icon.tsx";
import { NoteID } from "../lib/nostr-ts/nip19.ts";
import { ChatMessagesGetter } from "./app_update.tsx"; import { ChatMessagesGetter } from "./app_update.tsx";
export type RightPanelModel = { export type RightPanelModel = {
@ -354,14 +355,14 @@ function MessageBoxGroup(props: {
<pre <pre
class={tw`text-[#DCDDDE] whitespace-pre-wrap break-words font-roboto text-sm`} class={tw`text-[#DCDDDE] whitespace-pre-wrap break-words font-roboto text-sm`}
> >
{ParseMessageContent( {ParseMessageContent(
first_group, first_group,
props.authorProfile, props.authorProfile,
props.profilesSyncer, props.profilesSyncer,
props.eventSyncer, props.eventSyncer,
props.emit, props.emit,
props.profileGetter, props.profileGetter,
)} )}
</pre> </pre>
</div> </div>
</li>, </li>,
@ -551,6 +552,17 @@ export function ParseMessageContent(
vnode.push(Card(event, profile ? profile.profile : undefined, emit)); vnode.push(Card(event, profile ? profile.profile : undefined, emit));
} }
break; break;
case "nevent": {
const event = eventSyncer.syncEvent(NoteID.FromString(item.event.pointer.id));
if (
event instanceof Promise || event.kind == NostrKind.DIRECT_MESSAGE
) {
vnode.push(itemStr);
break;
}
const profile = profileGetter.getProfilesByPublicKey(event.publicKey);
vnode.push(Card(event, profile ? profile.profile : undefined, emit));
}
case "tag": case "tag":
// todo // todo
break; break;