From 57348472f86e50ca8f7d2bfa9d0c16087098899f Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Wed, 5 Nov 2025 15:09:23 -0800 Subject: [PATCH] Always join spaces when visiting them --- src/app/components/SpaceAuthError.svelte | 30 ++++++++++++++++++--- src/app/components/SpaceCheck.svelte | 17 +++++++----- src/app/components/SpaceVisitConfirm.svelte | 24 ----------------- 3 files changed, 37 insertions(+), 34 deletions(-) delete mode 100644 src/app/components/SpaceVisitConfirm.svelte diff --git a/src/app/components/SpaceAuthError.svelte b/src/app/components/SpaceAuthError.svelte index ebf02d1f6..8a75cdcad 100644 --- a/src/app/components/SpaceAuthError.svelte +++ b/src/app/components/SpaceAuthError.svelte @@ -12,12 +12,29 @@ import ModalFooter from "@lib/components/ModalFooter.svelte" import SpaceAccessRequest from "@app/components/SpaceAccessRequest.svelte" import {pushModal} from "@app/util/modal" + import {removeSpaceMembership, publishLeaveRequest, removeTrustedRelay} from "@app/core/commands" const {url, error} = $props() const back = () => goto("/home") const requestAccess = () => pushModal(SpaceAccessRequest, {url}) + + const leaveSpace = async () => { + loading = true + + try { + await removeSpaceMembership(url) + await publishLeaveRequest({url}) + await removeTrustedRelay(url) + } finally { + loading = false + } + + goto("/home") + } + + let loading = $state(false)
@@ -40,9 +57,14 @@ Go Home - +
+ + +
diff --git a/src/app/components/SpaceCheck.svelte b/src/app/components/SpaceCheck.svelte index 82c2b53f0..bd38759ed 100644 --- a/src/app/components/SpaceCheck.svelte +++ b/src/app/components/SpaceCheck.svelte @@ -10,19 +10,24 @@ import Button from "@lib/components/Button.svelte" import ModalHeader from "@lib/components/ModalHeader.svelte" import ModalFooter from "@lib/components/ModalFooter.svelte" - import SpaceVisitConfirm, {confirmSpaceVisit} from "@app/components/SpaceVisitConfirm.svelte" + import SpaceJoinConfirm, {confirmSpaceJoin} from "@app/components/SpaceJoinConfirm.svelte" import {attemptRelayAccess} from "@app/core/commands" import {pushModal} from "@app/util/modal" + import {pushToast} from "@app/util/toast" const {url} = $props() const back = () => history.back() - const next = () => { - if (!error && Pool.get().get(url).auth.status === AuthStatus.None) { - pushModal(SpaceVisitConfirm, {url}, {replaceState: true}) + const next = async () => { + if (error) { + return pushToast({theme: "error", message: error, timeout: 30_000}) + } + + if (Pool.get().get(url).auth.status === AuthStatus.None) { + pushModal(SpaceJoinConfirm, {url}, {replaceState: true}) } else { - confirmSpaceVisit(url) + await confirmSpaceJoin(url) } } @@ -72,7 +77,7 @@ Go back diff --git a/src/app/components/SpaceVisitConfirm.svelte b/src/app/components/SpaceVisitConfirm.svelte deleted file mode 100644 index 37548f126..000000000 --- a/src/app/components/SpaceVisitConfirm.svelte +++ /dev/null @@ -1,24 +0,0 @@ - - - - -