@ -8,11 +8,12 @@ import NoteToSelf from "Element/NoteToSelf";
|
||||
import useLogin from "Hooks/useLogin";
|
||||
import WriteMessage from "Element/WriteMessage";
|
||||
import { Chat, ChatType, useChatSystem } from "chat";
|
||||
import { Nip4ChatSystem } from "chat/nip4";
|
||||
|
||||
export default function DmWindow({ id }: { id: string }) {
|
||||
const pubKey = useLogin().publicKey;
|
||||
const dms = useChatSystem();
|
||||
const chat = dms.find(a => a.id === id);
|
||||
const chat = dms.find(a => a.id === id) ?? Nip4ChatSystem.createChatObj(id, []);
|
||||
|
||||
function sender() {
|
||||
if (id === pubKey) {
|
||||
@ -24,7 +25,7 @@ export default function DmWindow({ id }: { id: string }) {
|
||||
if (chat?.profile) {
|
||||
return <ProfileImage pubkey={id} className="f-grow mb10" profile={chat.profile} />;
|
||||
}
|
||||
return <ProfileImage pubkey={""} className="f-grow mb10" overrideUsername={chat?.id} />;
|
||||
return <ProfileImage pubkey={id ?? ""} className="f-grow mb10" overrideUsername={chat?.id} />;
|
||||
}
|
||||
|
||||
return (
|
||||
@ -34,7 +35,7 @@ export default function DmWindow({ id }: { id: string }) {
|
||||
<div className="flex f-col">{chat && <DmChatSelected chat={chat} />}</div>
|
||||
</div>
|
||||
<div>
|
||||
<WriteMessage chatId={id} />
|
||||
<WriteMessage chat={chat} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
@ -7,9 +7,9 @@ import useFileUpload from "Upload";
|
||||
import { openFile } from "SnortUtils";
|
||||
import Textarea from "./Textarea";
|
||||
import { System } from "index";
|
||||
import { useChatSystem } from "chat";
|
||||
import { Chat } from "chat";
|
||||
|
||||
export default function WriteMessage({ chatId }: { chatId: string }) {
|
||||
export default function WriteMessage({ chat }: { chat: Chat }) {
|
||||
const [msg, setMsg] = useState("");
|
||||
const [sending, setSending] = useState(false);
|
||||
const [uploading, setUploading] = useState(false);
|
||||
@ -17,7 +17,6 @@ export default function WriteMessage({ chatId }: { chatId: string }) {
|
||||
const [error, setError] = useState("");
|
||||
const publisher = useEventPublisher();
|
||||
const uploader = useFileUpload();
|
||||
const chat = useChatSystem().find(a => a.id === chatId);
|
||||
|
||||
async function attachFile() {
|
||||
try {
|
||||
|
Reference in New Issue
Block a user