mirror of
https://github.com/coracle-social/flotilla.git
synced 2025-12-10 10:57:04 +00:00
Move connection check
This commit is contained in:
@@ -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>
|
||||
|
||||
|
||||
@@ -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)},
|
||||
|
||||
Reference in New Issue
Block a user