Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ThreadNavigationSidebar.tsx

706 lines26.8 KB

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