Skip to content

Commit 3d98cf9

Browse files
committed
redux types: Split PerAccountSettingsState from SettingsState
1 parent 20bca74 commit 3d98cf9

File tree

1 file changed

+35
-4
lines changed

1 file changed

+35
-4
lines changed

src/reduxTypes.js

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,19 +287,50 @@ export type ThemeName = 'default' | 'night';
287287
*/
288288
export type BrowserPreference = 'embedded' | 'external' | 'default';
289289

290+
/**
291+
* The user's chosen settings specific to this account.
292+
*/
293+
export type PerAccountSettingsState = $ReadOnly<{
294+
offlineNotification: boolean,
295+
onlineNotification: boolean,
296+
streamNotification: boolean,
297+
...
298+
}>;
299+
300+
/**
301+
* The user's chosen settings.
302+
*
303+
* This is a mix of server data representing the active account (see
304+
* {@link PerAccountSettingsState}), and client-only data that applies
305+
* across all the user's accounts on this client (i.e. on this install of
306+
* the app on this device.)
307+
*/
290308
export type SettingsState = $ReadOnly<{|
309+
...$Exact<PerAccountSettingsState>,
310+
311+
// The properties below apply independent of account. That also means
312+
// they can't come from the server. For per-account settings, see
313+
// PerAccountSettingsState.
314+
291315
// The user's chosen language, as an IETF BCP 47 language tag.
292316
language: string,
293317

294318
theme: ThemeName,
295-
offlineNotification: boolean,
296-
onlineNotification: boolean,
297-
experimentalFeaturesEnabled: boolean,
298-
streamNotification: boolean,
299319
browser: BrowserPreference,
320+
321+
// TODO cut this? what was it?
322+
experimentalFeaturesEnabled: boolean,
323+
324+
// Possibly this should be per-account. If so it should probably be put
325+
// on the server, so it can also be cross-device for the account.
300326
doNotMarkMessagesAsRead: boolean,
301327
|}>;
302328

329+
// As part of letting GlobalState freely convert to PerAccountState,
330+
// we'll want the same for SettingsState. (This is also why
331+
// PerAccountSettingsState is inexact.)
332+
(s: SettingsState): PerAccountSettingsState => s; // eslint-disable-line no-unused-expressions
333+
303334
export type StreamsState = $ReadOnlyArray<Stream>;
304335

305336
export type SubscriptionsState = $ReadOnlyArray<Subscription>;

0 commit comments

Comments
 (0)