Skip to content

Commit 3ce7344

Browse files
juliusmarmingeaaditagrawal
authored andcommitted
Fix sidebar highlighting for draft threads (pingdotgg#4679)
(cherry picked from commit 6a3df51)
1 parent b3a7104 commit 3ce7344

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

apps/web/src/components/SidebarV2.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,11 @@ import { threadEnvironment } from "../state/threads";
9696
import { projectEnvironment } from "../state/projects";
9797
import { useEnvironmentQuery } from "../state/query";
9898
import { useAtomCommand } from "../state/use-atom-command";
99-
import { buildThreadRouteParams, resolveThreadRouteTarget } from "../threadRoutes";
99+
import {
100+
buildThreadRouteParams,
101+
resolveActiveThreadRouteRef,
102+
resolveThreadRouteTarget,
103+
} from "../threadRoutes";
100104
import { formatRelativeTimeLabel, parseTimestampDate } from "../timestampFormat";
101105
import type { SidebarThreadSummary } from "../types";
102106
import { cn } from "~/lib/utils";
@@ -1052,7 +1056,13 @@ export default function SidebarV2() {
10521056
strict: false,
10531057
select: (params) => resolveThreadRouteTarget(params),
10541058
});
1055-
const routeThreadRef = routeTarget?.kind === "server" ? routeTarget.threadRef : null;
1059+
const routeDraftThread = useComposerDraftStore((store) =>
1060+
routeTarget?.kind === "draft" ? store.getDraftSession(routeTarget.draftId) : null,
1061+
);
1062+
const routeThreadRef = useMemo(
1063+
() => resolveActiveThreadRouteRef(routeTarget, routeDraftThread),
1064+
[routeDraftThread, routeTarget],
1065+
);
10561066
const routeThreadKey = routeThreadRef ? scopedThreadKey(routeThreadRef) : null;
10571067
const routeTargetRef = useRef(routeTarget);
10581068
routeTargetRef.current = routeTarget;

0 commit comments

Comments
 (0)