Skip to content

Commit

Permalink
session: Remember to fetch data after logout and login.
Browse files Browse the repository at this point in the history
Our initial fetch of a snapshot of the user's data from the server,
and subscription to a queue of updates to that data, are done in
`doInitialFetch`, which is controlled by the `needsInitialFetch` flag.

That flag's effect is edge-triggered -- it's consulted inside a
`componentDidUpdate` method, which means it typically will cause a
`doInitialFetch` call only when it's *updated* to true, not if it's
continuously true.

In particular this means that on login, when we certainly need to
fetch the data from the server, we need `needsInitialFetch` to *have
been* false so that our updating it to true will have the desired
effect.  In particular, if the user logs out, we certainly want the
flag to be false.  Make that change.

Before this change, if the user managed to do a logout / login
sequence where `needsInitialFetch` starts out true, we'd sit not
loading any data until they quit the app and relaunched it.

[greg: expanded commit message]
  • Loading branch information
rk-for-zulip authored and gnprice committed Nov 20, 2019
1 parent 1d8133c commit 7caa4d0
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/session/sessionReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export default (state: SessionState = initialState, action: Action): SessionStat
return {
...state,
lastNarrow: null,
needsInitialFetch: false,
};

case ACCOUNT_SWITCH:
Expand Down

0 comments on commit 7caa4d0

Please sign in to comment.