Skip to content

Commit 5558b4e

Browse files
committed
Compute the collaboration mode picker value dynamically
1 parent 17ed187 commit 5558b4e

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/store/settings-store.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ interface SettingsState {
2525
[ Setting.POST_UPDATE_NOTIFICATION ]: boolean;
2626
[ Setting.USER_ENTER_NOTIFICATION ]: boolean;
2727
[ Setting.USER_EXIT_NOTIFICATION ]: boolean;
28+
// ToDo: Delete this once we complete the feature.
2829
[ Setting.COLLABORATION_MODE_PICKER ]: boolean;
2930
}
3031

@@ -36,10 +37,12 @@ const DEFAULT_STATE: SettingsState = {
3637
[ Setting.POST_UPDATE_NOTIFICATION ]: true,
3738
[ Setting.USER_ENTER_NOTIFICATION ]: true,
3839
[ Setting.USER_EXIT_NOTIFICATION ]: false,
39-
[ Setting.COLLABORATION_MODE_PICKER ]: isDevelopment() ? true : false,
40+
// ToDo: Delete this once we complete the feature.
41+
[ Setting.COLLABORATION_MODE_PICKER ]: false,
4042
};
4143

4244
// Settings that are only available in development mode
45+
// ToDo: Delete COLLABORATION_MODE_PICKER once we complete the feature.
4346
const DEV_ONLY_SETTINGS: Setting[] = [ Setting.DEBUG_TOOLS, Setting.COLLABORATION_MODE_PICKER ];
4447

4548
const actions = {
@@ -55,6 +58,12 @@ const reducer = (
5558
): SettingsState => {
5659
switch ( action.type ) {
5760
case 'SET_SETTING': {
61+
// ToDo: Delete COLLABORATION_MODE_PICKER once we complete the feature.
62+
// Skip saving COLLABORATION_MODE_PICKER as it's computed dynamically
63+
if ( action.payload.setting === Setting.COLLABORATION_MODE_PICKER ) {
64+
return state;
65+
}
66+
5867
const newState = {
5968
...state,
6069
[ action.payload.setting ]: action.payload.enabled,
@@ -70,10 +79,18 @@ const reducer = (
7079

7180
const selectors = {
7281
getSetting( state: SettingsState, setting: Setting ): boolean {
73-
// Special handling for dev-only settings
82+
// ToDo: Delete COLLABORATION_MODE_PICKER once we complete the feature.
83+
// COLLABORATION_MODE_PICKER is always true in development, false otherwise
84+
// It's not stored in state or localStorage
85+
if ( setting === Setting.COLLABORATION_MODE_PICKER ) {
86+
return isDevelopment();
87+
}
88+
89+
// Special handling for other dev-only settings
7490
if ( DEV_ONLY_SETTINGS.includes( setting ) ) {
7591
return isDevelopment() ? state[ setting ] : false;
7692
}
93+
7794
return state[ setting ];
7895
},
7996
};

0 commit comments

Comments
 (0)