diff options
Diffstat (limited to 'src/models')
-rw-r--r-- | src/models/Recipe.js | 4 | ||||
-rw-r--r-- | src/models/Service.js | 31 |
2 files changed, 29 insertions, 6 deletions
diff --git a/src/models/Recipe.js b/src/models/Recipe.js index dcb998a19..a20eeb087 100644 --- a/src/models/Recipe.js +++ b/src/models/Recipe.js | |||
@@ -40,6 +40,8 @@ export default class Recipe { | |||
40 | 40 | ||
41 | autoHibernate = false; | 41 | autoHibernate = false; |
42 | 42 | ||
43 | partition = ''; | ||
44 | |||
43 | constructor(data) { | 45 | constructor(data) { |
44 | if (!data) { | 46 | if (!data) { |
45 | throw Error('Recipe config not valid'); | 47 | throw Error('Recipe config not valid'); |
@@ -82,6 +84,8 @@ export default class Recipe { | |||
82 | 84 | ||
83 | this.autoHibernate = data.config.autoHibernate || this.autoHibernate; | 85 | this.autoHibernate = data.config.autoHibernate || this.autoHibernate; |
84 | 86 | ||
87 | this.partition = data.config.partition || this.partition; | ||
88 | |||
85 | this.message = data.config.message || this.message; | 89 | this.message = data.config.message || this.message; |
86 | } | 90 | } |
87 | 91 | ||
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'; | |||
4 | import path from 'path'; | 4 | import path from 'path'; |
5 | 5 | ||
6 | import userAgent from '../helpers/userAgent-helpers'; | 6 | import userAgent from '../helpers/userAgent-helpers'; |
7 | import { TODOS_RECIPE_ID, todosStore } from '../features/todos'; | ||
7 | 8 | ||
8 | const debug = require('debug')('Ferdi:Service'); | 9 | const debug = require('debug')('Franz:Service'); |
9 | 10 | ||
10 | export const RESTRICTION_TYPES = { | 11 | export 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()); |