From c579c6bbac7390115970d65109a1d1d4f500d920 Mon Sep 17 00:00:00 2001 From: Bennett Date: Sat, 18 Apr 2020 09:31:59 +0200 Subject: #577 Keep services in hibernation at startup (#584) * Add setting to hibernate on startup * Implement service hibernation on startup * Fix lint * Clarify comment --- src/models/Service.js | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/models/Service.js') diff --git a/src/models/Service.js b/src/models/Service.js index dc8febe0b..2f2b4572d 100644 --- a/src/models/Service.js +++ b/src/models/Service.js @@ -139,6 +139,17 @@ export default class Service { this.recipe = recipe; + // Check if "Hibernate on Startup" is enabled and hibernate all services except active one + const { + hibernate, + hibernateOnStartup, + } = window.ferdi.stores.settings.app; + // The service store is probably not loaded yet so we need to use localStorage data to get active service + const isActive = window.localStorage.service && JSON.parse(window.localStorage.service).activeService === this.id; + if (hibernate && hibernateOnStartup && !isActive) { + this.isHibernating = true; + } + autorun(() => { if (!this.isEnabled) { this.webview = null; -- cgit v1.2.3-54-g00ecf