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/Navigation.tsx | 133 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 112 insertions(+), 21 deletions(-) (limited to 'src/Navigation.tsx') diff --git a/src/Navigation.tsx b/src/Navigation.tsx index 4e0403be9..17bb3c159 100644 --- a/src/Navigation.tsx +++ b/src/Navigation.tsx @@ -28,6 +28,7 @@ import {isNative} from 'platform/detection' import {useColorSchemeStyle} from 'lib/hooks/useColorSchemeStyle' import {router} from './routes' import {usePalette} from 'lib/hooks/usePalette' +import {useUnreadCountLabel} from 'lib/hooks/useUnreadCountLabel' import {useStores} from './state' import {HomeScreen} from './view/screens/Home' @@ -55,6 +56,7 @@ import {AppPasswords} from 'view/screens/AppPasswords' import {ModerationMutedAccounts} from 'view/screens/ModerationMutedAccounts' import {ModerationBlockedAccounts} from 'view/screens/ModerationBlockedAccounts' import {getRoutingInstrumentation} from 'lib/sentry' +import {bskyTitle} from 'lib/strings/headings' const navigationRef = createNavigationContainerRef() @@ -69,45 +71,120 @@ const Tab = createBottomTabNavigator() /** * These "common screens" are reused across stacks. */ -function commonScreens(Stack: typeof HomeTab) { +function commonScreens(Stack: typeof HomeTab, unreadCountLabel?: string) { + const title = (page: string) => bskyTitle(page, unreadCountLabel) + return ( <> - - + + + + ({title: title(`@${route.params.name}`)})} /> - - ({ + title: title(`People following @${route.params.name}`), + })} + /> + ({ + title: title(`People followed by @${route.params.name}`), + })} + /> + + ({title: title(`Post by @${route.params.name}`)})} + /> + ({title: title(`Post by @${route.params.name}`)})} + /> + ({title: title(`Post by @${route.params.name}`)})} + /> + + + + + - - - - - - - - - - + + - - ) } @@ -221,6 +298,8 @@ const MyProfileTabNavigator = observer(() => { */ function FlatNavigator() { const pal = usePalette('default') + const unreadCountLabel = useUnreadCountLabel() + const title = (page: string) => bskyTitle(page, unreadCountLabel) return ( - - - - {commonScreens(Flat as typeof HomeTab)} + + + + {commonScreens(Flat as typeof HomeTab, unreadCountLabel)} ) } -- cgit 1.4.1