From aec323e2c4aa6f03e089ddf541c9ffa29c7da108 Mon Sep 17 00:00:00 2001 From: Flemmli97 Date: Mon, 14 Oct 2024 14:51:27 +0200 Subject: [PATCH 1/4] impl file sharing chat --- src/lib/components/files/ShareFile.svelte | 128 ++++++++++++++++++ .../components/messaging/ChatPreview.svelte | 15 +- .../messaging/embeds/FileEmbed.svelte | 11 +- src/routes/chat/+page.svelte | 23 +++- 4 files changed, 171 insertions(+), 6 deletions(-) create mode 100644 src/lib/components/files/ShareFile.svelte diff --git a/src/lib/components/files/ShareFile.svelte b/src/lib/components/files/ShareFile.svelte new file mode 100644 index 000000000..36e385db9 --- /dev/null +++ b/src/lib/components/files/ShareFile.svelte @@ -0,0 +1,128 @@ + + +
+ +
+ +
+ {#each $chats as chat} + + {/each} +
+
+
+ + diff --git a/src/lib/components/messaging/ChatPreview.svelte b/src/lib/components/messaging/ChatPreview.svelte index cf6235a0a..877e2caef 100644 --- a/src/lib/components/messaging/ChatPreview.svelte +++ b/src/lib/components/messaging/ChatPreview.svelte @@ -19,6 +19,7 @@ export let chat: Chat export let cta: boolean = false export let loading: boolean + export let interactable: boolean = true const timeAgo = new TimeAgo("en-US") @@ -69,13 +70,20 @@ timeago = getTimeAgo(chat.last_message_at) }, 500) }) + + function getClass() { + if (!interactable) return "" + return `${cta ? "cta" : ""} ${get(Store.state.activeChat)?.id === chat.id ? "active-chat" : ""}` + } - + --> diff --git a/src/routes/chat/+page.svelte b/src/routes/chat/+page.svelte index 65983103b..8604e74a3 100644 --- a/src/routes/chat/+page.svelte +++ b/src/routes/chat/+page.svelte @@ -55,6 +55,7 @@ import { tempCDN } from "$lib/utils/CommonVariables" import { checkMobile } from "$lib/utils/Mobile" import BrowseFiles from "../files/BrowseFiles.svelte" + import ShareFile from "$lib/components/files/ShareFile.svelte" let loading = false let contentAsideOpen = false @@ -98,6 +99,8 @@ let reactingTo: string | undefined let fileUpload: FileInput + let fileToShare: [Attachment, string] | undefined + $: chats = UIStore.state.chats $: pendingMessages = derived(ConversationStore.getPendingMessages($activeChat), msg => Object.values(msg)) @@ -418,6 +421,23 @@ }} /> {/if} + {#if fileToShare} + { + fileToShare = undefined + }}> + { + fileToShare = undefined + }} /> + + {/if} + {#if dragging_files > 0}
@@ -703,7 +723,8 @@ type: "unknown/unknown", remotePath: "", }} - on:download={_ => download_attachment(message.id, attachment)} /> + on:download={_ => download_attachment(message.id, attachment)} + on:share={_ => (fileToShare = [attachment, $activeChat.id])} /> {:else if attachment.kind === MessageAttachmentKind.Image} Date: Mon, 14 Oct 2024 14:56:51 +0200 Subject: [PATCH 2/4] lang --- src/lib/components/files/ShareFile.svelte | 4 ++-- src/lib/lang/en.json | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/components/files/ShareFile.svelte b/src/lib/components/files/ShareFile.svelte index 36e385db9..5f6308b7c 100644 --- a/src/lib/components/files/ShareFile.svelte +++ b/src/lib/components/files/ShareFile.svelte @@ -55,12 +55,12 @@