Open History to see the last commit
1import type { IssueRef } from "@t3tools/contracts";
2
3import { useIntentTarget } from "~/hooks/useIntentTarget";
4import { issueEnvironment } from "~/state/issues";
5import { useEnvironmentQuery } from "~/state/query";
6
7import type { IssueRowTarget } from "./IssueRow";
8
9export function issuePanelReference(
10 target: Omit<IssueRef, "host"> & { readonly host?: string | undefined },
11): IssueRef {
12 return {
13 projectId: target.projectId,
14 tracker: target.tracker,
15 ...(target.host ? { host: target.host.toLowerCase() } : {}),
16 scope: target.scope,
17 key: target.key,
18 };
19}
20
21export function useIssueIntentPrefetch(isListed: (target: IssueRowTarget) => boolean) {
22 const [target, setIntent] = useIntentTarget(isListed);
23 useEnvironmentQuery(
24 target === null
25 ? null
26 : issueEnvironment.detail({
27 environmentId: target.environmentId,
28 input: issuePanelReference(target),
29 }),
30 );
31 return setIntent;
32}