aboutsummaryrefslogtreecommitdiffstats
path: root/src/models/Service.js
diff options
context:
space:
mode:
authorLibravatar kytwb <412895+kytwb@users.noreply.github.com>2021-07-23 10:04:43 +0100
committerLibravatar GitHub <noreply@github.com>2021-07-23 11:04:43 +0200
commit012e55ebf87559f2d782e5400fb885df8b80a445 (patch)
tree1966e58defe2bcd9541ca9a3f4db67a95a6b4249 /src/models/Service.js
parentRemoved references to 'premium' i18n keys that are no longer used. (diff)
downloadferdium-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/models/Service.js')
-rw-r--r--src/models/Service.js21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/models/Service.js b/src/models/Service.js
index 397950787..162dcea65 100644
--- a/src/models/Service.js
+++ b/src/models/Service.js
@@ -37,8 +37,6 @@ export default class Service {
37 37
38 @observable isMuted = false; 38 @observable isMuted = false;
39 39
40 @observable isHibernating = false;
41
42 @observable team = ''; 40 @observable team = '';
43 41
44 @observable customUrl = ''; 42 @observable customUrl = '';
@@ -77,7 +75,7 @@ export default class Service {
77 75
78 @observable isHibernationEnabled = false; 76 @observable isHibernationEnabled = false;
79 77
80 @observable isHibernating = false; 78 @observable isHibernationRequested = false;
81 79
82 @observable lastUsed = Date.now(); // timestamp 80 @observable lastUsed = Date.now(); // timestamp
83 81
@@ -145,14 +143,11 @@ export default class Service {
145 this.recipe = recipe; 143 this.recipe = recipe;
146 144
147 // Check if "Hibernate on Startup" is enabled and hibernate all services except active one 145 // Check if "Hibernate on Startup" is enabled and hibernate all services except active one
148 const { 146 const { hibernateOnStartup } = window.ferdi.stores.settings.app;
149 hibernate,
150 hibernateOnStartup,
151 } = window.ferdi.stores.settings.app;
152 // The service store is probably not loaded yet so we need to use localStorage data to get active service 147 // The service store is probably not loaded yet so we need to use localStorage data to get active service
153 const isActive = window.localStorage.service && JSON.parse(window.localStorage.service).activeService === this.id; 148 const isActive = window.localStorage.service && JSON.parse(window.localStorage.service).activeService === this.id;
154 if (hibernate && hibernateOnStartup && !isActive) { 149 if (hibernateOnStartup && !isActive) {
155 this.isHibernating = true; 150 this.isHibernationRequested = true;
156 } 151 }
157 152
158 autorun(() => { 153 autorun(() => {
@@ -185,6 +180,14 @@ export default class Service {
185 return this.recipe.id === todosStore.todoRecipeId; 180 return this.recipe.id === todosStore.todoRecipeId;
186 } 181 }
187 182
183 @computed get canHibernate() {
184 return this.isHibernationEnabled;
185 }
186
187 @computed get isHibernating() {
188 return this.canHibernate && this.isHibernationRequested;
189 }
190
188 get webview() { 191 get webview() {
189 if (this.isTodosService) { 192 if (this.isTodosService) {
190 return todosStore.webview; 193 return todosStore.webview;