Skip to content

Commit 4d793dd

Browse files
fix(mobile): keep diff diagnostics compatible with React Compiler
1 parent 24a5c6a commit 4d793dd

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

‎apps/mobile/src/features/pull-requests/usePullRequestDiffHighlightFiles.ts‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@ import type { ReviewParsedDiff } from "../review/reviewModel";
1212
import { createPullRequestDiffHighlightFiles } from "./pullRequestDiffHighlightFiles";
1313
import { pullRequestTarget, type PullRequestDiffParams } from "./usePullRequestDiff";
1414

15+
function traceSourceEndpoint(environmentId: string, url: string) {
16+
try {
17+
const endpoint = new URL(url);
18+
traceDiffHighlight("source-endpoint", {
19+
environment: diffHighlightTraceHash(environmentId),
20+
origin: diffHighlightTraceHash(endpoint.origin),
21+
port: endpoint.port || (endpoint.protocol === "https:" ? "443" : "80"),
22+
});
23+
} catch {
24+
traceDiffHighlight("source-endpoint-invalid");
25+
}
26+
}
27+
1528
export function usePullRequestDiffHighlightFiles(
1629
params: PullRequestDiffParams,
1730
parsed: ReviewParsedDiff,
@@ -33,16 +46,7 @@ export function usePullRequestDiffHighlightFiles(
3346
? profile.httpBaseUrl
3447
: undefined;
3548
if (url) {
36-
try {
37-
const endpoint = new URL(url);
38-
traceDiffHighlight("source-endpoint", {
39-
environment: diffHighlightTraceHash(environmentId),
40-
origin: diffHighlightTraceHash(endpoint.origin),
41-
port: endpoint.port || (endpoint.protocol === "https:" ? "443" : "80"),
42-
});
43-
} catch {
44-
traceDiffHighlight("source-endpoint-invalid");
45-
}
49+
traceSourceEndpoint(environmentId, url);
4650
} else traceDiffHighlight("source-endpoint-unavailable");
4751
}
4852
return createPullRequestDiffHighlightFiles(

0 commit comments

Comments
 (0)