Give inbox a view-model, incrementally updated #1065
Labels
a-home
The home screens of the app; finding and starting conversations
a-model
Implementing our data model (PerAccountStore, etc.)
performance
Smooth and responsive UI; fixing jank, stutters, and lag
Milestone
When the user has the inbox (InboxPage) open and an event means a new unread message or other change relevant to that page, we need to update the data it consumes and then rebuild the page.
Currently we do this by having the widget's build method itself do a computation that involves going through every unread conversation in
Unreads
, as well as various other data, sorting and filtering in the ways the inbox UI needs, in order to construct from scratch the whole list of conversations for the inbox. This is inefficient.Instead, the preferred architecture is to have a view-model that keeps those data structures around — the
sections
list that is the output of that computation, plus any ancillary data structures that might be needed in order to efficiently updatesections
— and responds to events by incrementally updating the data, ideally in O(1) time for each event. For example this is how the recent-DMs page works:RecentDmConversationsView
exists to be the view-model forRecentDmConversationsPage
.This isn't an urgent issue, because the scale of the inefficiency is tolerable. I tried some quick performance measurements today (details in chat), on a test user with tons of unreads on chat.zulip.org, on my Pixel 8. The absolute longest that the recomputation from scratch took was 40.7ms; the median was around 7ms.
The text was updated successfully, but these errors were encountered: