diff options
author | 2021-07-23 10:04:43 +0100 | |
---|---|---|
committer | 2021-07-23 11:04:43 +0200 | |
commit | 012e55ebf87559f2d782e5400fb885df8b80a445 (patch) | |
tree | 1966e58defe2bcd9541ca9a3f4db67a95a6b4249 /src/stores | |
parent | Removed references to 'premium' i18n keys that are no longer used. (diff) | |
download | ferdium-app-012e55ebf87559f2d782e5400fb885df8b80a445.tar.gz ferdium-app-012e55ebf87559f2d782e5400fb885df8b80a445.tar.zst ferdium-app-012e55ebf87559f2d782e5400fb885df8b80a445.zip |
Fix hibernation mode (#1486)
* Use hibernation strategy from settings instead of hardcoded 5 minutes
* Fix conditions with isHibernationEnabled, previously disableHibernation
* Make service hibernation obey global setting
Also refactors hibernation to move some hibernation enablement logic
into the Service model
* Remove global hibernation enable switch
Implements option 4 from
https://github.com/getferdi/ferdi/pull/1486#issuecomment-860290992
according to
https://github.com/getferdi/ferdi/pull/1486#issuecomment-876558694
* Implements #865 : Add 'hibernate service' and 'wake up service' in the sidebar context menu.
* Removed 'hibernationEnabled' check on main settings screen
Since this is an (imo) incongruous behavior for the first time user.
They will see a message, but with no ability to choose the hibernation strategy.
* Autogenerated files from conflict fixes
Co-authored-by: Kristóf Marussy <kristof@marussy.com>
Co-authored-by: Vijay A <avijayr@protonmail.com>
Diffstat (limited to 'src/stores')
-rw-r--r-- | src/stores/ServicesStore.js | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index 9521f8493..6064b9929 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js | |||
@@ -166,8 +166,8 @@ export default class ServicesStore extends Store { | |||
166 | _serviceMaintenance() { | 166 | _serviceMaintenance() { |
167 | this.all.forEach((service) => { | 167 | this.all.forEach((service) => { |
168 | // Defines which services should be hibernated. | 168 | // Defines which services should be hibernated. |
169 | if (!service.isActive && (Date.now() - service.lastUsed > ms('5m'))) { | 169 | if (!service.isActive && (Date.now() - service.lastUsed > ms(`${this.stores.settings.all.app.hibernationStrategy}s`))) { |
170 | // If service is stale for 5 min, hibernate it. | 170 | // If service is stale, hibernate it. |
171 | this._hibernate({ serviceId: service.id }); | 171 | this._hibernate({ serviceId: service.id }); |
172 | } | 172 | } |
173 | 173 | ||
@@ -820,19 +820,23 @@ export default class ServicesStore extends Store { | |||
820 | 820 | ||
821 | @action _hibernate({ serviceId }) { | 821 | @action _hibernate({ serviceId }) { |
822 | const service = this.one(serviceId); | 822 | const service = this.one(serviceId); |
823 | if (service.isActive || !service.isHibernationEnabled) { | 823 | if (!service.canHibernate) { |
824 | return; | ||
825 | } | ||
826 | if (service.isActive) { | ||
824 | debug('Skipping service hibernation'); | 827 | debug('Skipping service hibernation'); |
825 | return; | 828 | return; |
826 | } | 829 | } |
827 | 830 | ||
828 | debug(`Hibernate ${service.name}`); | 831 | debug(`Hibernate ${service.name}`); |
829 | 832 | ||
830 | service.isHibernating = true; | 833 | service.isHibernationRequested = true; |
831 | } | 834 | } |
832 | 835 | ||
833 | @action _awake({ serviceId }) { | 836 | @action _awake({ serviceId }) { |
837 | debug('Waking up from service hibernation'); | ||
834 | const service = this.one(serviceId); | 838 | const service = this.one(serviceId); |
835 | service.isHibernating = false; | 839 | service.isHibernationRequested = false; |
836 | service.liveFrom = Date.now(); | 840 | service.liveFrom = Date.now(); |
837 | } | 841 | } |
838 | 842 | ||