From 50c1841a06d0502428f70bb0bb225cca70f82c20 Mon Sep 17 00:00:00 2001 From: LW Date: Tue, 16 May 2023 11:13:05 -0700 Subject: feat: Update HTML `title` on web #626 #599 (#655) For any `Screen` that shows on desktop, `title` is "(1) ... - Bluesky" where "(1)" is the unread notification count. The titles are unlocalized and the string "Bluesky" is hardcoded, following the pattern of the rest of the app. Display names and post content are loaded into the title as effects. Tested: * all screens * screen changes / component mounts/unmounts * long posts with links and images * display name set/unset * spamming myself with notifications, clearing notifications * /profile/did:... links * lint (only my changed files), jest, e2e. New utilities: `useUnreadCountLabel`, `bskyTitle`, `combinedDisplayName`, `useSetTitle`. resolves: #626 #599 --- src/lib/strings/display-names.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/lib/strings/display-names.ts') diff --git a/src/lib/strings/display-names.ts b/src/lib/strings/display-names.ts index 555151b55..b98153732 100644 --- a/src/lib/strings/display-names.ts +++ b/src/lib/strings/display-names.ts @@ -10,3 +10,18 @@ export function sanitizeDisplayName(str: string): string { } return '' } + +export function combinedDisplayName({ + handle, + displayName, +}: { + handle?: string + displayName?: string +}): string { + if (!handle) { + return '' + } + return displayName + ? `${sanitizeDisplayName(displayName)} (@${handle})` + : `@${handle}` +} -- cgit 1.4.1