TypeScript
fix(mobile): opening another stack layer no longer shows the previous PR (#24730)
Victor Vogel1a93920deafd
diff --git a/apps/mobile/src/features/pull-requests/PullRequestStackCard.tsx b/apps/mobile/src/features/pull-requests/PullRequestStackCard.tsxindex b2f51a9bd0a..cbb751c74c4 100644--- a/apps/mobile/src/features/pull-requests/PullRequestStackCard.tsx+++ b/apps/mobile/src/features/pull-requests/PullRequestStackCard.tsx@@ -4,6 +4,7 @@ import { Platform, View } from "react-native";import { useSelectWorkspaceDetail } from "../workspace/useSelectWorkspaceDetail";import { AppText as Text } from "../../components/ui/AppText";import { PullRequestCardGroup, PullRequestCardRow } from "./PullRequestControls";+import { pullRequestLayerParams } from "./pullRequestStack";import { pullRequestStatus } from "./pullRequestStatus";import type { PullRequestParams } from "./usePullRequestDiff";import type { PullRequestStackState } from "./usePullRequestStack";@@ -66,7 +67,7 @@ export function PullRequestStackCard(props: {selected? undefined: () => {- const params = { ...props.params, number: layer.number };+ const params = pullRequestLayerParams(props.params, layer.number);if (Platform.OS === "android")selectDetail({ name: "PullRequest", params });else navigation.dispatch(StackActions.push("PullRequest", params));diff --git a/apps/mobile/src/features/pull-requests/pullRequestStack.test.ts b/apps/mobile/src/features/pull-requests/pullRequestStack.test.tsindex bc91b36a54a..2a2fc9d87cd 100644--- a/apps/mobile/src/features/pull-requests/pullRequestStack.test.ts+++ b/apps/mobile/src/features/pull-requests/pullRequestStack.test.ts@@ -2,6 +2,7 @@ import { sourceControlClients } from "@t3tools/client-runtime/source-control-cliimport { ProjectId, type PullRequestStack, type ThreadPullRequestLink } from "@t3tools/contracts";import { describe, expect, it } from "vite-plus/test";import {+ pullRequestLayerParams,pullRequestStackMerge,savedPullRequestStack,singlePullRequestMergeAllowed,@@ -124,6 +125,26 @@ describe("mobile stack merge scope", () => {});});+describe("mobile stack layer navigation", () => {+ it("opens another layer without the summary of the layer it came from", () => {+ const route = {+ environmentId: "environment",+ projectId: "project",+ repository: "acme/web",+ host: "github.com",+ number: 2,+ initialSummary: { number: 2, url: "https://github.com/acme/web/pull/2" },+ };+ expect(pullRequestLayerParams(route, 3)).toEqual({+ environmentId: "environment",+ projectId: "project",+ repository: "acme/web",+ host: "github.com",+ number: 3,+ });+ });+});+describe("mobile saved stack navigation", () => {it("keeps all saved layers and enriches titles without carrying action revisions", () => {const saved = savedPullRequestStack([link], reference);diff --git a/apps/mobile/src/features/pull-requests/pullRequestStack.ts b/apps/mobile/src/features/pull-requests/pullRequestStack.tsindex d6b06e6a4dd..eb8e3736ec9 100644--- a/apps/mobile/src/features/pull-requests/pullRequestStack.ts+++ b/apps/mobile/src/features/pull-requests/pullRequestStack.ts@@ -67,6 +67,15 @@ export function savedPullRequestStack(};}+/** The list summary describes the layer it was opened from, so another layer's route drops it. */+export function pullRequestLayerParams<Params extends { readonly initialSummary?: unknown }>(+ params: Params,+ number: number,+) {+ const { initialSummary: _, ...layer } = params;+ return { ...layer, number };+}+export function singlePullRequestMergeAllowed(input: {readonly supportsStackActions: boolean;readonly hasStack: boolean;