@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 03:37 UTC

main
ts 19 lines 685 Bytes
Raw
1 import { useEffect, useRef } from "react";
2
3 import type { WorkspaceSearchMode } from "./workspace-tabs-state";
4
5 export function useSearchScrollRestoration(
6 searchMode: WorkspaceSearchMode | undefined,
7 restore: () => void,
8 ) {
9 const previousSearchMode = useRef(searchMode);
10 // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- restores the native list's saved search position
11 useEffect(() => {
12 const cancelledSearch =
13 previousSearchMode.current !== undefined &&
14 previousSearchMode.current !== "resting" &&
15 searchMode === "resting";
16 previousSearchMode.current = searchMode;
17 if (cancelledSearch) restore();
18 }, [searchMode, restore]);
19 }