Skip to content
Permalink
Browse files
feat(Service): Add service hibernation to save system resources
  • Loading branch information
adlk committed Feb 20, 2020
1 parent a406262 commit cb92dd7f1f442829ad5a31b1965e96415871f344
Showing 10 changed files with 175 additions and 47 deletions.
@@ -91,4 +91,10 @@ export default {
serviceId: PropTypes.string.isRequired,
},
openDevToolsForActiveService: {},
hibernate: {
serviceId: PropTypes.string.isRequired,
},
awake: {
serviceId: PropTypes.string.isRequired,
},
};
@@ -143,11 +143,13 @@ export default @observer class ServiceView extends Component {
{service.recipe.id === CUSTOM_WEBSITE_ID && (
<WebControlsScreen service={service} />
)}
<ServiceWebview
service={service}
setWebviewReference={setWebviewReference}
detachService={detachService}
/>
{!service.isHibernating && (
<ServiceWebview
service={service}
setWebviewReference={setWebviewReference}
detachService={detachService}
/>
)}
</>
)}
</>
@@ -77,6 +77,10 @@ const messages = defineMessages({
id: 'settings.service.form.isMutedInfo',
defaultMessage: '!!!When disabled, all notification sounds and audio playback are muted',
},
isHibernationEnabledInfo: {
id: 'settings.service.form.isHibernatedEnabledInfo',
defaultMessage: '!!!When enabled, a service will be shut down after a period of time to save system resources.',
},
headlineNotifications: {
id: 'settings.service.form.headlineNotifications',
defaultMessage: '!!!Notifications',
@@ -333,6 +337,10 @@ export default @observer class EditServiceForm extends Component {
<Toggle field={form.$('isDarkModeEnabled')} />
)}
<Toggle field={form.$('isEnabled')} />
<Toggle field={form.$('isHibernationEnabled')} />
<p className="settings__help">
{intl.formatMessage(messages.isHibernationEnabledInfo)}
</p>
</div>
</div>
<div className="service-icon">
@@ -33,6 +33,10 @@ const messages = defineMessages({
id: 'settings.service.form.enableService',
defaultMessage: '!!!Enable service',
},
enableHibernation: {
id: 'settings.service.form.enableHibernation',
defaultMessage: '!!!Enable hibernation',
},
enableNotification: {
id: 'settings.service.form.enableNotification',
defaultMessage: '!!!Enable Notifications',
@@ -114,8 +118,11 @@ export default @inject('stores', 'actions') @observer class EditServiceScreen ex

const {
stores,
router,
} = this.props;

const { action } = router.params;

let defaultSpellcheckerLanguage = SPELLCHECKER_LOCALES[stores.settings.app.spellcheckerLanguage];

if (stores.settings.app.spellcheckerLanguage === 'automatic') {
@@ -140,6 +147,11 @@ export default @inject('stores', 'actions') @observer class EditServiceScreen ex
value: service.isEnabled,
default: true,
},
isHibernationEnabled: {
label: intl.formatMessage(messages.enableHibernation),
value: action !== 'edit' ? recipe.autoHibernate : service.isHibernationEnabled,
default: true,
},
isNotificationEnabled: {
label: intl.formatMessage(messages.enableNotification),
value: service.isNotificationEnabled,
@@ -298,6 +298,7 @@
"settings.service.form.enableAudio": "Enable audio",
"settings.service.form.enableBadge": "Show unread message badges",
"settings.service.form.enableDarkMode": "Enable Dark Mode",
"settings.service.form.enableHibernation": "Enable hibernation",
"settings.service.form.enableNotification": "Enable notifications",
"settings.service.form.enableService": "Enable service",
"settings.service.form.headlineBadges": "Unread message badges",
@@ -308,6 +309,7 @@
"settings.service.form.iconUpload": "Drop your image, or click here",
"settings.service.form.indirectMessageInfo": "You will be notified about all new messages in a channel, not just @username, @channel, @here, ...",
"settings.service.form.indirectMessages": "Show message badge for all new messages",
"settings.service.form.isHibernatedEnabledInfo": "When enabled, a service will be shut down after a period of time to save system resources.",
"settings.service.form.isMutedInfo": "When disabled, all notification sounds and audio playback are muted",
"settings.service.form.name": "Name",
"settings.service.form.proxy.headline": "HTTP/HTTPS Proxy Settings",
@@ -181,16 +181,29 @@
"column": 3
}
},
{
"id": "settings.service.form.isHibernatedEnabledInfo",
"defaultMessage": "!!!When enabled, a service will be shut down after a period of time to save system resources.",
"file": "src/components/settings/services/EditServiceForm.js",
"start": {
"line": 80,
"column": 28
},
"end": {
"line": 83,
"column": 3
}
},
{
"id": "settings.service.form.headlineNotifications",
"defaultMessage": "!!!Notifications",
"file": "src/components/settings/services/EditServiceForm.js",
"start": {
"line": 80,
"line": 84,
"column": 25
},
"end": {
"line": 83,
"line": 87,
"column": 3
}
},
@@ -199,11 +212,11 @@
"defaultMessage": "!!!Unread message badges",
"file": "src/components/settings/services/EditServiceForm.js",
"start": {
"line": 84,
"line": 88,
"column": 18
},
"end": {
"line": 87,
"line": 91,
"column": 3
}
},
@@ -212,11 +225,11 @@
"defaultMessage": "!!!General",
"file": "src/components/settings/services/EditServiceForm.js",
"start": {
"line": 88,
"line": 92,
"column": 19
},
"end": {
"line": 91,
"line": 95,
"column": 3
}
},
@@ -225,11 +238,11 @@
"defaultMessage": "!!!Delete",
"file": "src/components/settings/services/EditServiceForm.js",
"start": {
"line": 92,
"line": 96,
"column": 14
},
"end": {
"line": 95,
"line": 99,
"column": 3
}
},
@@ -238,11 +251,11 @@
"defaultMessage": "!!!Drop your image, or click here",
"file": "src/components/settings/services/EditServiceForm.js",
"start": {
"line": 96,
"line": 100,
"column": 14
},
"end": {
"line": 99,
"line": 103,
"column": 3
}
},
@@ -251,11 +264,11 @@
"defaultMessage": "!!!HTTP/HTTPS Proxy Settings",
"file": "src/components/settings/services/EditServiceForm.js",
"start": {
"line": 100,
"line": 104,
"column": 17
},
"end": {
"line": 103,
"line": 107,
"column": 3
}
},
@@ -264,11 +277,11 @@
"defaultMessage": "!!!Please restart Franz after changing proxy Settings.",
"file": "src/components/settings/services/EditServiceForm.js",
"start": {
"line": 104,
"line": 108,
"column": 20
},
"end": {
"line": 107,
"line": 111,
"column": 3
}
},
@@ -277,11 +290,11 @@
"defaultMessage": "!!!Proxy settings will not be synchronized with the Franz servers.",
"file": "src/components/settings/services/EditServiceForm.js",
"start": {
"line": 108,
"line": 112,
"column": 13
},
"end": {
"line": 111,
"line": 115,
"column": 3
}
}

0 comments on commit cb92dd7

Please sign in to comment.