mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-18 03:30:39 +09:00
fix: keep thread polish independent of quicklook routing
This commit is contained in:
parent
958c11699e
commit
dc94e3d1df
1 changed files with 3 additions and 18 deletions
|
|
@ -2,13 +2,11 @@ import * as React from "react";
|
||||||
import * as RouterDom from "react-router-dom";
|
import * as RouterDom from "react-router-dom";
|
||||||
import type { NavigateOptions, To } from "react-router-dom";
|
import type { NavigateOptions, To } from "react-router-dom";
|
||||||
import { useCompany } from "@/context/CompanyContext";
|
import { useCompany } from "@/context/CompanyContext";
|
||||||
import { IssueLinkQuicklook } from "@/components/IssueLinkQuicklook";
|
|
||||||
import {
|
import {
|
||||||
applyCompanyPrefix,
|
applyCompanyPrefix,
|
||||||
extractCompanyPrefixFromPath,
|
extractCompanyPrefixFromPath,
|
||||||
normalizeCompanyPrefix,
|
normalizeCompanyPrefix,
|
||||||
} from "@/lib/company-routes";
|
} from "@/lib/company-routes";
|
||||||
import { parseIssuePathIdFromPath } from "@/lib/issue-reference";
|
|
||||||
|
|
||||||
function resolveTo(to: To, companyPrefix: string | null): To {
|
function resolveTo(to: To, companyPrefix: string | null): To {
|
||||||
if (typeof to === "string") {
|
if (typeof to === "string") {
|
||||||
|
|
@ -42,23 +40,10 @@ function useActiveCompanyPrefix(): string | null {
|
||||||
|
|
||||||
export * from "react-router-dom";
|
export * from "react-router-dom";
|
||||||
|
|
||||||
type CompanyLinkProps = React.ComponentProps<typeof RouterDom.Link> & {
|
export const Link = React.forwardRef<HTMLAnchorElement, React.ComponentProps<typeof RouterDom.Link>>(
|
||||||
disableIssueQuicklook?: boolean;
|
function CompanyLink({ to, ...props }, ref) {
|
||||||
};
|
|
||||||
|
|
||||||
export const Link = React.forwardRef<HTMLAnchorElement, CompanyLinkProps>(
|
|
||||||
function CompanyLink({ to, disableIssueQuicklook = false, ...props }, ref) {
|
|
||||||
const companyPrefix = useActiveCompanyPrefix();
|
const companyPrefix = useActiveCompanyPrefix();
|
||||||
const resolvedTo = resolveTo(to, companyPrefix);
|
return <RouterDom.Link ref={ref} to={resolveTo(to, companyPrefix)} {...props} />;
|
||||||
const issuePathId = disableIssueQuicklook
|
|
||||||
? null
|
|
||||||
: parseIssuePathIdFromPath(typeof resolvedTo === "string" ? resolvedTo : resolvedTo.pathname);
|
|
||||||
|
|
||||||
if (issuePathId) {
|
|
||||||
return <IssueLinkQuicklook ref={ref} to={resolvedTo} issuePathId={issuePathId} {...props} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
return <RouterDom.Link ref={ref} to={resolvedTo} {...props} />;
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue