Skip to content

Commit 2900836

Browse files
committed
fix(web): copy cached panel pull request URLs
1 parent b6f18e2 commit 2900836

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

‎apps/web/src/hooks/useOpenPanelPullRequestUrl.ts‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { scopeProjectRef } from "@t3tools/client-runtime/environment";
22
import { EnvironmentId, ProjectId, type ScopedThreadRef } from "@t3tools/contracts";
3+
import { useMemo } from "react";
34

5+
import {
6+
readPullRequestDetailSnapshot,
7+
resolveDisplayedPullRequestDetail,
8+
} from "../components/pullRequest/pullRequestDetail.logic";
49
import { gitHubPullRequestBrowserUrl } from "../lib/openPullRequestLink";
510
import { selectActiveRightPanelSurface, useRightPanelStore } from "../rightPanelStore";
611
import { useProject } from "../state/entities";
@@ -32,8 +37,19 @@ export function useOpenPanelPullRequestUrl(threadRef: ScopedThreadRef | null): s
3237
})
3338
: null,
3439
).data;
40+
const cachedDetail = useMemo(
41+
() =>
42+
reference && environmentId
43+
? readPullRequestDetailSnapshot(
44+
typeof window === "undefined" ? undefined : window.localStorage,
45+
environmentId,
46+
reference,
47+
)
48+
: null,
49+
[environmentId, reference],
50+
);
3551
return reference
36-
? (detail?.url ??
52+
? (resolveDisplayedPullRequestDetail({ live: detail, cached: cachedDetail, reference })?.url ??
3753
gitHubPullRequestBrowserUrl(
3854
project?.repositoryIdentity,
3955
reference.repository,

0 commit comments

Comments
 (0)