diff options
author | 2019-10-06 15:09:32 +0200 | |
---|---|---|
committer | 2019-10-06 15:09:32 +0200 | |
commit | 26c075372a1bb461752c873cfed0a96b10a4bba9 (patch) | |
tree | 3eaf471910990e81b2d718e42c3e9e31bbdc6cd0 /src/components | |
parent | Merge pull request #102 from getferdi/l10n_master (diff) | |
download | ferdium-app-26c075372a1bb461752c873cfed0a96b10a4bba9.tar.gz ferdium-app-26c075372a1bb461752c873cfed0a96b10a4bba9.tar.zst ferdium-app-26c075372a1bb461752c873cfed0a96b10a4bba9.zip |
Add option to choose hibernation strategy
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/services/content/ServiceView.js | 5 | ||||
-rw-r--r-- | src/components/settings/settings/EditSettingsForm.js | 19 |
2 files changed, 22 insertions, 2 deletions
diff --git a/src/components/services/content/ServiceView.js b/src/components/services/content/ServiceView.js index 0cfefc92b..f6686548d 100644 --- a/src/components/services/content/ServiceView.js +++ b/src/components/services/content/ServiceView.js | |||
@@ -3,7 +3,6 @@ import PropTypes from 'prop-types'; | |||
3 | import { autorun, reaction } from 'mobx'; | 3 | import { autorun, reaction } from 'mobx'; |
4 | import { observer, inject } from 'mobx-react'; | 4 | import { observer, inject } from 'mobx-react'; |
5 | import classnames from 'classnames'; | 5 | import classnames from 'classnames'; |
6 | import ms from 'ms'; | ||
7 | 6 | ||
8 | import ServiceModel from '../../../models/Service'; | 7 | import ServiceModel from '../../../models/Service'; |
9 | import StatusBarTargetUrl from '../../ui/StatusBarTargetUrl'; | 8 | import StatusBarTargetUrl from '../../ui/StatusBarTargetUrl'; |
@@ -104,11 +103,13 @@ export default @observer @inject('stores') class ServiceView extends Component { | |||
104 | }; | 103 | }; |
105 | 104 | ||
106 | startHibernationTimer() { | 105 | startHibernationTimer() { |
106 | const timerDuration = (Number(this.props.stores.settings.all.app.hibernationStrategy) || 300) * 1000; | ||
107 | |||
107 | const hibernationTimer = setTimeout(() => { | 108 | const hibernationTimer = setTimeout(() => { |
108 | this.setState({ | 109 | this.setState({ |
109 | hibernate: true, | 110 | hibernate: true, |
110 | }); | 111 | }); |
111 | }, ms('5m')); | 112 | }, timerDuration); |
112 | 113 | ||
113 | this.setState({ | 114 | this.setState({ |
114 | hibernationTimer, | 115 | hibernationTimer, |
diff --git a/src/components/settings/settings/EditSettingsForm.js b/src/components/settings/settings/EditSettingsForm.js index 75f0d9d23..a15b4c255 100644 --- a/src/components/settings/settings/EditSettingsForm.js +++ b/src/components/settings/settings/EditSettingsForm.js | |||
@@ -31,6 +31,10 @@ const messages = defineMessages({ | |||
31 | id: 'settings.app.headlineGeneral', | 31 | id: 'settings.app.headlineGeneral', |
32 | defaultMessage: '!!!General', | 32 | defaultMessage: '!!!General', |
33 | }, | 33 | }, |
34 | hibernateInfo: { | ||
35 | id: 'settings.app.hibernateInfo', | ||
36 | defaultMessage: '!!!By default, Ferdi will keep all your services open and loaded in the background so they are ready when you want to use them. Service Hibernation will unload your services after a specified amount. This is useful to save RAM or keeping services from slowing down your computer.', | ||
37 | }, | ||
34 | serverInfo: { | 38 | serverInfo: { |
35 | id: 'settings.app.serverInfo', | 39 | id: 'settings.app.serverInfo', |
36 | defaultMessage: '!!!We advice you to logout after changing your server as your settings might not be saved otherwise.', | 40 | defaultMessage: '!!!We advice you to logout after changing your server as your settings might not be saved otherwise.', |
@@ -147,6 +151,7 @@ export default @observer class EditSettingsForm extends Component { | |||
147 | isWorkspaceEnabled: PropTypes.bool.isRequired, | 151 | isWorkspaceEnabled: PropTypes.bool.isRequired, |
148 | server: PropTypes.string.isRequired, | 152 | server: PropTypes.string.isRequired, |
149 | noUpdates: PropTypes.bool.isRequired, | 153 | noUpdates: PropTypes.bool.isRequired, |
154 | hibernationEnabled: PropTypes.bool.isRequired, | ||
150 | }; | 155 | }; |
151 | 156 | ||
152 | static contextTypes = { | 157 | static contextTypes = { |
@@ -181,6 +186,7 @@ export default @observer class EditSettingsForm extends Component { | |||
181 | isWorkspaceEnabled, | 186 | isWorkspaceEnabled, |
182 | server, | 187 | server, |
183 | noUpdates, | 188 | noUpdates, |
189 | hibernationEnabled, | ||
184 | } = this.props; | 190 | } = this.props; |
185 | const { intl } = this.context; | 191 | const { intl } = this.context; |
186 | 192 | ||
@@ -218,6 +224,19 @@ export default @observer class EditSettingsForm extends Component { | |||
218 | <Toggle field={form.$('enableSystemTray')} /> | 224 | <Toggle field={form.$('enableSystemTray')} /> |
219 | <Toggle field={form.$('privateNotifications')} /> | 225 | <Toggle field={form.$('privateNotifications')} /> |
220 | <Toggle field={form.$('hibernate')} /> | 226 | <Toggle field={form.$('hibernate')} /> |
227 | {hibernationEnabled && ( | ||
228 | <Select field={form.$('hibernationStrategy')} /> | ||
229 | )} | ||
230 | <p | ||
231 | className="settings__message" | ||
232 | style={{ | ||
233 | borderTop: 0, marginTop: 0, paddingTop: 0, marginBottom: '2rem', | ||
234 | }} | ||
235 | > | ||
236 | <span> | ||
237 | { intl.formatMessage(messages.hibernateInfo) } | ||
238 | </span> | ||
239 | </p> | ||
221 | {process.platform === 'win32' && ( | 240 | {process.platform === 'win32' && ( |
222 | <Toggle field={form.$('minimizeToSystemTray')} /> | 241 | <Toggle field={form.$('minimizeToSystemTray')} /> |
223 | )} | 242 | )} |