From 6ae97425b0c0da181a9ec26e52535ceadd1f4e46 Mon Sep 17 00:00:00 2001 From: vantezzen Date: Sun, 13 Oct 2019 13:09:29 +0200 Subject: Add indicator for hibernating services --- src/components/services/content/ServiceView.js | 25 ++++++++++++++++++++++++- src/components/services/tabs/TabItem.js | 5 +++++ 2 files changed, 29 insertions(+), 1 deletion(-) (limited to 'src/components') diff --git a/src/components/services/content/ServiceView.js b/src/components/services/content/ServiceView.js index 041e9941d..664a494c1 100644 --- a/src/components/services/content/ServiceView.js +++ b/src/components/services/content/ServiceView.js @@ -15,7 +15,7 @@ import SettingsStore from '../../../stores/SettingsStore'; import WebControlsScreen from '../../../features/webControls/containers/WebControlsScreen'; import { CUSTOM_WEBSITE_ID } from '../../../features/webControls/constants'; -export default @observer @inject('stores') class ServiceView extends Component { +export default @observer @inject('stores', 'actions') class ServiceView extends Component { static propTypes = { service: PropTypes.instanceOf(ServiceModel).isRequired, setWebviewReference: PropTypes.func.isRequired, @@ -27,6 +27,11 @@ export default @observer @inject('stores') class ServiceView extends Component { stores: PropTypes.shape({ settings: PropTypes.instanceOf(SettingsStore).isRequired, }).isRequired, + actions: PropTypes.shape({ + service: PropTypes.shape({ + setHibernation: PropTypes.func.isRequired, + }).isRequired, + }).isRequired, }; static defaultProps = { @@ -77,10 +82,24 @@ export default @observer @inject('stores') class ServiceView extends Component { this.setState({ hibernate: false, }); + this.props.actions.service.setHibernation({ + serviceId: this.props.service.id, + hibernating: false, + }); } }, ); + // Store hibernation status to state, otherwise the webview won't get unloaded correctly + reaction( + () => this.props.service.isHibernating, + () => { + this.setState({ + hibernate: this.props.service.isHibernating, + }); + }, + ); + // Start hibernation counter if we are in background if (!this.props.service.isActive && this.props.stores.settings.all.app.hibernate) { this.startHibernationTimer(); @@ -110,6 +129,10 @@ export default @observer @inject('stores') class ServiceView extends Component { this.setState({ hibernate: true, }); + this.props.actions.service.setHibernation({ + serviceId: this.props.service.id, + hibernating: true, + }); }, timerDuration); this.setState({ diff --git a/src/components/services/tabs/TabItem.js b/src/components/services/tabs/TabItem.js index 8de7dc438..36338a910 100644 --- a/src/components/services/tabs/TabItem.js +++ b/src/components/services/tabs/TabItem.js @@ -145,6 +145,11 @@ class TabItem extends Component { • )} + {service.isHibernating && ( + + • + + )} ); } -- cgit v1.2.3-70-g09d2