summaryrefslogtreecommitdiffstats
path: root/src/features/todos/store.js
diff options
context:
space:
mode:
authorLibravatar Dominik Guzei <dominik.guzei@gmail.com>2019-08-08 01:00:02 +0200
committerLibravatar Dominik Guzei <dominik.guzei@gmail.com>2019-08-08 01:02:38 +0200
commit81d368040d84a923941732ff0a696065764f12a6 (patch)
treefc5682a3ed7ed1d52672509332fbc35f3935afd5 /src/features/todos/store.js
parentUpdate en-US.json (diff)
downloadferdium-app-81d368040d84a923941732ff0a696065764f12a6.tar.gz
ferdium-app-81d368040d84a923941732ff0a696065764f12a6.tar.zst
ferdium-app-81d368040d84a923941732ff0a696065764f12a6.zip
send franz config to todos webview on init
Diffstat (limited to 'src/features/todos/store.js')
-rw-r--r--src/features/todos/store.js36
1 files changed, 28 insertions, 8 deletions
diff --git a/src/features/todos/store.js b/src/features/todos/store.js
index 79c218b65..acf95df0d 100644
--- a/src/features/todos/store.js
+++ b/src/features/todos/store.js
@@ -1,3 +1,4 @@
1import { ThemeType } from '@meetfranz/theme';
1import { 2import {
2 computed, 3 computed,
3 action, 4 action,
@@ -10,6 +11,7 @@ import { FeatureStore } from '../utils/FeatureStore';
10import { createReactions } from '../../stores/lib/Reaction'; 11import { createReactions } from '../../stores/lib/Reaction';
11import { createActionBindings } from '../utils/ActionBinding'; 12import { createActionBindings } from '../utils/ActionBinding';
12import { DEFAULT_TODOS_WIDTH, TODOS_MIN_WIDTH, DEFAULT_TODOS_VISIBLE } from '.'; 13import { DEFAULT_TODOS_WIDTH, TODOS_MIN_WIDTH, DEFAULT_TODOS_VISIBLE } from '.';
14import { IPC } from './constants';
13 15
14const debug = require('debug')('Franz:feature:todos:store'); 16const debug = require('debug')('Franz:feature:todos:store');
15 17
@@ -101,22 +103,40 @@ export default class TodoStore extends FeatureStore {
101 103
102 @action _handleHostMessage = (message) => { 104 @action _handleHostMessage = (message) => {
103 debug('_handleHostMessage', message); 105 debug('_handleHostMessage', message);
104 if (message.action === 'create:todo') { 106 if (message.action === 'todos:create') {
105 this.webview.send('hostMessage', message); 107 this.webview.send(IPC.TODOS_HOST_CHANNEL, message);
106 } 108 }
107 }; 109 };
108 110
109 @action _handleClientMessage = (message) => { 111 @action _handleClientMessage = (message) => {
110 debug('_handleClientMessage', message); 112 debug('_handleClientMessage', message);
111 if (message.action === 'goToService') { 113 switch (message.action) {
112 const { url, serviceId } = message.data; 114 case 'todos:initialized': this._onTodosClientInitialized(); break;
113 if (url) { 115 case 'todos:goToService': this._goToService(message.data); break;
114 this.stores.services.one(serviceId).webview.loadURL(url); 116 default:
115 } 117 debug('Unknown client message reiceived', message);
116 this.actions.service.setActive({ serviceId });
117 } 118 }
118 }; 119 };
119 120
121 // Todos client message handlers
122
123 _onTodosClientInitialized = () => {
124 this.webview.send(IPC.TODOS_HOST_CHANNEL, {
125 action: 'todos:configure',
126 data: {
127 authToken: this.stores.user.authToken,
128 theme: this.stores.ui.isDarkThemeActive ? ThemeType.dark : ThemeType.default,
129 },
130 });
131 };
132
133 _goToService = ({ url, serviceId }) => {
134 if (url) {
135 this.stores.services.one(serviceId).webview.loadURL(url);
136 }
137 this.actions.service.setActive({ serviceId });
138 };
139
120 // Reactions 140 // Reactions
121 141
122 _setFeatureEnabledReaction = () => { 142 _setFeatureEnabledReaction = () => {