@@ -19,6 +19,41 @@ import {
19
19
} from '../actionConstants' ;
20
20
import { getHasAuth } from '../account/accountsSelectors' ;
21
21
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
+
22
57
/**
23
58
* Miscellaneous non-persistent state about this run of the app.
24
59
*
@@ -28,25 +63,19 @@ import { getHasAuth } from '../account/accountsSelectors';
28
63
* initialized to their default values.
29
64
*/
30
65
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.
32
71
33
72
// `null` if we don't know. See the place where we set this, for what that
34
73
// means.
35
74
isOnline : boolean | null ,
36
75
37
76
isHydrated : boolean ,
38
77
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 ,
48
78
orientation : Orientation ,
49
- outboxSending : boolean ,
50
79
51
80
/**
52
81
* Our actual device token, as most recently learned from the system.
@@ -67,20 +96,13 @@ export type SessionState = $ReadOnly<{|
67
96
pushToken : string | null ,
68
97
69
98
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 ,
82
99
| } > ;
83
100
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
+
84
106
const initialState : SessionState = {
85
107
eventQueueId : - 1 ,
86
108
0 commit comments