@@ -3,10 +3,10 @@ import type {
33 ContextMenuOpenContext as TreeContextMenuOpenContext ,
44} from "@pierre/trees" ;
55import type { EnvironmentId , ProjectEntry } from "@t3tools/contracts" ;
6- import { FileTree , useFileTree , useFileTreeSearch } from "@pierre/trees/react" ;
6+ import { FileTree , useFileTree , useFileTreeSearch , useFileTreeSelector } from "@pierre/trees/react" ;
77import { serializeComposerFileLink } from "@t3tools/shared/composerTrigger" ;
88import { ChevronsDownUpIcon , ChevronsUpDownIcon , RotateCw } from "lucide-react" ;
9- import { useCallback , useEffect , useMemo , useRef , useSyncExternalStore } from "react" ;
9+ import { useEffect , useMemo , useRef } from "react" ;
1010
1111import { Button } from "~/components/ui/button" ;
1212import { InputGroup , InputGroupInput } from "~/components/ui/input-group" ;
@@ -257,14 +257,8 @@ export default function FileBrowserPanel({
257257 unsafeCSS : TREE_UNSAFE_CSS ,
258258 } ) ;
259259 const search = useFileTreeSearch ( model ) ;
260- const subscribeToTree = useCallback (
261- ( onStoreChange : ( ) => void ) => model . subscribe ( onStoreChange ) ,
262- [ model ] ,
263- ) ;
264- const allDirectoriesExpanded = useSyncExternalStore (
265- subscribeToTree ,
266- ( ) => areAllDirectoriesExpanded ( model , directoryPaths ) ,
267- ( ) => false ,
260+ const allDirectoriesExpanded = useFileTreeSelector ( model , ( currentModel ) =>
261+ areAllDirectoriesExpanded ( currentModel , directoryPaths ) ,
268262 ) ;
269263 const toggleAllDirectories = ( ) => {
270264 setAllDirectoriesExpanded ( model , directoryPaths , ! allDirectoriesExpanded ) ;
0 commit comments