2024-08-16 19:42:00 +00:00
|
|
|
<script lang="ts">
|
2025-05-20 16:35:33 +00:00
|
|
|
import type {Snippet} from "svelte"
|
2024-08-16 22:17:30 +00:00
|
|
|
import {page} from "$app/stores"
|
2025-10-22 15:35:42 +00:00
|
|
|
import {once} from "@welshman/lib"
|
2024-08-16 19:42:00 +00:00
|
|
|
import Page from "@lib/components/Page.svelte"
|
|
|
|
|
import SecondaryNav from "@lib/components/SecondaryNav.svelte"
|
2025-11-13 18:36:28 +00:00
|
|
|
import SpaceMenu from "@app/components/SpaceMenu.svelte"
|
2024-11-19 04:31:17 +00:00
|
|
|
import SpaceAuthError from "@app/components/SpaceAuthError.svelte"
|
2025-09-03 16:02:54 +00:00
|
|
|
import SpaceTrustRelay from "@app/components/SpaceTrustRelay.svelte"
|
2025-08-21 22:01:31 +00:00
|
|
|
import {pushModal} from "@app/util/modal"
|
|
|
|
|
import {setChecked} from "@app/util/notifications"
|
2025-10-22 15:35:42 +00:00
|
|
|
import {decodeRelay, deriveRelayAuthError, relaysPendingTrust} from "@app/core/state"
|
2025-08-21 22:01:31 +00:00
|
|
|
import {notifications} from "@app/util/notifications"
|
2025-05-20 16:35:33 +00:00
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
children?: Snippet
|
2025-02-04 00:37:14 +00:00
|
|
|
}
|
|
|
|
|
|
2025-02-04 01:21:46 +00:00
|
|
|
const {children}: Props = $props()
|
2024-08-16 19:42:00 +00:00
|
|
|
|
2025-10-13 20:35:02 +00:00
|
|
|
const url = decodeRelay($page.params.relay!)
|
2024-11-14 20:16:44 +00:00
|
|
|
|
2025-09-03 22:29:57 +00:00
|
|
|
const authError = deriveRelayAuthError(url)
|
2024-11-19 04:31:17 +00:00
|
|
|
|
2025-11-05 00:14:32 +00:00
|
|
|
const showAuthError = once(() =>
|
|
|
|
|
pushModal(SpaceAuthError, {url, error: $authError}, {noEscape: true}),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const showPendingTrust = once(() => pushModal(SpaceTrustRelay, {url}, {noEscape: true}))
|
2024-11-07 23:19:19 +00:00
|
|
|
|
2024-12-11 22:10:20 +00:00
|
|
|
// We have to watch this one, since on mobile the badge will be visible when active
|
2025-02-04 03:28:29 +00:00
|
|
|
$effect(() => {
|
2024-12-16 19:24:10 +00:00
|
|
|
if ($notifications.has($page.url.pathname)) {
|
2024-11-14 20:16:44 +00:00
|
|
|
setChecked($page.url.pathname)
|
|
|
|
|
}
|
2025-02-04 00:37:14 +00:00
|
|
|
})
|
2024-11-14 20:16:44 +00:00
|
|
|
|
2025-09-03 22:29:57 +00:00
|
|
|
// Watch for relay errors and notify the user
|
|
|
|
|
$effect(() => {
|
|
|
|
|
if ($authError) {
|
|
|
|
|
showAuthError()
|
2025-11-05 00:14:32 +00:00
|
|
|
} else if ($relaysPendingTrust.includes(url)) {
|
|
|
|
|
showPendingTrust()
|
2025-09-03 22:29:57 +00:00
|
|
|
}
|
|
|
|
|
})
|
2024-08-16 19:42:00 +00:00
|
|
|
</script>
|
|
|
|
|
|
2024-11-14 20:16:44 +00:00
|
|
|
<SecondaryNav>
|
2025-11-13 18:36:28 +00:00
|
|
|
<SpaceMenu {url} />
|
2024-11-14 20:16:44 +00:00
|
|
|
</SecondaryNav>
|
|
|
|
|
<Page>
|
2024-11-20 16:53:12 +00:00
|
|
|
{#key $page.url.pathname}
|
2025-02-04 00:37:14 +00:00
|
|
|
{@render children?.()}
|
2024-11-20 16:53:12 +00:00
|
|
|
{/key}
|
2024-11-14 20:16:44 +00:00
|
|
|
</Page>
|