Skip to content

Give inbox a view-model, incrementally updated #1065

@gnprice

Description

@gnprice

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 update sections ­— 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 for RecentDmConversationsPage.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a-homeThe home screens of the app; finding and starting conversationsa-modelImplementing our data model (PerAccountStore, etc.)performanceSmooth and responsive UI; fixing jank, stutters, and lag

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions