forked from coracle/flotilla
Simplify page title logic per review
This commit is contained in:
+6
-18
@@ -1,13 +1,7 @@
|
||||
import {append, identity, uniq} from "@welshman/lib"
|
||||
import {displayPubkey, getTagValue, type Filter, type TrustedEvent} from "@welshman/util"
|
||||
import {
|
||||
PLATFORM_NAME,
|
||||
decodeRelay,
|
||||
getEventsForUrl,
|
||||
getRoom,
|
||||
makeRoomId,
|
||||
splitChatId,
|
||||
} from "@app/core/state"
|
||||
import {repository} from "@welshman/app"
|
||||
import {displayPubkey, getTagValue} from "@welshman/util"
|
||||
import {PLATFORM_NAME, decodeRelay, getRoom, makeRoomId, splitChatId} from "@app/core/state"
|
||||
|
||||
const FALLBACK_APP_NAME = "Flotilla"
|
||||
|
||||
@@ -69,10 +63,8 @@ const getRoomTitle = (params: RouteParams) => {
|
||||
return getRoom(makeRoomId(url, h))?.name || "Room"
|
||||
}
|
||||
|
||||
const getEventForTitle = (routeId: string, params: RouteParams): TrustedEvent | undefined => {
|
||||
const relay = params.relay
|
||||
|
||||
if (!relay || !eventRoutes.has(routeId)) {
|
||||
const getEventForTitle = (routeId: string, params: RouteParams) => {
|
||||
if (!eventRoutes.has(routeId)) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -82,11 +74,7 @@ const getEventForTitle = (routeId: string, params: RouteParams): TrustedEvent |
|
||||
return
|
||||
}
|
||||
|
||||
const url = decodeRelay(relay)
|
||||
const filters: Filter[] = [{ids: [eventId], limit: 1}]
|
||||
const events = Array.from(getEventsForUrl(url, filters))
|
||||
|
||||
return events[0]
|
||||
return repository.getEvent(eventId)
|
||||
}
|
||||
|
||||
const getChatTitle = (chatId: string | undefined, pubkey: string | undefined) => {
|
||||
|
||||
@@ -48,10 +48,6 @@
|
||||
|
||||
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
|
||||
@@ -207,9 +203,7 @@
|
||||
})
|
||||
|
||||
$effect(() => {
|
||||
if (typeof document !== "undefined") {
|
||||
document.title = pageTitle
|
||||
}
|
||||
document.title = getPageTitle({page: $page, pubkey: $pubkey})
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user