From c60d724aba3b1f82a9d5739ecb5c6e82becaa0a5 Mon Sep 17 00:00:00 2001 From: Julian Jelfs Date: Mon, 18 Sep 2023 15:45:32 +0100 Subject: [PATCH 01/12] some progress --- .../home/CryptoTransferBuilder.svelte | 2 +- .../src/components/home/CurrentChat.svelte | 30 ++- .../components/home/DraftMediaMessage.svelte | 15 +- .../app/src/components/home/Footer.svelte | 16 +- .../src/components/home/GiphySelector.svelte | 6 +- .../src/components/home/MemeBuilder.svelte | 2 +- .../src/components/home/MessageActions.svelte | 14 +- .../src/components/home/MessageEntry.svelte | 12 +- .../src/components/home/PollBuilder.svelte | 2 +- .../src/components/home/thread/Thread.svelte | 30 ++- frontend/openchat-client/src/openchat.ts | 208 ++++++++-------- frontend/openchat-client/src/stores/chat.ts | 14 +- .../src/stores/draftMessageFactory.ts | 19 +- frontend/openchat-client/src/utils/chat.ts | 41 +--- frontend/openchat-client/src/utils/media.ts | 3 +- .../openchat-client/src/utils/user.spec.ts | 4 +- .../openchat-shared/src/domain/chat/chat.ts | 35 +++ frontend/turbo.json | 232 +++++++++--------- 18 files changed, 356 insertions(+), 329 deletions(-) diff --git a/frontend/app/src/components/home/CryptoTransferBuilder.svelte b/frontend/app/src/components/home/CryptoTransferBuilder.svelte index 1ae6e8d669..4d3e535912 100644 --- a/frontend/app/src/components/home/CryptoTransferBuilder.svelte +++ b/frontend/app/src/components/home/CryptoTransferBuilder.svelte @@ -91,7 +91,7 @@ createdAtNanos: BigInt(Date.now()) * BigInt(1_000_000), }, }; - dispatch("sendTransfer", [content, undefined]); + dispatch("sendTransfer", content); lastCryptoSent.set(ledger); dispatch("close"); } diff --git a/frontend/app/src/components/home/CurrentChat.svelte b/frontend/app/src/components/home/CurrentChat.svelte index 99d28eb852..6f3d69bdd2 100644 --- a/frontend/app/src/components/home/CurrentChat.svelte +++ b/frontend/app/src/components/home/CurrentChat.svelte @@ -21,6 +21,7 @@ CommunityMap, type CommunitySummary, ICP_SYMBOL, + type AttachmentContent, } from "openchat-client"; import PollBuilder from "./PollBuilder.svelte"; import CryptoTransferBuilder from "./CryptoTransferBuilder.svelte"; @@ -60,7 +61,7 @@ $: currentChatTextContent = client.currentChatTextContent; $: currentChatReplyingTo = client.currentChatReplyingTo; $: currentChatPinnedMessages = client.currentChatPinnedMessages; - $: currentChatFileToAttach = client.currentChatFileToAttach; + $: currentChatAttachment = client.currentChatAttachment; $: currentChatEditingEvent = client.currentChatEditingEvent; $: currentChatDraftMessage = client.currentChatDraftMessage; $: lastCryptoSent = client.lastCryptoSent; @@ -143,7 +144,7 @@ }; } - function fileSelected(ev: CustomEvent) { + function fileSelected(ev: CustomEvent) { currentChatDraftMessage.setAttachment(chat.id, ev.detail); } @@ -193,7 +194,7 @@ .editMessageWithAttachment( chat.id, text, - $currentChatFileToAttach, + $currentChatAttachment, $currentChatEditingEvent ) .then((success) => { @@ -202,28 +203,33 @@ } }); } else { - sendMessageWithAttachment(text, mentioned, $currentChatFileToAttach); + sendMessageWithAttachment(text, mentioned, $currentChatAttachment); } } function sendMessageWithAttachment( textContent: string | undefined, mentioned: User[], - fileToAttach: MessageContent | undefined + attachment: AttachmentContent | undefined ) { client.sendMessageWithAttachment( - chat.id, + { chatId: chat.id }, events, textContent, mentioned, - fileToAttach, - $currentChatReplyingTo, - undefined + attachment, + $currentChatReplyingTo ); } - export function sendMessageWithContent(ev: CustomEvent<[MessageContent, string | undefined]>) { - sendMessageWithAttachment(ev.detail[1], [], ev.detail[0]); + export function sendMessageWithContent(ev: CustomEvent) { + client.sendMessageWithContent( + { chatId: chat.id }, + events, + [], + ev.detail, + $currentChatReplyingTo + ); } function forwardMessage(msg: Message) { @@ -332,7 +338,7 @@ {#if showFooter}