diff options
author | 2019-09-11 14:17:13 +0200 | |
---|---|---|
committer | 2019-09-11 14:17:13 +0200 | |
commit | ddab3a88b297fe244971b0d4fb9ff3fca3a8a1fe (patch) | |
tree | 4d1df67bd12c0a4f82c483f1c2d4f6c9e20c4281 /src/containers | |
parent | Update CHANGELOG.md (diff) | |
download | ferdium-app-ddab3a88b297fe244971b0d4fb9ff3fca3a8a1fe.tar.gz ferdium-app-ddab3a88b297fe244971b0d4fb9ff3fca3a8a1fe.tar.zst ferdium-app-ddab3a88b297fe244971b0d4fb9ff3fca3a8a1fe.zip |
feat(Workspaces): Setting to keep all workspaces loaded
Diffstat (limited to 'src/containers')
-rw-r--r-- | src/containers/settings/EditSettingsScreen.js | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/src/containers/settings/EditSettingsScreen.js b/src/containers/settings/EditSettingsScreen.js index 65b5a45df..9aba212be 100644 --- a/src/containers/settings/EditSettingsScreen.js +++ b/src/containers/settings/EditSettingsScreen.js | |||
@@ -19,6 +19,8 @@ import ErrorBoundary from '../../components/util/ErrorBoundary'; | |||
19 | 19 | ||
20 | import globalMessages from '../../i18n/globalMessages'; | 20 | import globalMessages from '../../i18n/globalMessages'; |
21 | import { DEFAULT_IS_FEATURE_ENABLED_BY_USER } from '../../features/todos'; | 21 | import { DEFAULT_IS_FEATURE_ENABLED_BY_USER } from '../../features/todos'; |
22 | import WorkspacesStore from '../../features/workspaces/store'; | ||
23 | import { DEFAULT_SETTING_KEEP_ALL_WORKSPACES_LOADED } from '../../features/workspaces'; | ||
22 | 24 | ||
23 | const messages = defineMessages({ | 25 | const messages = defineMessages({ |
24 | autoLaunchOnStart: { | 26 | autoLaunchOnStart: { |
@@ -73,6 +75,10 @@ const messages = defineMessages({ | |||
73 | id: 'settings.app.form.enableTodos', | 75 | id: 'settings.app.form.enableTodos', |
74 | defaultMessage: '!!!Enable Franz Todos', | 76 | defaultMessage: '!!!Enable Franz Todos', |
75 | }, | 77 | }, |
78 | keepAllWorkspacesLoaded: { | ||
79 | id: 'settings.app.form.keepAllWorkspacesLoaded', | ||
80 | defaultMessage: '!!!Keep all workspaces loaded', | ||
81 | }, | ||
76 | }); | 82 | }); |
77 | 83 | ||
78 | export default @inject('stores', 'actions') @observer class EditSettingsScreen extends Component { | 84 | export default @inject('stores', 'actions') @observer class EditSettingsScreen extends Component { |
@@ -81,12 +87,13 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e | |||
81 | }; | 87 | }; |
82 | 88 | ||
83 | onSubmit(settingsData) { | 89 | onSubmit(settingsData) { |
84 | const { todos } = this.props.stores; | 90 | const { todos, workspaces } = this.props.stores; |
85 | const { | 91 | const { |
86 | app, | 92 | app, |
87 | settings, | 93 | settings, |
88 | user, | 94 | user, |
89 | todos: todosActions, | 95 | todos: todosActions, |
96 | workspaces: workspaceActions, | ||
90 | } = this.props.actions; | 97 | } = this.props.actions; |
91 | 98 | ||
92 | app.launchOnStartup({ | 99 | app.launchOnStartup({ |
@@ -118,14 +125,24 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e | |||
118 | }, | 125 | }, |
119 | }); | 126 | }); |
120 | 127 | ||
128 | if (workspaces.isFeatureActive) { | ||
129 | const { keepAllWorkspacesLoaded } = workspaces.settings; | ||
130 | if (keepAllWorkspacesLoaded !== settingsData.keepAllWorkspacesLoaded) { | ||
131 | workspaceActions.toggleKeepAllWorkspacesLoadedSetting(); | ||
132 | } | ||
133 | } | ||
134 | |||
121 | if (todos.isFeatureActive) { | 135 | if (todos.isFeatureActive) { |
122 | todosActions.toggleTodosFeatureVisibility(); | 136 | const { isFeatureEnabledByUser } = todos.settings; |
137 | if (isFeatureEnabledByUser !== settingsData.enableTodos) { | ||
138 | todosActions.toggleTodosFeatureVisibility(); | ||
139 | } | ||
123 | } | 140 | } |
124 | } | 141 | } |
125 | 142 | ||
126 | prepareForm() { | 143 | prepareForm() { |
127 | const { | 144 | const { |
128 | app, settings, user, todos, | 145 | app, settings, user, todos, workspaces, |
129 | } = this.props.stores; | 146 | } = this.props.stores; |
130 | const { intl } = this.context; | 147 | const { intl } = this.context; |
131 | 148 | ||
@@ -210,6 +227,14 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e | |||
210 | }, | 227 | }, |
211 | }; | 228 | }; |
212 | 229 | ||
230 | if (workspaces.isFeatureActive) { | ||
231 | config.fields.keepAllWorkspacesLoaded = { | ||
232 | label: intl.formatMessage(messages.keepAllWorkspacesLoaded), | ||
233 | value: workspaces.settings.keepAllWorkspacesLoaded, | ||
234 | default: DEFAULT_SETTING_KEEP_ALL_WORKSPACES_LOADED, | ||
235 | }; | ||
236 | } | ||
237 | |||
213 | if (todos.isFeatureActive) { | 238 | if (todos.isFeatureActive) { |
214 | config.fields.enableTodos = { | 239 | config.fields.enableTodos = { |
215 | label: intl.formatMessage(messages.enableTodos), | 240 | label: intl.formatMessage(messages.enableTodos), |
@@ -225,6 +250,7 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e | |||
225 | const { | 250 | const { |
226 | app, | 251 | app, |
227 | todos, | 252 | todos, |
253 | workspaces, | ||
228 | } = this.props.stores; | 254 | } = this.props.stores; |
229 | const { | 255 | const { |
230 | updateStatus, | 256 | updateStatus, |
@@ -255,6 +281,7 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e | |||
255 | onClearAllCache={clearAllCache} | 281 | onClearAllCache={clearAllCache} |
256 | isSpellcheckerIncludedInCurrentPlan={spellcheckerConfig.isIncludedInCurrentPlan} | 282 | isSpellcheckerIncludedInCurrentPlan={spellcheckerConfig.isIncludedInCurrentPlan} |
257 | isTodosEnabled={todos.isFeatureActive} | 283 | isTodosEnabled={todos.isFeatureActive} |
284 | isWorkspaceEnabled={workspaces.isFeatureActive} | ||
258 | /> | 285 | /> |
259 | </ErrorBoundary> | 286 | </ErrorBoundary> |
260 | ); | 287 | ); |
@@ -267,6 +294,7 @@ EditSettingsScreen.wrappedComponent.propTypes = { | |||
267 | user: PropTypes.instanceOf(UserStore).isRequired, | 294 | user: PropTypes.instanceOf(UserStore).isRequired, |
268 | settings: PropTypes.instanceOf(SettingsStore).isRequired, | 295 | settings: PropTypes.instanceOf(SettingsStore).isRequired, |
269 | todos: PropTypes.instanceOf(TodosStore).isRequired, | 296 | todos: PropTypes.instanceOf(TodosStore).isRequired, |
297 | workspaces: PropTypes.instanceOf(WorkspacesStore).isRequired, | ||
270 | }).isRequired, | 298 | }).isRequired, |
271 | actions: PropTypes.shape({ | 299 | actions: PropTypes.shape({ |
272 | app: PropTypes.shape({ | 300 | app: PropTypes.shape({ |
@@ -284,5 +312,8 @@ EditSettingsScreen.wrappedComponent.propTypes = { | |||
284 | todos: PropTypes.shape({ | 312 | todos: PropTypes.shape({ |
285 | toggleTodosFeatureVisibility: PropTypes.func.isRequired, | 313 | toggleTodosFeatureVisibility: PropTypes.func.isRequired, |
286 | }).isRequired, | 314 | }).isRequired, |
315 | workspaces: PropTypes.shape({ | ||
316 | toggleAllWorkspacesLoadedSetting: PropTypes.func.isRequired, | ||
317 | }).isRequired, | ||
287 | }).isRequired, | 318 | }).isRequired, |
288 | }; | 319 | }; |