summaryrefslogtreecommitdiffstats
path: root/src/features/todos/store.js
diff options
context:
space:
mode:
authorLibravatar Dominik Guzei <dominik.guzei@gmail.com>2019-07-31 17:08:29 +0200
committerLibravatar Dominik Guzei <dominik.guzei@gmail.com>2019-07-31 17:08:29 +0200
commitbd49d59008d64db13e3f37277ec873a3a464ef9e (patch)
tree7d4f4a943477e543abbcacd2ceb2ac0002054910 /src/features/todos/store.js
parentMerge branch 'develop' into feature/todos (diff)
downloadferdium-app-bd49d59008d64db13e3f37277ec873a3a464ef9e.tar.gz
ferdium-app-bd49d59008d64db13e3f37277ec873a3a464ef9e.tar.zst
ferdium-app-bd49d59008d64db13e3f37277ec873a3a464ef9e.zip
MVP for service <-> todos integration
Diffstat (limited to 'src/features/todos/store.js')
-rw-r--r--src/features/todos/store.js29
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 = () => {