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