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

per-account 3/n: Sort out remaining selectors #5030

Merged
merged 11 commits into from
Oct 4, 2021

Conversation

gnprice
Copy link
Member

@gnprice gnprice commented Oct 4, 2021

This is the next PR in the series after #5016, #5017, and #5023, produced from the branch described at #5006 (comment).

From the foreshadowing last time:

After this PR, the conversion of tryGetAuth is still incomplete, so that's next up. Then we handle a few remaining selectors elsewhere, in particular those for state.settings and state.session.

That's this PR.

Next, continuing what we mentioned last time:

After that, we'll convert thunk actions and React components so that they get a PerAccountState rather than a GlobalState.

@chrisbobbe
Copy link
Contributor

chrisbobbe commented Oct 4, 2021

Thanks, LGTM! Please merge at will.

One nit is that "remaining selectors" isn't quite accurate, I think—remember this bit, from your 59d8813:

A more boring class of exceptions is the many small anonymous
selectors (mostly as callbacks to useSelector) that get bits of
the settings and session data. Many of those are really
per-account, but for now we leave them all marked as global.

gnprice added 11 commits October 4, 2021 16:39
This was a workaround for zulip#4388/zulip#4391.  With the introduction of
withHaveServerDataGate, we've fixed that bug properly, and this
condition should actually be impossible.
Most of its callers are in thunk actions or React components
that are clearly per-account.  Explicitly comment two that
aren't obvious: one component that sounds like it could be
cross-account, and one thunk action in outboxActions.
I've just read through all the callers, and confirmed that they're
all per-account.  Which is what one would hope, given that this
selector's interface was already that it'll throw an exception if
there isn't an active account.

As a bonus, an untruthful error message gets fixed.  We've been
reporting "Active account not logged in" not only in the case
where indeed the active account is not logged in, but also in the
case where there is no active account at all.

This is NFC other than that change in error message.
All the callers have been converted to the explicitly per-account
tryGetThisAuth, with or without tryGetActiveAccountState first.

We'll complete the migration of this function's callers shortly,
by renaming the new version back to this name tryGetAuth.
This temporarily had the wordier name tryGetThisAuth just to
facilitate sorting out its various callers between per-account
and global.
This will let us distinguish places where we need a global setting
from those where we need a per-account setting.
Most of the places we handle a *SettingsState, it's all local so we
don't have or need a type annotation naming what type of object is
involved.  At one place where we do, though, make that annotation
more specific.
As usual, we let the short simple name be kept by the per-account
version.
@gnprice gnprice force-pushed the pr-peraccount-part3 branch from 3883530 to 34827a6 Compare October 4, 2021 23:39
@gnprice gnprice merged commit 34827a6 into zulip:main Oct 4, 2021
@gnprice
Copy link
Member Author

gnprice commented Oct 4, 2021

Thanks for the review! Merged.

One nit is that "remaining selectors" isn't quite accurate, I think—remember this bit, from your 59d8813:

A more boring class of exceptions is the many small anonymous
selectors (mostly as callbacks to useSelector) that get bits of
the settings and session data. Many of those are really
per-account, but for now we leave them all marked as global.

True. I guess what I really meant is more like "remaining named selectors", or "remaining selectors in *Selectors.js files".

Those small anonymous selectors, we'll get to as part of migrating the React components that they're part of.

(I didn't see "remaining" in the commit messages, so I believe this only applies to the PR title.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants