Julius MarmingeT3 Code Mobile [WIP] (#2013)b3e8c035 months agoHistory
46 lines · 1.6 KB · TypeScript
RawDownload
import { useAtomValue } from "@effect/atom-react";import {  type ComposerPathSearchState,  type ComposerPathSearchTarget,  EMPTY_COMPOSER_PATH_SEARCH_ATOM,  EMPTY_COMPOSER_PATH_SEARCH_STATE,  composerPathSearchStateAtom,  createComposerPathSearchManager,  getComposerPathSearchTargetKey,  normalizeComposerPathSearchQuery,} from "@t3tools/client-runtime";import { useEffect, useMemo } from "react"; import { appAtomRegistry } from "./atom-registry";import {  getEnvironmentClient,  subscribeEnvironmentConnections,} from "./environment-session-registry"; const COMPOSER_PATH_SEARCH_STALE_TIME_MS = 15_000; const composerPathSearchManager = createComposerPathSearchManager({  getRegistry: () => appAtomRegistry,  getClient: (environmentId) => getEnvironmentClient(environmentId)?.projects ?? null,  subscribeClientChanges: subscribeEnvironmentConnections,  staleTimeMs: COMPOSER_PATH_SEARCH_STALE_TIME_MS,}); export function useComposerPathSearch(target: ComposerPathSearchTarget): ComposerPathSearchState {  const stableTarget = useMemo(    () => ({      environmentId: target.environmentId,      cwd: target.cwd,      query: normalizeComposerPathSearchQuery(target.query),    }),    [target.cwd, target.environmentId, target.query],  );  const targetKey = getComposerPathSearchTargetKey(stableTarget);   useEffect(() => composerPathSearchManager.watch(stableTarget), [stableTarget]);   const state = useAtomValue(    targetKey !== null ? composerPathSearchStateAtom(targetKey) : EMPTY_COMPOSER_PATH_SEARCH_ATOM,  );  return targetKey === null ? EMPTY_COMPOSER_PATH_SEARCH_STATE : state;}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t