zulip-flutter
zulip-flutter copied to clipboard
Maintain total unread counts efficiently
For counting the number of unread messages you have in a stream, or overall, our initial implementation (in #364) will iterate each time through all your unread topics in that stream, or all your unread topics and DM conversations, in order to add up the numbers of unreads.
This is inefficient. In a busy realm, it's common to have thousands of unread conversations, and that could be enough to make this material. So we should do something efficient instead: maintain a count for each stream, and an overall count, and update those incrementally on events.
This will come after we implement stream and topic muting (#346), because that feature will add complexity to these counts — the counts we want are the ones that take account of muting, not the raw totals — and may affect the shape of how we want to build this.
A version of this was drafted as #345 but not merged. It was focused on the raw totals, but parts of it may be useful when we go to implement this after we have muting.