diff --git a/src/app/components/SpaceAuthError.svelte b/src/app/components/SpaceAuthError.svelte index ebf02d1f..8a75cdca 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 82c2b53f..bd38759e 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 37548f12..00000000 --- a/src/app/components/SpaceVisitConfirm.svelte +++ /dev/null @@ -1,24 +0,0 @@ - - - - -