Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give inbox a view-model, incrementally updated #1065

Open
gnprice opened this issue Nov 20, 2024 · 0 comments
Open

Give inbox a view-model, incrementally updated #1065

gnprice opened this issue Nov 20, 2024 · 0 comments
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

Comments

@gnprice
Copy link
Member

gnprice commented Nov 20, 2024

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.

@gnprice gnprice added a-model Implementing our data model (PerAccountStore, etc.) a-home The home screens of the app; finding and starting conversations performance Smooth and responsive UI; fixing jank, stutters, and lag labels Nov 20, 2024
@gnprice gnprice added this to the Post-launch milestone Nov 20, 2024
@gnprice gnprice modified the milestones: M6: Post-launch, M7: Future Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
Status: No status
Development

No branches or pull requests

1 participant