Skip to content

Commit c718449

Browse files
committed
session: Move type into reducers file.
This puts it next to the code that cares in detail about all these fields, making both easier to read and modify.
1 parent b55f594 commit c718449

File tree

3 files changed

+31
-25
lines changed

3 files changed

+31
-25
lines changed

src/directSelectors.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* @flow strict-local */
22
import type {
33
GlobalState,
4-
SessionState,
54
DraftState,
65
FetchingState,
76
FlagsState,
@@ -28,6 +27,7 @@ import type {
2827
User,
2928
UserGroup,
3029
} from './types';
30+
import type { SessionState } from './session/sessionReducers';
3131

3232
export const getAccounts = (state: GlobalState): Account[] => state.accounts;
3333

src/session/sessionReducers.js

+28-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
/* @flow strict-local */
22
import type {
3-
SessionState,
3+
Debug,
4+
Dimensions,
5+
EditMessage,
6+
Narrow,
7+
Orientation,
48
SessionAction,
59
RehydrateAction,
610
AccountSwitchAction,
@@ -37,6 +41,29 @@ import {
3741
} from '../actionConstants';
3842
import { hasAuth } from '../account/accountsSelectors';
3943

44+
/**
45+
* Miscellaneous non-persistent state about this run of the app.
46+
*
47+
* @prop lastNarrow - the last narrow we navigated to. If the user is
48+
* currently in a chat screen this will also be the "current" narrow,
49+
* but they may also be on an associated info screen or have navigated
50+
* away entirely.
51+
*/
52+
export type SessionState = {|
53+
eventQueueId: number,
54+
editMessage: ?EditMessage,
55+
isOnline: boolean,
56+
isActive: boolean,
57+
isHydrated: boolean,
58+
lastNarrow: ?Narrow,
59+
needsInitialFetch: boolean,
60+
orientation: Orientation,
61+
outboxSending: boolean,
62+
/** For background, google [ios safe area]. */
63+
safeAreaInsets: Dimensions,
64+
debug: Debug,
65+
|};
66+
4067
const initialState: SessionState = {
4168
eventQueueId: -1,
4269
editMessage: null,

src/types.js

+2-23
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import type {
1919
} from './api/apiTypes';
2020
import type { AppStyles } from './styles/theme';
2121

22+
import type { SessionState } from './session/sessionReducers';
23+
2224
export type { ChildrenArray } from 'react';
2325
export type React$Node = Node; // eslint-disable-line flowtype/type-id-match
2426

@@ -240,29 +242,6 @@ export type Debug = {|
240242
doNotMarkMessagesAsRead: boolean,
241243
|};
242244

243-
/**
244-
* Miscellaneous non-persistent state about this run of the app.
245-
*
246-
* @prop lastNarrow - the last narrow we navigated to. If the user is
247-
* currently in a chat screen this will also be the "current" narrow,
248-
* but they may also be on an associated info screen or have navigated
249-
* away entirely.
250-
*/
251-
export type SessionState = {|
252-
eventQueueId: number,
253-
editMessage: ?EditMessage,
254-
isOnline: boolean,
255-
isActive: boolean,
256-
isHydrated: boolean,
257-
lastNarrow: ?Narrow,
258-
needsInitialFetch: boolean,
259-
orientation: Orientation,
260-
outboxSending: boolean,
261-
/** For background, google [ios safe area]. */
262-
safeAreaInsets: Dimensions,
263-
debug: Debug,
264-
|};
265-
266245
/**
267246
* Info about how completely we know the messages in each narrow of
268247
* MessagesState.

0 commit comments

Comments
 (0)