diff options
Diffstat (limited to 'src/features/todos/store.js')
-rw-r--r-- | src/features/todos/store.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/features/todos/store.js b/src/features/todos/store.js index e7e13b37f..737902946 100644 --- a/src/features/todos/store.js +++ b/src/features/todos/store.js | |||
@@ -18,6 +18,8 @@ export default class TodoStore extends FeatureStore { | |||
18 | 18 | ||
19 | @observable isFeatureActive = false; | 19 | @observable isFeatureActive = false; |
20 | 20 | ||
21 | webview = null; | ||
22 | |||
21 | @computed get width() { | 23 | @computed get width() { |
22 | const width = this.settings.width || DEFAULT_TODOS_WIDTH; | 24 | const width = this.settings.width || DEFAULT_TODOS_WIDTH; |
23 | 25 | ||
@@ -39,6 +41,9 @@ export default class TodoStore extends FeatureStore { | |||
39 | 41 | ||
40 | this._registerActions(createActionBindings([ | 42 | this._registerActions(createActionBindings([ |
41 | [todoActions.resize, this._resize], | 43 | [todoActions.resize, this._resize], |
44 | [todoActions.setTodosWebview, this._setTodosWebview], | ||
45 | [todoActions.handleHostMessage, this._handleHostMessage], | ||
46 | [todoActions.handleClientMessage, this._handleClientMessage], | ||
42 | ])); | 47 | ])); |
43 | 48 | ||
44 | // REACTIONS | 49 | // REACTIONS |
@@ -76,6 +81,30 @@ export default class TodoStore extends FeatureStore { | |||
76 | }); | 81 | }); |
77 | }; | 82 | }; |
78 | 83 | ||
84 | @action _setTodosWebview = ({ webview }) => { | ||
85 | debug('_setTodosWebview', webview); | ||
86 | this.webview = webview; | ||
87 | }; | ||
88 | |||
89 | @action _handleHostMessage = (message) => { | ||
90 | debug('_handleHostMessage', message); | ||
91 | if (message.action === 'create:todo') { | ||
92 | console.log(this.webview); | ||
93 | this.webview.send('hostMessage', message); | ||
94 | } | ||
95 | }; | ||
96 | |||
97 | @action _handleClientMessage = (message) => { | ||
98 | debug('_handleClientMessage', message); | ||
99 | if (message.action === 'goToService') { | ||
100 | const { url, serviceId } = message.data; | ||
101 | if (url) { | ||
102 | this.stores.services.one(serviceId).webview.loadURL(url); | ||
103 | } | ||
104 | this.actions.service.setActive({ serviceId }); | ||
105 | } | ||
106 | }; | ||
107 | |||
79 | // Reactions | 108 | // Reactions |
80 | 109 | ||
81 | _setFeatureEnabledReaction = () => { | 110 | _setFeatureEnabledReaction = () => { |