GeezerVison is showing github.com — fix(mobile): cold-start PR links start on the Pulls list on Android · pingdotgg/t3code@2afaf60
File treeExpand file treeCollapse file tree Open diff view settings apps/mobile/src/features/layout
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx +2-5Lines changed: 2 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -112,7 +112,7 @@ import { | 112 | 112 | workspaceTabColumns, | 113 | 113 | workspaceTabNavigationState, | 114 | 114 | } from "./workspace/workspace-tab-navigation"; | 115 | | -import type { WorkspaceTab } from "./workspace/workspace-tabs-state"; | | 115 | +import { workspaceTabOf, type WorkspaceTab } from "./workspace/workspace-tabs-state"; | 116 | 116 | import { workspaceRoutesOf } from "./workspace-overlay-routes"; | 117 | 117 | import { SettingsWorkspaceLayout } from "../settings/SettingsWorkspaceLayout"; | 118 | 118 | import { WorkspaceThreadSidebar } from "./workspace/WorkspaceThreadSidebar"; | @@ -570,10 +570,7 @@ function AdaptiveWorkspaceLayoutContent( | 570 | 570 | setFileInspectorPreferredVisible(false); | 571 | 571 | setInspectorSheetRoute(null); | 572 | 572 | if (layout.variant === "medium") setPrimarySidebarVisible(false); | 573 | | - workspace?.dispatch({ | 574 | | - type: "select", | 575 | | - tab: detail.name === "Thread" ? "threads" : "pullRequests", | 576 | | - }); | | 573 | + workspace?.dispatch({ type: "select", tab: workspaceTabOf(detail.name) }); | 577 | 574 | startOpeningDetail(detail); | 578 | 575 | navigation.dispatch(selectWorkspaceDetail(detail, sheet)); | 579 | 576 | }); | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/layout/workspace/AndroidWorkspaceTabsProvider.tsx +5-1Lines changed: 5 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -3,6 +3,7 @@ import { createContext, use, type ReactNode } from "react"; | 3 | 3 | import { Platform } from "react-native"; | 4 | 4 | import { androidWorkspaceSettingsOpen } from "./android-workspace-tabs"; | 5 | 5 | import { WorkspaceTabsProvider } from "./WorkspaceTabsContext"; | | 6 | +import { workspaceTabOf } from "./workspace-tabs-state"; | 6 | 7 |
| 7 | 8 | interface AndroidWorkspaceRoot { | 8 | 9 | /** | @@ -35,7 +36,10 @@ export function AndroidWorkspaceTabsProvider(props: { | 35 | 36 | settingsIndex < 0 ? null : (props.state.routes[settingsIndex + 1]?.name ?? null); | 36 | 37 | const root = { key, settingsOpen, settingsRoute, settingsPage }; | 37 | 38 | return Platform.OS === "android" ? ( | 38 | | - <WorkspaceTabsProvider> | | 39 | + // A cold-start link lands on a page with no list selection; start on that page's list. | | 40 | + <WorkspaceTabsProvider | | 41 | + initialTab={workspaceTabOf(props.state.routes.find((route) => route.name !== "Home")?.name)} | | 42 | + > | 39 | 43 | <AndroidWorkspaceRootContext value={root}>{props.children}</AndroidWorkspaceRootContext> | 40 | 44 | </WorkspaceTabsProvider> | 41 | 45 | ) : ( | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/layout/workspace/WorkspaceTabsContext.tsx +4-3Lines changed: 4 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -52,8 +52,8 @@ function resolveWorkspaceTabsSelection( | 52 | 52 |
| 53 | 53 | // One model per provider. Handlers on frozen screens keep stale closures, so | 54 | 54 | // they read the current selection from the registry at call time. | 55 | | -function createWorkspaceTabsModel() { | 56 | | - const stored = Atom.make(initialWorkspaceTabsState()); | | 55 | +function createWorkspaceTabsModel(selectedTab?: WorkspaceTab) { | | 56 | + const stored = Atom.make(initialWorkspaceTabsState(selectedTab)); | 57 | 57 | const scrollOffsets: Record<WorkspaceSearchTab, number> = { | 58 | 58 | threads: 0, | 59 | 59 | pullRequests: 0, | @@ -75,9 +75,10 @@ function createWorkspaceTabsModel() { | 75 | 75 | export function WorkspaceTabsProvider(props: { | 76 | 76 | readonly children: ReactNode; | 77 | 77 | readonly settingsOpen?: boolean; | | 78 | + readonly initialTab?: WorkspaceTab; | 78 | 79 | }) { | 79 | 80 | const registry = use(RegistryContext); | 80 | | - const [model] = useState(createWorkspaceTabsModel); | | 81 | + const [model] = useState(() => createWorkspaceTabsModel(props.initialTab)); | 81 | 82 | const state = useAtomValue(model.resolved); | 82 | 83 | const context = { | 83 | 84 | state, | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/layout/workspace/workspace-tabs-state.ts +9-2Lines changed: 9 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -38,9 +38,16 @@ function emptyTab(): WorkspaceTabState { | 38 | 38 | return { query: "", searchMode: "resting", scrollOffset: 0, searchEntryOffset: 0 }; | 39 | 39 | } | 40 | 40 |
| 41 | | -export function initialWorkspaceTabsState(): WorkspaceTabsState { | | 41 | +/** The list a workspace page belongs to. */ | | 42 | +export function workspaceTabOf(routeName: string | undefined): WorkspaceTab { | | 43 | + return routeName === "PullRequest" ? "pullRequests" : "threads"; | | 44 | +} | | 45 | + | | 46 | +export function initialWorkspaceTabsState( | | 47 | + selectedTab: WorkspaceTab = "threads", | | 48 | +): WorkspaceTabsState { | 42 | 49 | return { | 43 | | - selectedTab: "threads", | | 50 | + selectedTab, | 44 | 51 | selectionRevision: 0, | 45 | 52 | tabs: { | 46 | 53 | threads: emptyTab(), | |
|