aboutsummaryrefslogtreecommitdiffstats
path: root/src/models/Service.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/models/Service.js')
-rw-r--r--src/models/Service.js31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/models/Service.js b/src/models/Service.js
index 4b5e8592d..ef1276619 100644
--- a/src/models/Service.js
+++ b/src/models/Service.js
@@ -4,8 +4,9 @@ import normalizeUrl from 'normalize-url';
4import path from 'path'; 4import path from 'path';
5 5
6import userAgent from '../helpers/userAgent-helpers'; 6import userAgent from '../helpers/userAgent-helpers';
7import { TODOS_RECIPE_ID, todosStore } from '../features/todos';
7 8
8const debug = require('debug')('Ferdi:Service'); 9const debug = require('debug')('Franz:Service');
9 10
10export const RESTRICTION_TYPES = { 11export const RESTRICTION_TYPES = {
11 SERVICE_LIMIT: 0, 12 SERVICE_LIMIT: 0,
@@ -17,7 +18,7 @@ export default class Service {
17 18
18 recipe = ''; 19 recipe = '';
19 20
20 webview = null; 21 _webview = null;
21 22
22 timer = null; 23 timer = null;
23 24
@@ -77,13 +78,15 @@ export default class Service {
77 78
78 @observable restrictionType = null; 79 @observable restrictionType = null;
79 80
80 @observable disableHibernation = false; 81 @observable isHibernationEnabled = false;
82
83 @observable isHibernating = false;
81 84
82 @observable lastUsed = Date.now(); // timestamp 85 @observable lastUsed = Date.now(); // timestamp
83 86
84 @observable lastPoll = null; 87 @observable lastPoll = Date.now();
85 88
86 @observable lastPollAnswer = null; 89 @observable lastPollAnswer = Date.now();
87 90
88 @observable lostRecipeConnection = false; 91 @observable lostRecipeConnection = false;
89 92
@@ -136,7 +139,7 @@ export default class Service {
136 139
137 this.spellcheckerLanguage = data.spellcheckerLanguage !== undefined ? data.spellcheckerLanguage : this.spellcheckerLanguage; 140 this.spellcheckerLanguage = data.spellcheckerLanguage !== undefined ? data.spellcheckerLanguage : this.spellcheckerLanguage;
138 141
139 this.disableHibernation = data.disableHibernation !== undefined ? data.disableHibernation : this.disableHibernation; 142 this.isHibernationEnabled = data.isHibernationEnabled !== undefined ? data.isHibernationEnabled : this.isHibernationEnabled;
140 143
141 this.recipe = recipe; 144 this.recipe = recipe;
142 145
@@ -177,6 +180,18 @@ export default class Service {
177 }; 180 };
178 } 181 }
179 182
183 get webview() {
184 if (this.recipe.id === TODOS_RECIPE_ID) {
185 return todosStore.webview;
186 }
187
188 return this._webview;
189 }
190
191 set webview(webview) {
192 this._webview = webview;
193 }
194
180 @computed get url() { 195 @computed get url() {
181 if (this.recipe.hasCustomUrl && this.customUrl) { 196 if (this.recipe.hasCustomUrl && this.customUrl) {
182 let url; 197 let url;
@@ -225,6 +240,10 @@ export default class Service {
225 return ua; 240 return ua;
226 } 241 }
227 242
243 @computed get partition() {
244 return this.recipe.partition || `persist:service-${this.id}`;
245 }
246
228 247
229 initializeWebViewEvents({ handleIPCMessage, openWindow, stores }) { 248 initializeWebViewEvents({ handleIPCMessage, openWindow, stores }) {
230 const webContents = remote.webContents.fromId(this.webview.getWebContentsId()); 249 const webContents = remote.webContents.fromId(this.webview.getWebContentsId());