Move connection check

This commit is contained in:
Jon Staab
2024-11-07 15:19:19 -08:00
parent ba54615a3f
commit 1b15767a17
2 changed files with 16 additions and 8 deletions

View File

@@ -22,9 +22,7 @@
roomsByUrl,
GENERAL,
} from "@app/state"
import {checkRelayConnection, checkRelayAuth} from "@app/commands"
import {pushModal} from "@app/modal"
import {pushToast} from "@app/toast"
import {makeSpacePath} from "@app/routes"
export let url
@@ -73,12 +71,6 @@
onMount(async () => {
replaceState = Boolean(element.closest(".drawer"))
const error = (await checkRelayConnection(url)) || (await checkRelayAuth(url))
if (error) {
pushToast({theme: "error", message: error})
}
})
</script>

View File

@@ -7,11 +7,27 @@
import Delay from "@lib/components/Delay.svelte"
import SecondaryNav from "@lib/components/SecondaryNav.svelte"
import MenuSpace from "@app/components/MenuSpace.svelte"
import {pushToast} from "@app/toast"
import {checkRelayConnection, checkRelayAuth} from "@app/commands"
import {decodeRelay, MEMBERSHIPS, THREAD, MESSAGE, COMMENT} from "@app/state"
$: url = decodeRelay($page.params.relay)
const ifLet = <T>(x: T | undefined, f: (x: T) => void) => x === undefined ? undefined : f(x)
const checkConnection = async () => {
ifLet(await checkRelayConnection(url), error => {
pushToast({theme: "error", message: error})
})
ifLet(await checkRelayAuth(url), error => {
pushToast({theme: "error", message: error})
})
}
onMount(() => {
checkConnection()
const sub = subscribe({
filters: [
{kinds: [DELETE], "#k": [THREAD, COMMENT, MESSAGE].map(String)},