/** @jsx h */ import { Component, h, VNode } from "https://esm.sh/preact@10.17.1"; import { PublicKey } from "../../libs/nostr.ts/key.ts"; import { NostrAccountContext } from "../../libs/nostr.ts/nostr.ts"; import { RelayRecordGetter } from "../database.ts"; import { EventBus } from "../event-bus.ts"; import { ChatMessagesGetter, UI_Interaction_Event, UserBlocker } from "./app_update.tsx"; import { IconButtonClass } from "./components/tw.ts"; import { LeftArrowIcon } from "./icons/left-arrow-icon.tsx"; import { MessagePanel_V0 } from "./message-panel.tsx"; import { ProfileGetter } from "./search.tsx"; import { ConversationList, ConversationListRetriever, NewMessageChecker, PinListGetter, } from "./conversation-list.tsx"; import { func_GetEventByID } from "./message-list.tsx"; import { ProfileCard } from "./profile-card.tsx"; export type DM_Model = { currentConversation: PublicKey | undefined; }; type DirectMessageContainerProps = { ctx: NostrAccountContext; bus: EventBus; getters: { profileGetter: ProfileGetter; messageGetter: ChatMessagesGetter; pinListGetter: PinListGetter; convoListRetriever: ConversationListRetriever; newMessageChecker: NewMessageChecker; relayRecordGetter: RelayRecordGetter; isUserBlocked: (pubkey: PublicKey) => boolean; getEventByID: func_GetEventByID; }; userBlocker: UserBlocker; } & DM_Model; export type StartInvite = { type: "StartInvite"; publicKey: PublicKey; }; export class DirectMessageContainer extends Component { render(props: DirectMessageContainerProps) { const t = Date.now(); console.log(DirectMessageContainer.name, "?"); const vDom = (
{this.props.currentConversation ? (
) : undefined}
); console.debug("DirectMessageContainer:end", Date.now() - t); return vDom; } } function TopBar(props: { bus: EventBus; currentConversation: PublicKey; profileGetter: ProfileGetter; buttons: VNode[]; }) { const conversation_profile = props.profileGetter.getProfilesByPublicKey( props.currentConversation, ); let conversation_name = conversation_profile?.profile.name || conversation_profile?.profile.display_name || props.currentConversation.bech32(); return (
{ if (!props.currentConversation) { return; } props.bus.emit({ type: "ViewUserDetail", pubkey: props.currentConversation, }); }} > {conversation_name}
{props.buttons}
); }