diff options
author | 2019-09-07 15:50:23 +0200 | |
---|---|---|
committer | 2019-09-07 15:50:23 +0200 | |
commit | e7a74514c1e7c3833dfdcf5900cb87f9e6e8354e (patch) | |
tree | b8314e4155503b135dcb07e8b4a0e847e25c19cf /src/containers/settings/EditSettingsScreen.js | |
parent | Update CHANGELOG.md (diff) | |
parent | Update CHANGELOG.md (diff) | |
download | ferdium-app-e7a74514c1e7c3833dfdcf5900cb87f9e6e8354e.tar.gz ferdium-app-e7a74514c1e7c3833dfdcf5900cb87f9e6e8354e.tar.zst ferdium-app-e7a74514c1e7c3833dfdcf5900cb87f9e6e8354e.zip |
Merge branch 'master' of https://github.com/meetfranz/franz into franz-5.3.0
Diffstat (limited to 'src/containers/settings/EditSettingsScreen.js')
-rw-r--r-- | src/containers/settings/EditSettingsScreen.js | 47 |
1 files changed, 41 insertions, 6 deletions
diff --git a/src/containers/settings/EditSettingsScreen.js b/src/containers/settings/EditSettingsScreen.js index 38f73c20f..954f64dc6 100644 --- a/src/containers/settings/EditSettingsScreen.js +++ b/src/containers/settings/EditSettingsScreen.js | |||
@@ -6,6 +6,7 @@ import { defineMessages, intlShape } from 'react-intl'; | |||
6 | import AppStore from '../../stores/AppStore'; | 6 | import AppStore from '../../stores/AppStore'; |
7 | import SettingsStore from '../../stores/SettingsStore'; | 7 | import SettingsStore from '../../stores/SettingsStore'; |
8 | import UserStore from '../../stores/UserStore'; | 8 | import UserStore from '../../stores/UserStore'; |
9 | import TodosStore from '../../features/todos/store'; | ||
9 | import Form from '../../lib/Form'; | 10 | import Form from '../../lib/Form'; |
10 | import { APP_LOCALES, SPELLCHECKER_LOCALES } from '../../i18n/languages'; | 11 | import { APP_LOCALES, SPELLCHECKER_LOCALES } from '../../i18n/languages'; |
11 | import { DEFAULT_APP_SETTINGS } from '../../config'; | 12 | import { DEFAULT_APP_SETTINGS } from '../../config'; |
@@ -19,6 +20,7 @@ import ErrorBoundary from '../../components/util/ErrorBoundary'; | |||
19 | import { API } from '../../environment'; | 20 | import { API } from '../../environment'; |
20 | 21 | ||
21 | import globalMessages from '../../i18n/globalMessages'; | 22 | import globalMessages from '../../i18n/globalMessages'; |
23 | import { DEFAULT_IS_FEATURE_ENABLED_BY_USER } from '../../features/todos'; | ||
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.beta', | 75 | id: 'settings.app.form.beta', |
74 | defaultMessage: '!!!Include beta versions', | 76 | defaultMessage: '!!!Include beta versions', |
75 | }, | 77 | }, |
78 | enableTodos: { | ||
79 | id: 'settings.app.form.enableTodos', | ||
80 | defaultMessage: '!!!Enable Franz Todos', | ||
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,7 +87,13 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e | |||
81 | }; | 87 | }; |
82 | 88 | ||
83 | onSubmit(settingsData) { | 89 | onSubmit(settingsData) { |
84 | const { app, settings, user } = this.props.actions; | 90 | const { todos } = this.props.stores; |
91 | const { | ||
92 | app, | ||
93 | settings, | ||
94 | user, | ||
95 | todos: todosActions, | ||
96 | } = this.props.actions; | ||
85 | 97 | ||
86 | app.launchOnStartup({ | 98 | app.launchOnStartup({ |
87 | enable: settingsData.autoLaunchOnStart, | 99 | enable: settingsData.autoLaunchOnStart, |
@@ -112,10 +124,16 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e | |||
112 | locale: settingsData.locale, | 124 | locale: settingsData.locale, |
113 | }, | 125 | }, |
114 | }); | 126 | }); |
127 | |||
128 | if (todos.isFeatureActive) { | ||
129 | todosActions.toggleTodosFeatureVisibility(); | ||
130 | } | ||
115 | } | 131 | } |
116 | 132 | ||
117 | prepareForm() { | 133 | prepareForm() { |
118 | const { app, settings, user } = this.props.stores; | 134 | const { |
135 | app, settings, user, todos, | ||
136 | } = this.props.stores; | ||
119 | const { intl } = this.context; | 137 | const { intl } = this.context; |
120 | 138 | ||
121 | const locales = getSelectOptions({ | 139 | const locales = getSelectOptions({ |
@@ -171,8 +189,8 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e | |||
171 | }, | 189 | }, |
172 | enableSpellchecking: { | 190 | enableSpellchecking: { |
173 | label: intl.formatMessage(messages.enableSpellchecking), | 191 | label: intl.formatMessage(messages.enableSpellchecking), |
174 | value: !this.props.stores.user.data.isPremium && spellcheckerConfig.isPremium ? false : settings.all.app.enableSpellchecking, | 192 | value: !this.props.stores.user.data.isPremium && !spellcheckerConfig.isIncludedInCurrentPlan ? false : settings.all.app.enableSpellchecking, |
175 | default: !this.props.stores.user.data.isPremium && spellcheckerConfig.isPremium ? false : DEFAULT_APP_SETTINGS.enableSpellchecking, | 193 | default: !this.props.stores.user.data.isPremium && !spellcheckerConfig.isIncludedInCurrentPlan ? false : DEFAULT_APP_SETTINGS.enableSpellchecking, |
176 | }, | 194 | }, |
177 | spellcheckerLanguage: { | 195 | spellcheckerLanguage: { |
178 | label: intl.formatMessage(globalMessages.spellcheckerLanguage), | 196 | label: intl.formatMessage(globalMessages.spellcheckerLanguage), |
@@ -204,16 +222,28 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e | |||
204 | }, | 222 | }, |
205 | }; | 223 | }; |
206 | 224 | ||
225 | if (todos.isFeatureActive) { | ||
226 | config.fields.enableTodos = { | ||
227 | label: intl.formatMessage(messages.enableTodos), | ||
228 | value: todos.settings.isFeatureEnabledByUser, | ||
229 | default: DEFAULT_IS_FEATURE_ENABLED_BY_USER, | ||
230 | }; | ||
231 | } | ||
232 | |||
207 | return new Form(config); | 233 | return new Form(config); |
208 | } | 234 | } |
209 | 235 | ||
210 | render() { | 236 | render() { |
211 | const { | 237 | const { |
238 | app, | ||
239 | todos, | ||
240 | } = this.props.stores; | ||
241 | const { | ||
212 | updateStatus, | 242 | updateStatus, |
213 | cacheSize, | 243 | cacheSize, |
214 | updateStatusTypes, | 244 | updateStatusTypes, |
215 | isClearingAllCache, | 245 | isClearingAllCache, |
216 | } = this.props.stores.app; | 246 | } = app; |
217 | const { | 247 | const { |
218 | checkForUpdates, | 248 | checkForUpdates, |
219 | installUpdate, | 249 | installUpdate, |
@@ -235,7 +265,8 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e | |||
235 | cacheSize={cacheSize} | 265 | cacheSize={cacheSize} |
236 | isClearingAllCache={isClearingAllCache} | 266 | isClearingAllCache={isClearingAllCache} |
237 | onClearAllCache={clearAllCache} | 267 | onClearAllCache={clearAllCache} |
238 | isSpellcheckerPremiumFeature={spellcheckerConfig.isPremium} | 268 | isSpellcheckerIncludedInCurrentPlan={spellcheckerConfig.isIncludedInCurrentPlan} |
269 | isTodosEnabled={todos.isFeatureActive} | ||
239 | /> | 270 | /> |
240 | </ErrorBoundary> | 271 | </ErrorBoundary> |
241 | ); | 272 | ); |
@@ -247,6 +278,7 @@ EditSettingsScreen.wrappedComponent.propTypes = { | |||
247 | app: PropTypes.instanceOf(AppStore).isRequired, | 278 | app: PropTypes.instanceOf(AppStore).isRequired, |
248 | user: PropTypes.instanceOf(UserStore).isRequired, | 279 | user: PropTypes.instanceOf(UserStore).isRequired, |
249 | settings: PropTypes.instanceOf(SettingsStore).isRequired, | 280 | settings: PropTypes.instanceOf(SettingsStore).isRequired, |
281 | todos: PropTypes.instanceOf(TodosStore).isRequired, | ||
250 | }).isRequired, | 282 | }).isRequired, |
251 | actions: PropTypes.shape({ | 283 | actions: PropTypes.shape({ |
252 | app: PropTypes.shape({ | 284 | app: PropTypes.shape({ |
@@ -261,5 +293,8 @@ EditSettingsScreen.wrappedComponent.propTypes = { | |||
261 | user: PropTypes.shape({ | 293 | user: PropTypes.shape({ |
262 | update: PropTypes.func.isRequired, | 294 | update: PropTypes.func.isRequired, |
263 | }).isRequired, | 295 | }).isRequired, |
296 | todos: PropTypes.shape({ | ||
297 | toggleTodosFeatureVisibility: PropTypes.func.isRequired, | ||
298 | }).isRequired, | ||
264 | }).isRequired, | 299 | }).isRequired, |
265 | }; | 300 | }; |