From c208e392ab206aee1717ffa08524613055a80a2c Mon Sep 17 00:00:00 2001 From: Mishig Date: Sat, 30 Dec 2023 22:39:47 +0100 Subject: [PATCH] Update share behaviour (#645) * Update share behaviour * Simplify * format * wording * lint --------- Co-authored-by: Victor Mustar Co-authored-by: Nathan Sarrazin --- src/lib/components/chat/ChatWindow.svelte | 38 ++++++++++++++++++++--- src/lib/shareConversation.ts | 4 +-- src/lib/utils/share.ts | 4 +-- 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/src/lib/components/chat/ChatWindow.svelte b/src/lib/components/chat/ChatWindow.svelte index 6b2b3d9b234..949602cf37d 100644 --- a/src/lib/components/chat/ChatWindow.svelte +++ b/src/lib/components/chat/ChatWindow.svelte @@ -1,11 +1,12 @@
@@ -226,12 +247,19 @@

{#if messages.length} {/if}
diff --git a/src/lib/shareConversation.ts b/src/lib/shareConversation.ts index 0086fcaf5d4..064a586a596 100644 --- a/src/lib/shareConversation.ts +++ b/src/lib/shareConversation.ts @@ -8,7 +8,7 @@ export async function shareConversation(id: string, title: string) { try { if (id.length === 7) { const url = get(page).url; - share(getShareUrl(url, id), title); + await share(getShareUrl(url, id), title); } else { const res = await fetch(`${base}/conversation/${id}/share`, { method: "POST", @@ -24,7 +24,7 @@ export async function shareConversation(id: string, title: string) { } const { url } = await res.json(); - share(url, title); + await share(url, title); } } catch (err) { error.set(ERROR_MESSAGES.default); diff --git a/src/lib/utils/share.ts b/src/lib/utils/share.ts index 4587669a101..f0ddb2f1191 100644 --- a/src/lib/utils/share.ts +++ b/src/lib/utils/share.ts @@ -1,7 +1,7 @@ -export function share(url: string, title: string) { +export async function share(url: string, title: string) { if (navigator.share) { navigator.share({ url, title }); } else { - prompt("Copy this public url to share:", url); + await navigator.clipboard.writeText(url); } }