From 26c075372a1bb461752c873cfed0a96b10a4bba9 Mon Sep 17 00:00:00 2001 From: vantezzen Date: Sun, 6 Oct 2019 15:09:32 +0200 Subject: Add option to choose hibernation strategy --- src/components/services/content/ServiceView.js | 5 +- .../settings/settings/EditSettingsForm.js | 19 ++ src/config.js | 11 + src/containers/settings/EditSettingsScreen.js | 19 +- src/helpers/i18n-helpers.js | 10 +- src/i18n/locales/defaultMessages.json | 190 ++++++++++------- src/i18n/locales/en-US.json | 2 + src/i18n/locales/zh-HANT.json | 237 +++++++++++---------- .../settings/settings/EditSettingsForm.json | 109 +++++----- .../containers/settings/EditSettingsScreen.json | 81 ++++--- 10 files changed, 396 insertions(+), 287 deletions(-) (limited to 'src') 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'; import { autorun, reaction } from 'mobx'; import { observer, inject } from 'mobx-react'; import classnames from 'classnames'; -import ms from 'ms'; import ServiceModel from '../../../models/Service'; import StatusBarTargetUrl from '../../ui/StatusBarTargetUrl'; @@ -104,11 +103,13 @@ export default @observer @inject('stores') class ServiceView extends Component { }; startHibernationTimer() { + const timerDuration = (Number(this.props.stores.settings.all.app.hibernationStrategy) || 300) * 1000; + const hibernationTimer = setTimeout(() => { this.setState({ hibernate: true, }); - }, ms('5m')); + }, timerDuration); this.setState({ 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({ id: 'settings.app.headlineGeneral', defaultMessage: '!!!General', }, + hibernateInfo: { + id: 'settings.app.hibernateInfo', + 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.', + }, serverInfo: { id: 'settings.app.serverInfo', 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 { isWorkspaceEnabled: PropTypes.bool.isRequired, server: PropTypes.string.isRequired, noUpdates: PropTypes.bool.isRequired, + hibernationEnabled: PropTypes.bool.isRequired, }; static contextTypes = { @@ -181,6 +186,7 @@ export default @observer class EditSettingsForm extends Component { isWorkspaceEnabled, server, noUpdates, + hibernationEnabled, } = this.props; const { intl } = this.context; @@ -218,6 +224,19 @@ export default @observer class EditSettingsForm extends Component { + {hibernationEnabled && ( +