Open History to see the last commit
1import { useActiveNewTask } from "../../state/active-new-task";
2import { ThreadUndoNotice } from "../home/ThreadUndoNotice";
3import { useAndroidControlSizing } from "../../components/ui/useAndroidControlSizing";
4import {
5 pickableProjectGroups,
6 resolveScratchProjectScopeKey,
7} from "@t3tools/client-runtime/state/project-grouping";
8import {
9 useAppearancePreferences,
10 useAndroidFloatingTabs,
11} from "../settings/appearance/AppearancePreferencesProvider";
12import type {
13 EnvironmentProject,
14 EnvironmentThreadShell,
15} from "@t3tools/client-runtime/state/shell";
16import { threadSearchMatchKey } from "@t3tools/client-runtime/state/thread-search";
17import { AnimatedLegendList } from "@legendapp/list/reanimated";
18import { THREAD_SIDEBAR_ROW_LAYOUT } from "./threadListAnimations";
19import { useAtomValue } from "@effect/atom-react";
20import { useMemo, useRef, useState } from "react";
21import { Platform, StyleSheet, View } from "react-native";
22import { GestureDetector, useNativeGesture } from "react-native-gesture-handler";
23import type { SwipeableMethods } from "react-native-gesture-handler/ReanimatedSwipeable";
24import { FLOATING_TABS } from "../layout/workspace/floating-workspace-tabs";
25import { useSafeAreaInsets } from "react-native-safe-area-context";
26
27import { AppText as Text } from "../../components/ui/AppText";
28import { scopedProjectKey, scopedThreadKey } from "../../lib/scopedEntities";
29import { useProjects, useNavigationThreadShells } from "../../state/entities";
30import { useThreadSearch } from "../../state/queries";
31import { useThreadListV2ShelfPreferences } from "./use-thread-list-v2-shelf-preferences";
32import { useThreadListNow } from "./use-thread-list-now";
33import { usePendingThreadOrder } from "../../state/thread-order";
34import { threadListEnvironmentsAtom } from "../../state/presentation";
35import { usePendingNewTasks, type PendingNewTask } from "../../state/use-pending-new-tasks";
36import { useQueuedThreadKeys } from "../../state/use-thread-outbox";
37import { useWorkspaceState } from "../../state/workspace";
38import { useSavedRemoteConnections } from "../../state/use-remote-environment-registry";
39import { useThreadListV2 } from "./useThreadListV2";
40import { useThreadJumpShortcuts } from "../keyboard/threadKeyboardShortcuts";
41import { requestThreadMessageJump } from "./threadMessageJump";
42import { useThreadListSearchMatches } from "./useThreadListSearchMatches";
43import { useHomeListOptions } from "../home/home-list-options";
44import { buildHomeListFilterMenuItems } from "../home/home-list-filter-menu";
45import { buildHomeProjectScopes } from "../home/homeThreadList";
46import { SwipeableScrollGateProvider, useSwipeableScrollGate } from "../home/thread-swipe-actions";
47import { usePendingTaskListActions } from "../home/usePendingTaskListActions";
48import { useThreadListActions } from "../home/useThreadListActions";
49import { useFabScroll } from "../home/FabScrollContext";
50import { WorkspaceListHeader } from "../layout/workspace/WorkspaceListHeader";
51import { WORKSPACE_LIST_SCROLL_INSETS } from "../layout/workspace/workspace-list-insets";
52import { WorkspaceSidebarColumn } from "../layout/workspace/WorkspaceSidebarColumn";
53import {
54 ThreadListV2PendingRow,
55 ThreadListV2Row,
56 ThreadListV2SettledShelfHeader,
57 ThreadListV2ShowMoreRow,
58 ThreadListV2SnoozedShelfHeader,
59 ThreadListV2WorkingShelfHeader,
60} from "./thread-list-v2-items";
61import { useThreadRowProviderInstanceResolver } from "./thread-provider-instance";
62import type { ThreadPrPresentation } from "../../state/thread-pr-presentation";
63import { ThreadPrDemandProvider } from "../../state/thread-pr-demand";
64import {
65 isThreadListV2ListItem,
66 threadListV2ListItemsAreEqual,
67 THREAD_LIST_V2_SETTLED_INITIAL_COUNT,
68 THREAD_LIST_V2_SETTLED_PAGE_COUNT,
69 type ThreadListV2ListItem,
70} from "./threadListV2";
71import { useSelectWorkspaceDetail } from "../layout/workspace/useSelectWorkspaceDetail";
72import { NativeScrollView } from "../../native/NativeScrollViewMarker";
73
74type SidebarListItem =
75 | ThreadListV2ListItem
76 | {
77 readonly type: "v2-show-more";
78 readonly key: string;
79 readonly hiddenCount: number;
80 readonly state?: "loading" | "failed";
81 };
82
83interface ThreadNavigationSidebarProps {
84 readonly width: number;
85 readonly visible: boolean;
86 readonly selectedThreadKey: string | null;
87 readonly onOpenSettings: () => void;
88 readonly onOpenEnvironmentSettings: () => void;
89 readonly onNewThreadOnBranch: (thread: EnvironmentThreadShell) => void;
90 readonly onNewThreadInProject: (project: EnvironmentProject) => void;
91 readonly onOpenPendingTask: (pendingTask: PendingNewTask) => void;
92 readonly onSearchQueryChange: (query: string) => void;
93 readonly onSelectThread: (thread: EnvironmentThreadShell) => void;
94 readonly onOpenThreadPullRequests: (
95 thread: EnvironmentThreadShell,
96 pr: ThreadPrPresentation,
97 ) => void;
98 readonly onRequestVisibility: () => void;
99 readonly searchQuery: string;
100}
101
102export function ThreadNavigationSidebar(props: ThreadNavigationSidebarProps) {
103 return (
104 <ThreadPrDemandProvider visible={props.visible}>
105 <WorkspaceSidebarColumn width={props.width}>
106 <ThreadNavigationSidebarPane {...props} />
107 </WorkspaceSidebarColumn>
108 </ThreadPrDemandProvider>
109 );
110}
111
112function ThreadNavigationSidebarPane(props: ThreadNavigationSidebarProps) {
113 const floatingTabsEnabled = useAndroidFloatingTabs();
114 const { themeVariables: materialTheme } = useAppearancePreferences();
115 const drawerColor = materialTheme["--color-drawer"];
116
117 const insets = useSafeAreaInsets();
118 const { fabClearance, fabSize } = useAndroidControlSizing();
119 const projects = useProjects();
120 const threads = useNavigationThreadShells();
121 const { environments: workspaceEnvironments, state: catalogState } = useWorkspaceState();
122 const { savedConnectionsById } = useSavedRemoteConnections();
123 const openSwipeableRef = useRef<SwipeableMethods | null>(null);
124 const sidebarScrollGesture = useNativeGesture();
125 const {
126 archiveThread,
127 confirmDeleteThread,
128 settleThread,
129 snoozeThread,
130 unsnoozeThread,
131 unsettleThread,
132 pinThread,
133 unpinThread,
134 setThreadAutoSettle,
135 moveThread,
136 renameThread,
137 regenerateThreadTitle,
138 } = useThreadListActions();
139 const pendingTasks = usePendingNewTasks();
140 const activeNewTask = useActiveNewTask();
141 const queuedThreadKeys = useQueuedThreadKeys();
142 const selectDetail = useSelectWorkspaceDetail();
143 const { confirmDeletePendingTask } = usePendingTaskListActions((params) =>
144 selectDetail({ name: "Thread", params }),
145 );
146 const environments = Object.values(savedConnectionsById)
147 .map((connection) => ({
148 environmentId: connection.environmentId,
149 label: connection.environmentLabel,
150 }))
151 .sort((left, right) => left.label.localeCompare(right.label));
152 const availableEnvironmentIds = new Set(
153 environments.map((environment) => environment.environmentId),
154 );
155 const { options, setSelectedEnvironmentId, setSelectedProjectKey } =
156 useHomeListOptions(availableEnvironmentIds);
157 const searchEnvironmentIds =
158 options.selectedEnvironmentId === null
159 ? workspaceEnvironments
160 .filter((environment) => environment.connectionState === "connected")
161 .map((environment) => environment.environmentId)
162 : workspaceEnvironments.some(
163 (environment) =>
164 environment.environmentId === options.selectedEnvironmentId &&
165 environment.connectionState === "connected",
166 )
167 ? [options.selectedEnvironmentId]
168 : [];
169 // A legacy per-environment scratch key resolves here on every render; the stored
170 // value is only rewritten when the user picks a filter.
171 const resolvedProjectKey = resolveScratchProjectScopeKey(options.selectedProjectKey, projects, {
172 sidebarProjectGroupingMode: options.projectGroupingMode,
173 sidebarProjectGroupingOverrides: {},
174 });
175 const projectScopes = useMemo(
176 () =>
177 buildHomeProjectScopes({
178 projects,
179 environmentId: options.selectedEnvironmentId,
180 projectGroupingMode: options.projectGroupingMode,
181 }),
182 [projects, options.selectedEnvironmentId, options.projectGroupingMode],
183 );
184 const projectFilterOptions = pickableProjectGroups(projectScopes).map((scope) => ({
185 key: scope.key,
186 label: scope.title,
187 }));
188 const projectTitleByProjectKey = useMemo(
189 () =>
190 new Map(
191 projectScopes.flatMap((scope) =>
192 scope.projectRefs.map(
193 (projectRef) =>
194 [
195 scopedProjectKey(projectRef.environmentId, projectRef.projectId),
196 scope.title,
197 ] as const,
198 ),
199 ),
200 ),
201 [projectScopes],
202 );
203 // An archived project's filter reads as all projects, matching the filter menu.
204 const selectedProjectScope =
205 pickableProjectGroups(projectScopes).find((scope) => scope.key === resolvedProjectKey) ?? null;
206 const threadSearch = useThreadSearch(
207 searchEnvironmentIds,
208 props.searchQuery,
209 selectedProjectScope === null
210 ? {}
211 : { projectIds: selectedProjectScope.projectRefs.map((ref) => ref.projectId) },
212 );
213 // This map reaches LegendList's extraData, which re-renders every row whenever it changes
214 // identity; the hook keeps it stable.
215 const threadSearchMatchByKey = useThreadListSearchMatches(threads, threadSearch);
216 const selectedProjectKey = selectedProjectScope?.key ?? null;
217 const projectByKey = useMemo(() => {
218 const map = new Map<string, EnvironmentProject>();
219 for (const project of projects) {
220 map.set(scopedProjectKey(project.environmentId, project.id), project);
221 }
222 return map;
223 }, [projects]);
224
225 const [settledVisibleCount, setSettledVisibleCount] = useState(
226 THREAD_LIST_V2_SETTLED_INITIAL_COUNT,
227 );
228 const settledResetKey = `${options.selectedEnvironmentId ?? "all"}:${selectedProjectKey ?? "all"}:${props.searchQuery.trim()}`;
229 const [lastSettledResetKey, setLastSettledResetKey] = useState(settledResetKey);
230 if (lastSettledResetKey !== settledResetKey) {
231 setLastSettledResetKey(settledResetKey);
232 setSettledVisibleCount(THREAD_LIST_V2_SETTLED_INITIAL_COUNT);
233 }
234 const showMoreSettled = () =>
235 setSettledVisibleCount((count) => count + THREAD_LIST_V2_SETTLED_PAGE_COUNT);
236 const {
237 loaded: shelfPreferencesLoaded,
238 settledShelfExpanded,
239 snoozedShelfExpanded,
240 workingShelfEnabled,
241 workingShelfExpanded,
242 toggleSettledShelf,
243 toggleSnoozedShelf,
244 toggleWorkingShelf,
245 } = useThreadListV2ShelfPreferences();
246 const now = useThreadListNow(threads);
247 const listEnvironments = useAtomValue(threadListEnvironmentsAtom);
248 const {
249 providersByEnvironmentId,
250 machineByEnvironmentId,
251 settlementEnvironmentIds,
252 snoozeEnvironmentIds,
253 snoozePresetsByEnvironmentId,
254 pinningEnvironmentIds,
255 autoSettleOptOutEnvironmentIds,
256 pinReorderEnvironmentIds,
257 activeReorderEnvironmentIds,
258 titleRegenerationEnvironmentIds,
259 } = listEnvironments;
260 const resolveProviderInstance = useThreadRowProviderInstanceResolver(providersByEnvironmentId);
261 const pendingOrder = usePendingThreadOrder();
262 const {
263 layout: threadListV2Layout,
264 items: threadListV2Items,
265 contentOnlyThreadKeys,
266 olderSettledShelf,
267 } = useThreadListV2({
268 threads,
269 pendingTasks,
270 environmentId: options.selectedEnvironmentId,
271 projectRefs: selectedProjectScope === null ? null : selectedProjectScope.projectRefs,
272 searchQuery: props.searchQuery,
273 searchMatches: threadSearchMatchByKey,
274 settlementEnvironmentIds,
275 snoozeEnvironmentIds,
276 pinReorderEnvironmentIds,
277 activeReorderEnvironmentIds,
278 queuedThreadKeys,
279 settledLimit: settledVisibleCount,
280 now,
281 pendingOrder,
282 shelfPreferencesLoaded,
283 workingShelfEnabled,
284 workingShelfExpanded,
285 snoozedShelfExpanded,
286 settledShelfExpanded,
287 selectedThreadKey: props.selectedThreadKey ?? null,
288 });
289 const listItems: readonly SidebarListItem[] =
290 settledShelfExpanded && threadListV2Layout.hiddenSettledCount > 0
291 ? [
292 ...threadListV2Items,
293 {
294 type: "v2-show-more",
295 key: "v2-show-more",
296 hiddenCount: threadListV2Layout.hiddenSettledCount,
297 ...(olderSettledShelf.loading
298 ? { state: "loading" as const }
299 : olderSettledShelf.failed
300 ? { state: "failed" as const }
301 : {}),
302 },
303 ]
304 : threadListV2Items;
305
306 const handleSwipeableWillOpen = (methods: SwipeableMethods) => {
307 if (openSwipeableRef.current !== methods) {
308 openSwipeableRef.current?.close();
309 openSwipeableRef.current = methods;
310 }
311 };
312 const handleSwipeableClose = (methods: SwipeableMethods) => {
313 if (openSwipeableRef.current === methods) {
314 openSwipeableRef.current = null;
315 }
316 };
317 // Destructure callback props; capturing all props would invalidate these row-closing handlers on unrelated changes.
318 const { onSelectThread, onOpenThreadPullRequests } = props;
319 // A row listed for a message match opens the thread at that message, by
320 // tap or by shortcut.
321 const handleSelectThread = (thread: EnvironmentThreadShell) => {
322 const key = threadSearchMatchKey({ environmentId: thread.environmentId, threadId: thread.id });
323 const messageId = contentOnlyThreadKeys.has(key)
324 ? threadSearchMatchByKey.get(key)?.messageId
325 : undefined;
326 if (messageId) {
327 requestThreadMessageJump(scopedThreadKey(thread.environmentId, thread.id), messageId);
328 }
329 onSelectThread(thread);
330 openSwipeableRef.current?.close();
331 };
332 const handleOpenThreadPullRequests = (
333 thread: EnvironmentThreadShell,
334 pr: ThreadPrPresentation,
335 ) => {
336 onOpenThreadPullRequests(thread, pr);
337 openSwipeableRef.current?.close();
338 };
339 const handleScrollBeginDrag = () => {
340 openSwipeableRef.current?.close();
341 };
342 const onFabScroll = useFabScroll();
343 const { swipeEnabled, scrollGateHandlers } = useSwipeableScrollGate({
344 onScroll: onFabScroll,
345 onScrollBeginDrag: handleScrollBeginDrag,
346 });
347 // Recycle equality needs project/search data for titles and favicons; keep the minute clock on items to limit updates.
348 const listExtraData = {
349 activeNewTask,
350 selectedThreadKey: props.selectedThreadKey ?? "",
351 projectByKey,
352 projectTitleByProjectKey,
353 savedConnectionsById,
354 listEnvironments,
355 threadSearchMatchByKey,
356 workingShelfEnabled,
357 };
358 useThreadJumpShortcuts(listItems, handleSelectThread);
359 const sidebarItemsAreEqual = (previous: SidebarListItem, item: SidebarListItem): boolean => {
360 if (isThreadListV2ListItem(previous) && isThreadListV2ListItem(item)) {
361 return threadListV2ListItemsAreEqual(previous, item);
362 }
363 if (previous.type === "v2-show-more" && item.type === "v2-show-more") {
364 return previous.hiddenCount === item.hiddenCount && previous.state === item.state;
365 }
366 return false;
367 };
368 const renderListItem = ({ item }: { readonly item: SidebarListItem }) => {
369 switch (item.type) {
370 case "v2-pending": {
371 const pendingScopeKey = scopedProjectKey(
372 item.pendingTask.environmentId,
373 item.pendingTask.projectId,
374 );
375 return (
376 <ThreadListV2PendingRow
377 pendingTask={item.pendingTask}
378 selected={
379 activeNewTask?.pendingKey === item.pendingTask.key ||
380 (item.pendingTask.kind === "pending" &&
381 scopedThreadKey(
382 item.pendingTask.environmentId,
383 item.pendingTask.message.threadId,
384 ) === props.selectedThreadKey)
385 }
386 project={projectByKey.get(pendingScopeKey) ?? null}
387 projectTitle={projectTitleByProjectKey.get(pendingScopeKey)}
388 environmentLabel={
389 Object.keys(savedConnectionsById).length > 1
390 ? (savedConnectionsById[item.pendingTask.environmentId]?.environmentLabel ?? null)
391 : null
392 }
393 environmentMachine={machineByEnvironmentId.get(item.pendingTask.environmentId)}
394 pane="sidebar"
395 showPendingDivider={item.showPendingDivider}
396 onSelectPendingTask={props.onOpenPendingTask}
397 onDeletePendingTask={confirmDeletePendingTask}
398 fullSwipeWidth={props.width - 20}
399 onSwipeableClose={handleSwipeableClose}
400 onSwipeableWillOpen={handleSwipeableWillOpen}
401 simultaneousSwipeGesture={sidebarScrollGesture}
402 />
403 );
404 }
405 case "v2-thread": {
406 const thread = item.item.thread;
407 const scopeKey = scopedProjectKey(thread.environmentId, thread.projectId);
408 return (
409 <ThreadListV2Row
410 onNewThreadOnBranch={props.onNewThreadOnBranch}
411 thread={thread}
412 variant={item.item.variant}
413 hasQueuedMessages={item.hasQueuedMessages}
414 snoozed={item.item.snoozed}
415 pinned={item.item.pinned}
416 wokeAt={item.item.wokeAt}
417 snoozePresetMinute={item.snoozePresetMinute ?? ""}
418 snoozeWakeLabelText={item.snoozeWakeLabelText}
419 timeLabel={item.timeLabel}
420 project={projectByKey.get(scopeKey) ?? null}
421 providerInstance={resolveProviderInstance(thread)}
422 providers={providersByEnvironmentId.get(thread.environmentId)}
423 environmentLabel={
424 Object.keys(savedConnectionsById).length > 1
425 ? (savedConnectionsById[thread.environmentId]?.environmentLabel ?? null)
426 : null
427 }
428 environmentMachine={machineByEnvironmentId.get(thread.environmentId)}
429 searchMatch={
430 // Only rows listed for their messages show one and open at it.
431 contentOnlyThreadKeys.has(
432 threadSearchMatchKey({ environmentId: thread.environmentId, threadId: thread.id }),
433 )
434 ? threadSearchMatchByKey.get(
435 threadSearchMatchKey({
436 environmentId: thread.environmentId,
437 threadId: thread.id,
438 }),
439 )
440 : undefined
441 }
442 searchQuery={threadSearch.query}
443 pane="sidebar"
444 selected={
445 !activeNewTask &&
446 scopedThreadKey(thread.environmentId, thread.id) === props.selectedThreadKey
447 }
448 fullSwipeWidth={props.width - 20}
449 onSelectThread={handleSelectThread}
450 onOpenThreadPullRequests={handleOpenThreadPullRequests}
451 onDeleteThread={confirmDeleteThread}
452 onArchiveThread={archiveThread}
453 onRenameThread={renameThread}
454 onRegenerateThreadTitle={regenerateThreadTitle}
455 titleRegenerationSupported={titleRegenerationEnvironmentIds.has(thread.environmentId)}
456 settlementSupported={settlementEnvironmentIds.has(thread.environmentId)}
457 onSettleThread={settleThread}
458 snoozeSupported={snoozeEnvironmentIds.has(thread.environmentId)}
459 snoozePresets={snoozePresetsByEnvironmentId.get(thread.environmentId)}
460 pinningSupported={pinningEnvironmentIds.has(thread.environmentId)}
461 autoSettleOptOutSupported={autoSettleOptOutEnvironmentIds.has(thread.environmentId)}
462 reorderSupported={
463 item.item.pinned
464 ? pinReorderEnvironmentIds.has(thread.environmentId)
465 : !workingShelfEnabled && activeReorderEnvironmentIds.has(thread.environmentId)
466 }
467 canMoveUp={item.canMoveUp}
468 canMoveDown={item.canMoveDown}
469 onSnoozeThread={snoozeThread}
470 onUnsnoozeThread={unsnoozeThread}
471 onUnsettleThread={unsettleThread}
472 onPinThread={pinThread}
473 onUnpinThread={unpinThread}
474 onSetThreadAutoSettle={setThreadAutoSettle}
475 onMoveThread={moveThread}
476 onSwipeableClose={handleSwipeableClose}
477 onSwipeableWillOpen={handleSwipeableWillOpen}
478 simultaneousSwipeGesture={sidebarScrollGesture}
479 />
480 );
481 }
482 case "v2-working-shelf":
483 return (
484 <ThreadListV2WorkingShelfHeader
485 count={item.count}
486 disabled={item.disabled}
487 expanded={item.expanded}
488 onToggle={toggleWorkingShelf}
489 pane="sidebar"
490 />
491 );
492 case "v2-snoozed-shelf":
493 return (
494 <ThreadListV2SnoozedShelfHeader
495 count={item.count}
496 disabled={item.disabled}
497 expanded={item.expanded}
498 onToggle={toggleSnoozedShelf}
499 pane="sidebar"
500 />
501 );
502 case "v2-settled-shelf":
503 return (
504 <ThreadListV2SettledShelfHeader
505 count={item.count}
506 disabled={item.disabled}
507 expanded={item.expanded}
508 onToggle={toggleSettledShelf}
509 pane="sidebar"
510 />
511 );
512 case "v2-show-more":
513 return (
514 <ThreadListV2ShowMoreRow
515 pane="sidebar"
516 hiddenCount={item.hiddenCount}
517 {...(item.state === undefined ? {} : { state: item.state })}
518 onPress={() => {
519 olderSettledShelf.retry();
520 showMoreSettled();
521 }}
522 />
523 );
524 }
525 };
526 const header = (
527 <WorkspaceListHeader
528 accessibilityLabel="T3 Code, Threads"
529 onOpenEnvironments={props.onOpenEnvironmentSettings}
530 onOpenSettings={props.onOpenSettings}
531 search={{
532 value: props.searchQuery,
533 onChangeText: props.onSearchQueryChange,
534 placeholder: "Search",
535 accessibilityLabel: "Search threads",
536 }}
537 filter={{
538 customized: options.selectedEnvironmentId !== null || selectedProjectKey !== null,
539 items: buildHomeListFilterMenuItems({
540 environments,
541 projects: projectFilterOptions,
542 selectedEnvironmentId: options.selectedEnvironmentId,
543 selectedProjectKey,
544 onEnvironmentChange: setSelectedEnvironmentId,
545 onProjectChange: setSelectedProjectKey,
546 }),
547 }}
548 sidebar={{
549 width: props.width,
550 visible: props.visible,
551 onRequestVisibility: props.onRequestVisibility,
552 }}
553 />
554 );
555 const listEmpty = (
556 <Text
557 className={
558 Platform.OS === "android"
559 ? "px-4 py-4 text-center text-sm text-drawer-foreground-muted"
560 : "px-2 py-4 text-sm text-drawer-foreground-muted"
561 }
562 >
563 {catalogState.isLoadingConnections
564 ? "Loading threads…"
565 : Platform.OS === "android" && !catalogState.hasConnections
566 ? "No environments connected"
567 : props.searchQuery.trim().length > 0
568 ? threadSearch.isPending
569 ? "Searching thread messages…"
570 : "No matching threads"
571 : selectedProjectScope !== null
572 ? `No threads in ${selectedProjectScope.title}`
573 : "No threads yet"}
574 </Text>
575 );
576
577 if (Platform.OS === "ios") {
578 return (
579 <>
580 {header}
581 <View className="flex-1">
582 <SwipeableScrollGateProvider enabled={swipeEnabled}>
583 <GestureDetector gesture={sidebarScrollGesture}>
584 <AnimatedLegendList
585 renderScrollComponent={NativeScrollView}
586 itemLayoutAnimation={THREAD_SIDEBAR_ROW_LAYOUT}
587 data={listItems}
588 drawDistance={500}
589 estimatedItemSize={64}
590 extraData={listExtraData}
591 getItemType={(item) => item.type}
592 itemsAreEqual={sidebarItemsAreEqual}
593 keyExtractor={(item) => item.key}
594 renderItem={renderListItem}
595 {...WORKSPACE_LIST_SCROLL_INSETS}
596 contentContainerStyle={[
597 styles.threadListContent,
598 {
599 paddingBottom: Math.max(insets.bottom, 16) + 16,
600 paddingTop: 6,
601 },
602 ]}
603 keyboardDismissMode="on-drag"
604 keyboardShouldPersistTaps="handled"
605 {...scrollGateHandlers}
606 recycleItems
607 scrollEventThrottle={16}
608 showsVerticalScrollIndicator={false}
609 style={styles.threadList}
610 ListEmptyComponent={listEmpty}
611 />
612 </GestureDetector>
613 </SwipeableScrollGateProvider>
614 <ThreadUndoNotice visible={props.visible} />
615 </View>
616 </>
617 );
618 }
619
620 // Android: the bar floats below the list.
621 return (
622 <View testID="thread-navigation-sidebar" className="flex-1 bg-header">
623 <View
624 className="flex-1"
625 style={{
626 marginHorizontal: 4,
627 paddingBottom: insets.bottom,
628 backgroundColor: drawerColor,
629 borderTopLeftRadius: 28,
630 borderTopRightRadius: 28,
631 overflow: "hidden",
632 }}
633 >
634 {listItems.length === 0 ? (
635 <View className="flex-1 items-center justify-center">{listEmpty}</View>
636 ) : (
637 <SwipeableScrollGateProvider enabled={swipeEnabled}>
638 <GestureDetector gesture={sidebarScrollGesture}>
639 {/* oxlint-disable-next-line t3code/require-registered-list-scroll -- The Android sidebar has no native header to register with. */}
640 <AnimatedLegendList
641 itemLayoutAnimation={THREAD_SIDEBAR_ROW_LAYOUT}
642 data={listItems}
643 drawDistance={500}
644 estimatedItemSize={64}
645 extraData={listExtraData}
646 getItemType={(item) => item.type}
647 itemsAreEqual={sidebarItemsAreEqual}
648 keyExtractor={(item) => item.key}
649 renderItem={renderListItem}
650 contentContainerStyle={{
651 paddingBottom: floatingTabsEnabled
652 ? FLOATING_TABS.bottom + FLOATING_TABS.edge + fabSize
653 : Math.max(insets.bottom, 16) + fabClearance - insets.bottom,
654 paddingTop: 6,
655 }}
656 keyboardDismissMode="on-drag"
657 keyboardShouldPersistTaps="handled"
658 {...scrollGateHandlers}
659 recycleItems
660 scrollEventThrottle={16}
661 showsVerticalScrollIndicator={false}
662 style={styles.threadList}
663 ListEmptyComponent={listEmpty}
664 />
665 </GestureDetector>
666 </SwipeableScrollGateProvider>
667 )}
668 </View>
669 {header}
670 <ThreadUndoNotice visible={props.visible} />
671 </View>
672 );
673}
674
675const styles = StyleSheet.create({
676 threadList: {
677 flex: 1,
678 },
679 threadListContent: {
680 paddingHorizontal: 8,
681 },
682});