99} from "@t3tools/client-runtime/state/thread-search" ;
1010import { LegendList } from "@legendapp/list/react-native" ;
1111import type { MenuAction } from "@react-native-menu/menu" ;
12- import { useAtomSet , useAtomValue } from "@effect/atom-react" ;
13- import { AsyncResult } from "effect/unstable/reactivity" ;
12+ import { useAtomValue } from "@effect/atom-react" ;
1413import type { EnvironmentId } from "@t3tools/contracts" ;
1514import { sortPinnedThreadsByOrderKey } from "@t3tools/client-runtime/state/thread-sort" ;
1615import { useCallback , useEffect , useMemo , useRef , useState , type ReactNode } from "react" ;
@@ -30,9 +29,9 @@ import { NativeStackScreenOptions } from "../../native/StackHeader";
3029import { scopedProjectKey , scopedThreadKey } from "../../lib/scopedEntities" ;
3130import { useThemeColor } from "../../lib/useThemeColor" ;
3231import { useProjects , useThreadShells } from "../../state/entities" ;
33- import { mobilePreferencesAtom , updateMobilePreferencesAtom } from "../../state/preferences" ;
3432import { useThreadSearch } from "../../state/queries" ;
3533import { useThreadListV2Enabled } from "./use-thread-list-v2-enabled" ;
34+ import { useThreadListV2ShelfPreferences } from "./use-thread-list-v2-shelf-preferences" ;
3635import { environmentServerConfigsAtom } from "../../state/server" ;
3736import { usePendingNewTasks } from "../../state/use-pending-new-tasks" ;
3837import { useWorkspaceState } from "../../state/workspace" ;
@@ -191,8 +190,6 @@ function NativeSidebarContainer(props: ThreadNavigationSidebarProps) {
191190function ThreadNavigationSidebarPane (
192191 props : ThreadNavigationSidebarProps & { readonly nativeChrome : boolean } ,
193192) {
194- const preferencesResult = useAtomValue ( mobilePreferencesAtom ) ;
195- const savePreferences = useAtomSet ( updateMobilePreferencesAtom ) ;
196193 const insets = useSafeAreaInsets ( ) ;
197194 const colorScheme = useColorScheme ( ) === "dark" ? "dark" : "light" ;
198195 const projects = useProjects ( ) ;
@@ -449,26 +446,13 @@ function ThreadNavigationSidebarPane(
449446 ( ) => setSettledVisibleCount ( ( count ) => count + THREAD_LIST_V2_SETTLED_PAGE_COUNT ) ,
450447 [ ] ,
451448 ) ;
452- const snoozedShelfExpanded =
453- AsyncResult . isSuccess ( preferencesResult ) &&
454- preferencesResult . value . threadListV2SnoozedShelfExpanded === true ;
455- const toggleSnoozedShelf = useCallback (
456- ( ) =>
457- savePreferences ( {
458- threadListV2SnoozedShelfExpanded : ! snoozedShelfExpanded ,
459- } ) ,
460- [ savePreferences , snoozedShelfExpanded ] ,
461- ) ;
462- const settledShelfExpanded =
463- ! AsyncResult . isSuccess ( preferencesResult ) ||
464- preferencesResult . value . threadListV2SettledShelfExpanded !== false ;
465- const toggleSettledShelf = useCallback (
466- ( ) =>
467- savePreferences ( {
468- threadListV2SettledShelfExpanded : ! settledShelfExpanded ,
469- } ) ,
470- [ savePreferences , settledShelfExpanded ] ,
471- ) ;
449+ const {
450+ loaded : shelfPreferencesLoaded ,
451+ settledShelfExpanded,
452+ snoozedShelfExpanded,
453+ toggleSettledShelf,
454+ toggleSnoozedShelf,
455+ } = useThreadListV2ShelfPreferences ( ) ;
472456 // now ticks per minute so the inactivity auto-settle boundary is actually
473457 // crossed while the pane stays open; without a clock dependency the
474458 // partition memoizes a frozen "now".
@@ -1000,6 +984,7 @@ function ThreadNavigationSidebarPane(
1000984 return (
1001985 < ThreadListV2SnoozedShelfHeader
1002986 count = { item . count }
987+ disabled = { ! shelfPreferencesLoaded }
1003988 expanded = { item . expanded }
1004989 onToggle = { toggleSnoozedShelf }
1005990 pane = "sidebar"
@@ -1009,6 +994,7 @@ function ThreadNavigationSidebarPane(
1009994 return (
1010995 < ThreadListV2SettledShelfHeader
1011996 count = { item . count }
997+ disabled = { ! shelfPreferencesLoaded }
1012998 expanded = { item . expanded }
1013999 onToggle = { toggleSettledShelf }
10141000 pane = "sidebar"
@@ -1129,6 +1115,7 @@ function ThreadNavigationSidebarPane(
11291115 props . width ,
11301116 savedConnectionsById ,
11311117 serverConfigs ,
1118+ shelfPreferencesLoaded ,
11321119 threadSearchMatchByKey ,
11331120 settleThread ,
11341121 settlementEnvironmentIds ,
0 commit comments