From 9fa1375435e7d6411313cc20b2d2d51c791a2c43 Mon Sep 17 00:00:00 2001 From: Saksham Jain Date: Tue, 14 Apr 2026 23:05:49 +0530 Subject: [PATCH] fix: handle unsupported Share API gracefully --- src/app/components/SpaceInvite.svelte | 32 +++++++++++++++++++++------ 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/app/components/SpaceInvite.svelte b/src/app/components/SpaceInvite.svelte index c4186372..d332ab13 100644 --- a/src/app/components/SpaceInvite.svelte +++ b/src/app/components/SpaceInvite.svelte @@ -30,8 +30,17 @@ const copyInvite = () => clip(invite) - const shareInvite = () => Share.share({url: invite}) + const shareInvite = async () => { + if (!canShare) return + try { + await Share.share({url: invite}) + } catch (e) { + console.error(e) + } +} + + let canShare = $state(false) let claim = $state("") let loading = $state(true) @@ -45,6 +54,13 @@ }) onMount(async () => { + try { + const {value} = await Share.canShare() + canShare = value + } catch { + canShare = false + } + const [[event]] = await Promise.all([ request({ relays: [url], @@ -84,12 +100,14 @@ {#snippet input()}
- + {#if canShare} + + {/if}