diff options
Diffstat (limited to 'src/stores')
-rw-r--r-- | src/stores/FeaturesStore.js | 11 | ||||
-rw-r--r-- | src/stores/ServicesStore.js | 16 |
2 files changed, 22 insertions, 5 deletions
diff --git a/src/stores/FeaturesStore.js b/src/stores/FeaturesStore.js index 2a0713b6f..0adee6adf 100644 --- a/src/stores/FeaturesStore.js +++ b/src/stores/FeaturesStore.js | |||
@@ -1,4 +1,4 @@ | |||
1 | import { computed, observable } from 'mobx'; | 1 | import { computed, observable, reaction } from 'mobx'; |
2 | 2 | ||
3 | import Store from './lib/Store'; | 3 | import Store from './lib/Store'; |
4 | import CachedRequest from './lib/CachedRequest'; | 4 | import CachedRequest from './lib/CachedRequest'; |
@@ -6,6 +6,7 @@ import CachedRequest from './lib/CachedRequest'; | |||
6 | import delayApp from '../features/delayApp'; | 6 | import delayApp from '../features/delayApp'; |
7 | import spellchecker from '../features/spellchecker'; | 7 | import spellchecker from '../features/spellchecker'; |
8 | import serviceProxy from '../features/serviceProxy'; | 8 | import serviceProxy from '../features/serviceProxy'; |
9 | import basicAuth from '../features/basicAuth'; | ||
9 | 10 | ||
10 | import { DEFAULT_FEATURES_CONFIG } from '../config'; | 11 | import { DEFAULT_FEATURES_CONFIG } from '../config'; |
11 | 12 | ||
@@ -21,6 +22,13 @@ export default class FeaturesStore extends Store { | |||
21 | 22 | ||
22 | await this.featuresRequest._promise; | 23 | await this.featuresRequest._promise; |
23 | setTimeout(this._enableFeatures.bind(this), 1); | 24 | setTimeout(this._enableFeatures.bind(this), 1); |
25 | |||
26 | // single key reaction | ||
27 | reaction(() => this.stores.user.data.isPremium, () => { | ||
28 | if (this.stores.user.isLoggedIn) { | ||
29 | this.featuresRequest.invalidate({ immediately: true }); | ||
30 | } | ||
31 | }); | ||
24 | } | 32 | } |
25 | 33 | ||
26 | @computed get anonymousFeatures() { | 34 | @computed get anonymousFeatures() { |
@@ -47,5 +55,6 @@ export default class FeaturesStore extends Store { | |||
47 | delayApp(this.stores, this.actions); | 55 | delayApp(this.stores, this.actions); |
48 | spellchecker(this.stores, this.actions); | 56 | spellchecker(this.stores, this.actions); |
49 | serviceProxy(this.stores, this.actions); | 57 | serviceProxy(this.stores, this.actions); |
58 | basicAuth(this.stores, this.actions); | ||
50 | } | 59 | } |
51 | } | 60 | } |
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index a618da547..f79197c38 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js | |||
@@ -1,5 +1,8 @@ | |||
1 | import { | 1 | import { |
2 | action, reaction, computed, observable, | 2 | action, |
3 | reaction, | ||
4 | computed, | ||
5 | observable, | ||
3 | } from 'mobx'; | 6 | } from 'mobx'; |
4 | import { debounce, remove } from 'lodash'; | 7 | import { debounce, remove } from 'lodash'; |
5 | 8 | ||
@@ -324,7 +327,11 @@ export default class ServicesStore extends Store { | |||
324 | service.webview = webview; | 327 | service.webview = webview; |
325 | 328 | ||
326 | if (!service.isAttached) { | 329 | if (!service.isAttached) { |
327 | service.initializeWebViewEvents(this); | 330 | debug('Webview is not attached, initializing'); |
331 | service.initializeWebViewEvents({ | ||
332 | handleIPCMessage: this.actions.service.handleIPCMessage, | ||
333 | openWindow: this.actions.service.openWindow, | ||
334 | }); | ||
328 | service.initializeWebViewListener(); | 335 | service.initializeWebViewListener(); |
329 | } | 336 | } |
330 | 337 | ||
@@ -659,14 +666,15 @@ export default class ServicesStore extends Store { | |||
659 | const service = this.one(serviceId); | 666 | const service = this.one(serviceId); |
660 | 667 | ||
661 | if (service.webview) { | 668 | if (service.webview) { |
662 | service.webview.send('initialize-recipe', service); | 669 | debug('Initialize recipe', service.recipe.id, service.name); |
670 | service.webview.send('initialize-recipe', service.shareWithWebview, service.recipe); | ||
663 | } | 671 | } |
664 | } | 672 | } |
665 | 673 | ||
666 | _initRecipePolling(serviceId) { | 674 | _initRecipePolling(serviceId) { |
667 | const service = this.one(serviceId); | 675 | const service = this.one(serviceId); |
668 | 676 | ||
669 | const delay = 1000; | 677 | const delay = 2000; |
670 | 678 | ||
671 | if (service) { | 679 | if (service) { |
672 | if (service.timer !== null) { | 680 | if (service.timer !== null) { |