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

unread [nfc]: Refactor computing contents of inbox screen #5690

Merged
merged 10 commits into from
Mar 22, 2023

Conversation

gnprice
Copy link
Member

@gnprice gnprice commented Mar 21, 2023

For #5362, we'll be revising how we apply the concept of muting, which will require some changes to this getUnreadStreamsAndTopics selector that computes the unreads to show on the inbox screen. The existing structure of that selector is a bit of a mess and would make that change more complicated than it needs to be. This PR cleans it up.

As a bonus, we get rid of one of the few remaining uses of the bogus-data object NULL_SUBSCRIPTION.

gnprice added 10 commits March 20, 2023 16:24
The existence of this helper is an implementation detail
of this function.  (And probably not even a good choice.)
It definitely should not have its own tests -- the tests
should be of the behavior that forms a meaningful interface
for the rest of the app to use.
There's further refactoring opportunities this opens up;
we'll take care of those in upcoming commits.
These were always false in the data structure actually returned
to the UI; their presence there was basically a leak of an
implementation detail, as the purpose they served was in the
communication between getUnreadStreamsAndTopics and its helper.
Now that we've erased that boundary, we don't need them at all.
(Empty here means there were unreads in the stream, but only in
muted topics.)
Use more locals rather than re-looking things up on an object;
and give them better names.
…opics

The Map nature here wasn't doing us any good; we only ever inserted
at a given stream once, and then just made an array from `.values()`.

(Long ago this code made use of this being a map; but that ended when
we switched to nice efficient data structures for stream unreads,
which among other things give us all the data for a given stream
at once.)
This is NFC because when there's no subscription, the old code
would get `in_home_view = false` and promptly ignore the stream.

As a bonus, this is one fewer use of NULL_SUBSCRIPTION.
Not many left!
@gnprice gnprice added P1 high-priority server release goal Things we should try to coordinate with a major Zulip Server release. labels Mar 21, 2023
@chrisbobbe chrisbobbe merged commit bc33c8c into zulip:main Mar 22, 2023
@chrisbobbe
Copy link
Contributor

Thanks, LGTM! Merged.

@gnprice gnprice deleted the pr-unreads-selector branch March 28, 2023 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 high-priority server release goal Things we should try to coordinate with a major Zulip Server release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants