Skip to content

Commit 20bca74

Browse files
committed
redux types: Split PerAccountSessionState from SessionState
1 parent 59d8813 commit 20bca74

File tree

1 file changed

+45
-23
lines changed

1 file changed

+45
-23
lines changed

src/session/sessionReducer.js

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,41 @@ import {
1919
} from '../actionConstants';
2020
import { getHasAuth } from '../account/accountsSelectors';
2121

22+
/**
23+
* Miscellaneous non-persistent state specific to a particular account.
24+
*
25+
* See {@link SessionState} for discussion of what "non-persistent" means.
26+
*/
27+
export type PerAccountSessionState = $ReadOnly<{
28+
eventQueueId: number,
29+
30+
/**
31+
* Whether the /register request is in progress.
32+
*
33+
* This happens on startup, or on re-init following a dead event
34+
* queue after 10 minutes of inactivity.
35+
*/
36+
loading: boolean,
37+
38+
needsInitialFetch: boolean,
39+
40+
outboxSending: boolean,
41+
42+
/**
43+
* Whether `ServerCompatNotice` (which we'll add soon) has been
44+
* dismissed this session.
45+
*
46+
* We put this in the per-session state deliberately, so that users
47+
* see the notice on every startup until the server is upgraded.
48+
* That's a better experience than not being able to load the realm
49+
* on mobile at all, which is what will happen soon if the user
50+
* doesn't act on the notice.
51+
*/
52+
hasDismissedServerCompatNotice: boolean,
53+
54+
...
55+
}>;
56+
2257
/**
2358
* Miscellaneous non-persistent state about this run of the app.
2459
*
@@ -28,25 +63,19 @@ import { getHasAuth } from '../account/accountsSelectors';
2863
* initialized to their default values.
2964
*/
3065
export type SessionState = $ReadOnly<{|
31-
eventQueueId: number,
66+
...$Exact<PerAccountSessionState>,
67+
68+
// The properties below are data about the device and the app as a whole,
69+
// independent of any particular Zulip server or account.
70+
// For per-account data, see PerAccountSessionState.
3271

3372
// `null` if we don't know. See the place where we set this, for what that
3473
// means.
3574
isOnline: boolean | null,
3675

3776
isHydrated: boolean,
3877

39-
/**
40-
* Whether the /register request is in progress.
41-
*
42-
* This happens on startup, or on re-init following a dead event
43-
* queue after 10 minutes of inactivity.
44-
*/
45-
loading: boolean,
46-
47-
needsInitialFetch: boolean,
4878
orientation: Orientation,
49-
outboxSending: boolean,
5079

5180
/**
5281
* Our actual device token, as most recently learned from the system.
@@ -67,20 +96,13 @@ export type SessionState = $ReadOnly<{|
6796
pushToken: string | null,
6897

6998
debug: Debug,
70-
71-
/**
72-
* Whether `ServerCompatNotice` (which we'll add soon) has been
73-
* dismissed this session.
74-
*
75-
* We put this in the per-session state deliberately, so that users
76-
* see the notice on every startup until the server is upgraded.
77-
* That's a better experience than not being able to load the realm
78-
* on mobile at all, which is what will happen soon if the user
79-
* doesn't act on the notice.
80-
*/
81-
hasDismissedServerCompatNotice: boolean,
8299
|}>;
83100

101+
// As part of letting GlobalState freely convert to PerAccountState,
102+
// we'll want the same for SessionState. (This is also why
103+
// PerAccountSessionState is inexact.)
104+
(s: SessionState): PerAccountSessionState => s; // eslint-disable-line no-unused-expressions
105+
84106
const initialState: SessionState = {
85107
eventQueueId: -1,
86108

0 commit comments

Comments
 (0)