Skip to content
TypeScript

perf(mobile): thread rows no longer re-render the list when another thread streams (#21255)

Julius Marminge685c4137f17d
diff --git a/apps/mobile/src/features/home/HomeScreen.tsx b/apps/mobile/src/features/home/HomeScreen.tsx
index fa4059922bd..e90fc1672bc 100644
--- a/apps/mobile/src/features/home/HomeScreen.tsx
+++ b/apps/mobile/src/features/home/HomeScreen.tsx
@@ -415,28 +415,14 @@ export function HomeScreen(props: HomeScreenProps) {
),
);
const handleSettleThread = props.onSettleThread;
- const handleSnoozeThread = (thread: EnvironmentThreadShell, snoozedUntil: string) => {
- void props.onSnoozeThread(thread, snoozedUntil);
- };
- const handleUnsnoozeThread = (thread: EnvironmentThreadShell) => {
- void props.onUnsnoozeThread(thread);
- };
- const handlePinThread = (thread: EnvironmentThreadShell) => {
- void props.onPinThread(thread);
- };
- const handleMoveThread = (thread: EnvironmentThreadShell, direction: ThreadMoveDestination) => {
- void props.onMoveThread(thread, direction);
- };
- const handleUnpinThread = (thread: EnvironmentThreadShell) => {
- void props.onUnpinThread(thread);
- };
- const handleSetThreadAutoSettle = (thread: EnvironmentThreadShell, enabled: boolean) => {
- void props.onSetThreadAutoSettle(thread, enabled);
- };
- const handleRegenerateThreadTitle = (thread: EnvironmentThreadShell) => {
- void props.onRegenerateThreadTitle(thread);
- };
- const handleRenameThread = (thread: EnvironmentThreadShell) => props.onRenameThread(thread);
+ const handleSnoozeThread = props.onSnoozeThread;
+ const handleUnsnoozeThread = props.onUnsnoozeThread;
+ const handlePinThread = props.onPinThread;
+ const handleMoveThread = props.onMoveThread;
+ const handleUnpinThread = props.onUnpinThread;
+ const handleSetThreadAutoSettle = props.onSetThreadAutoSettle;
+ const handleRegenerateThreadTitle = props.onRegenerateThreadTitle;
+ const handleRenameThread = props.onRenameThread;
const handleDeleteThread = props.onDeleteThread;
const handleUnsettleThread = props.onUnsettleThread;
const [settledVisibleCount, setSettledVisibleCount] = useState(
diff --git a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
index b0b6a4b3272..d9cf141d2f9 100644
--- a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
+++ b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
@@ -484,15 +484,18 @@ function ThreadNavigationSidebarPane(
openSwipeableRef.current = null;
}
};
+ // These close the open row too, so they cannot be pass-throughs. The compiler would
+ // recache a closure over `props` whenever any prop changed.
+ const { onSelectThread, onOpenThreadPullRequests } = props;
const handleSelectThread = (thread: EnvironmentThreadShell) => {
- props.onSelectThread(thread);
+ onSelectThread(thread);
openSwipeableRef.current?.close();
};
const handleOpenThreadPullRequests = (
thread: EnvironmentThreadShell,
pr: ThreadPrPresentation,
) => {
- props.onOpenThreadPullRequests(thread, pr);
+ onOpenThreadPullRequests(thread, pr);
openSwipeableRef.current?.close();
};
const handleScrollBeginDrag = () => {