From c96bd71d41a6454022cf4ef25365ebbde8a8cd3d Mon Sep 17 00:00:00 2001 From: vantezzen Date: Sun, 27 Oct 2019 10:24:23 +0100 Subject: Remove hiberation hack as observer is fixed --- src/components/services/content/ServiceView.js | 30 ++++++-------------------- 1 file changed, 6 insertions(+), 24 deletions(-) (limited to 'src/components/services/content/ServiceView.js') diff --git a/src/components/services/content/ServiceView.js b/src/components/services/content/ServiceView.js index 49ee24361..1fff5ef7a 100644 --- a/src/components/services/content/ServiceView.js +++ b/src/components/services/content/ServiceView.js @@ -42,10 +42,10 @@ export default @inject('stores', 'actions') @observer class ServiceView extends forceRepaint: false, targetUrl: '', statusBarVisible: false, - hibernate: false, - hibernationTimer: null, }; + hibernationTimer = null; + autorunDisposer = null; forceRepaintTimeout = null; @@ -73,15 +73,12 @@ export default @inject('stores', 'actions') @observer class ServiceView extends // Service is inactive - start hibernation countdown this.startHibernationTimer(); } else { - if (this.state.hibernationTimer) { + if (this.hibernationTimer) { // Service is active but we have an active hibernation timer: Clear timeout - clearTimeout(this.state.hibernationTimer); + clearTimeout(this.hibernationTimer); } // Service is active, wake up service from hibernation - this.setState({ - hibernate: false, - }); this.props.actions.service.setHibernation({ serviceId: this.props.service.id, hibernating: false, @@ -90,16 +87,6 @@ export default @inject('stores', 'actions') @observer class ServiceView extends }, ); - // 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(); @@ -126,18 +113,13 @@ export default @inject('stores', 'actions') @observer class ServiceView extends const timerDuration = (Number(this.props.stores.settings.all.app.hibernationStrategy) || 300) * 1000; const hibernationTimer = setTimeout(() => { - this.setState({ - hibernate: true, - }); this.props.actions.service.setHibernation({ serviceId: this.props.service.id, hibernating: true, }); }, timerDuration); - this.setState({ - hibernationTimer, - }); + this.hibernationTimer = hibernationTimer; } render() { @@ -208,7 +190,7 @@ export default @inject('stores', 'actions') @observer class ServiceView extends ) : ( <> - {!this.state.hibernate ? ( + {!service.isHibernating ? ( <> {(service.recipe.id === CUSTOM_WEBSITE_ID || showServiceNavigationBar) && ( -- cgit v1.2.3-54-g00ecf