Page titles (#16) #62

Merged
hodlbod merged 2 commits from feature/16-page-titles into dev 2026-02-17 20:39:08 +00:00
3 changed files with 16 additions and 25 deletions
Showing only changes of commit 275eb46565 - Show all commits
+9
View File
@@ -170,6 +170,15 @@ src/
- Do not define svelte event handlers inline, instead name them and put them in the script section of templates
- Avoid using `as`, except where necessary. Instead, annotate function parameters, and ensure upstream values are typed correctly.
**Human-First Simplicity (Jon Staab Style):**
- Prefer direct, readable code over layered abstractions.
- Do not add indirection (extra helpers, wrappers, stores, or derived state) unless it removes real repeated complexity.
- Reuse existing Welshman and Flotilla primitives before introducing new utilities or dependencies.
- Favor linear control flow and explicit naming over clever patterns.
- Remove defensive checks that do not apply in this runtime model.
- When two approaches work, pick the one that feels more human and easier to maintain.
## Common Tasks
### Adding a New Component
+6 -18
View File
@@ -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) => {
2
+1 -7
View File
@@ -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>
1