Move page title logic to util

This commit is contained in:
2026-02-17 19:04:38 +00:00
parent 6e865fef06
commit 0b887d62f6
2 changed files with 166 additions and 0 deletions
+12
View File
@@ -7,6 +7,7 @@
import {App, type URLOpenListenerEvent} from "@capacitor/app"
import {dev} from "$app/environment"
import {goto} from "$app/navigation"
import {page} from "$app/stores"
import {sync, throttled} from "@welshman/store"
import {call} from "@welshman/lib"
import {defaultSocketPolicies} from "@welshman/net"
@@ -42,10 +43,15 @@
import * as notifications from "@app/util/notifications"
import * as storage from "@app/util/storage"
import {syncKeyboard} from "@app/util/keyboard"
import {getPageTitle} from "@app/util/title"
import NewNotificationSound from "@src/app/components/NewNotificationSound.svelte"
const {children} = $props()
const pageTitle = $derived.by(() => {
return getPageTitle({page: $page, pubkey: $pubkey})
})
const policies = [authPolicy, blockPolicy, trustPolicy, mostlyRestrictedPolicy]
// Add stuff to window for convenience
@@ -199,6 +205,12 @@
App.removeAllListeners()
unsubscribe.then(call)
})
$effect(() => {
if (typeof document !== "undefined") {
document.title = pageTitle
}
})
</script>
<svelte:head>