diff --git a/App.tsx b/App.tsx index 52c5b4bb..fe627cc5 100644 --- a/App.tsx +++ b/App.tsx @@ -129,9 +129,12 @@ function LoadingScreen({ message }: { message: string }) { function MainTabsNavigator({ navigation }: NativeStackScreenProps) { const c = useColors(); - const mailboxes = useEmailStore((state) => state.mailboxes); + // Select the count, not the list: every mailbox fetch sets a new array, and + // re-rendering here re-renders the mail list with it. + const inboxUnreadCount = useEmailStore( + (state) => state.mailboxes.find((mailbox) => mailbox.role === 'inbox')?.unreadEmails ?? 0, + ); const logout = useAuthStore((state) => state.logout); - const inboxUnreadCount = mailboxes.find((mailbox) => mailbox.role === 'inbox')?.unreadEmails ?? 0; const hasCalendar = useHasCalendar(); const hasContacts = useHasContacts(); const hasFiles = useHasFiles(); @@ -146,6 +149,8 @@ function MainTabsNavigator({ navigation }: NativeStackScreenProps - + {/* On Fabric, native-stack keeps the screen right below the top live and + freezes the ones further down. */} +