2024-08-09 00:22:17 +00:00
|
|
|
<script lang="ts">
|
2024-08-16 22:17:30 +00:00
|
|
|
import {displayRelayUrl} from "@welshman/util"
|
2024-08-16 17:50:38 +00:00
|
|
|
import Spinner from "@lib/components/Spinner.svelte"
|
2024-08-09 23:22:09 +00:00
|
|
|
import Button from "@lib/components/Button.svelte"
|
2024-08-16 17:50:38 +00:00
|
|
|
import Icon from "@lib/components/Icon.svelte"
|
2024-10-09 23:11:23 +00:00
|
|
|
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
2024-10-10 21:33:50 +00:00
|
|
|
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
2024-10-15 22:52:30 +00:00
|
|
|
import {clearModals} from "@app/modal"
|
2024-09-11 17:48:34 +00:00
|
|
|
import {addSpaceMembership} from "@app/commands"
|
2024-08-09 00:22:17 +00:00
|
|
|
|
2024-09-11 17:48:34 +00:00
|
|
|
export let url
|
2024-08-15 19:08:07 +00:00
|
|
|
|
2024-08-16 19:42:00 +00:00
|
|
|
const back = () => history.back()
|
2024-08-15 19:08:07 +00:00
|
|
|
|
2024-08-23 20:33:36 +00:00
|
|
|
const tryJoin = async () => {
|
2024-10-17 19:08:19 +00:00
|
|
|
await addSpaceMembership(url)
|
2024-08-23 20:33:36 +00:00
|
|
|
|
2024-10-15 22:52:30 +00:00
|
|
|
clearModals()
|
2024-08-23 20:33:36 +00:00
|
|
|
}
|
|
|
|
|
|
2024-08-09 23:22:09 +00:00
|
|
|
const join = async () => {
|
|
|
|
|
loading = true
|
|
|
|
|
|
|
|
|
|
try {
|
2024-08-23 20:33:36 +00:00
|
|
|
await tryJoin()
|
2024-10-11 20:02:48 +00:00
|
|
|
} catch (e) {
|
2024-08-09 23:22:09 +00:00
|
|
|
loading = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let loading = false
|
2024-08-09 00:22:17 +00:00
|
|
|
</script>
|
|
|
|
|
|
2024-08-09 23:22:09 +00:00
|
|
|
<form class="column gap-4" on:submit|preventDefault={join}>
|
2024-10-09 23:11:23 +00:00
|
|
|
<ModalHeader>
|
|
|
|
|
<div slot="title">
|
|
|
|
|
Joining <span class="text-primary">{displayRelayUrl(url)}</span>
|
|
|
|
|
</div>
|
2024-10-09 23:15:09 +00:00
|
|
|
<div slot="info">Are you sure you'd like to join this space?</div>
|
2024-10-09 23:11:23 +00:00
|
|
|
</ModalHeader>
|
2024-10-10 21:33:50 +00:00
|
|
|
<ModalFooter>
|
2024-08-09 23:22:09 +00:00
|
|
|
<Button class="btn btn-link" on:click={back}>
|
2024-08-09 00:22:17 +00:00
|
|
|
<Icon icon="alt-arrow-left" />
|
|
|
|
|
Go back
|
2024-08-09 23:22:09 +00:00
|
|
|
</Button>
|
2024-09-11 17:48:34 +00:00
|
|
|
<Button type="submit" class="btn btn-primary" disabled={loading}>
|
2024-08-14 00:58:26 +00:00
|
|
|
<Spinner {loading}>Join Space</Spinner>
|
2024-08-09 23:22:09 +00:00
|
|
|
<Icon icon="alt-arrow-right" />
|
|
|
|
|
</Button>
|
2024-10-10 21:33:50 +00:00
|
|
|
</ModalFooter>
|
2024-08-09 23:22:09 +00:00
|
|
|
</form>
|