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