diff options
Diffstat (limited to 'src/features/todos/store.js')
-rw-r--r-- | src/features/todos/store.js | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/features/todos/store.js b/src/features/todos/store.js index 41e632b49..9ece76327 100644 --- a/src/features/todos/store.js +++ b/src/features/todos/store.js | |||
@@ -18,8 +18,7 @@ import { createActionBindings } from '../utils/ActionBinding'; | |||
18 | import { IPC, TODOS_ROUTES } from './constants'; | 18 | import { IPC, TODOS_ROUTES } from './constants'; |
19 | import UserAgent from '../../models/UserAgent'; | 19 | import UserAgent from '../../models/UserAgent'; |
20 | 20 | ||
21 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed | 21 | const debug = require('../../preload-safe-debug')('Ferdium:feature:todos:store'); |
22 | // const debug = require('debug')('Ferdium:feature:todos:store'); | ||
23 | 22 | ||
24 | export default class TodoStore extends FeatureStore { | 23 | export default class TodoStore extends FeatureStore { |
25 | @observable stores = null; | 24 | @observable stores = null; |
@@ -97,7 +96,7 @@ export default class TodoStore extends FeatureStore { | |||
97 | // ========== PUBLIC API ========= // | 96 | // ========== PUBLIC API ========= // |
98 | 97 | ||
99 | @action start(stores, actions) { | 98 | @action start(stores, actions) { |
100 | console.log('TodoStore::start'); | 99 | debug('TodoStore::start'); |
101 | this.stores = stores; | 100 | this.stores = stores; |
102 | this.actions = actions; | 101 | this.actions = actions; |
103 | 102 | ||
@@ -134,7 +133,7 @@ export default class TodoStore extends FeatureStore { | |||
134 | 133 | ||
135 | @action stop() { | 134 | @action stop() { |
136 | super.stop(); | 135 | super.stop(); |
137 | console.log('TodoStore::stop'); | 136 | debug('TodoStore::stop'); |
138 | this.reset(); | 137 | this.reset(); |
139 | this.isFeatureActive = false; | 138 | this.isFeatureActive = false; |
140 | } | 139 | } |
@@ -163,7 +162,7 @@ export default class TodoStore extends FeatureStore { | |||
163 | }; | 162 | }; |
164 | 163 | ||
165 | @action _setTodosWebview = ({ webview }) => { | 164 | @action _setTodosWebview = ({ webview }) => { |
166 | console.log('_setTodosWebview', webview); | 165 | debug('_setTodosWebview', webview); |
167 | if (this.webview !== webview) { | 166 | if (this.webview !== webview) { |
168 | this.webview = webview; | 167 | this.webview = webview; |
169 | this.userAgentModel.setWebviewReference(webview); | 168 | this.userAgentModel.setWebviewReference(webview); |
@@ -171,14 +170,14 @@ export default class TodoStore extends FeatureStore { | |||
171 | }; | 170 | }; |
172 | 171 | ||
173 | @action _handleHostMessage = message => { | 172 | @action _handleHostMessage = message => { |
174 | console.log('_handleHostMessage', message); | 173 | debug('_handleHostMessage', message); |
175 | if (message.action === 'todos:create') { | 174 | if (message.action === 'todos:create') { |
176 | this.webview.send(IPC.TODOS_HOST_CHANNEL, message); | 175 | this.webview.send(IPC.TODOS_HOST_CHANNEL, message); |
177 | } | 176 | } |
178 | }; | 177 | }; |
179 | 178 | ||
180 | @action _handleClientMessage = ({ channel, message = {} }) => { | 179 | @action _handleClientMessage = ({ channel, message = {} }) => { |
181 | console.log('_handleClientMessage', channel, message); | 180 | debug('_handleClientMessage', channel, message); |
182 | switch (message.action) { | 181 | switch (message.action) { |
183 | case 'todos:initialized': | 182 | case 'todos:initialized': |
184 | this._onTodosClientInitialized(); | 183 | this._onTodosClientInitialized(); |
@@ -187,7 +186,7 @@ export default class TodoStore extends FeatureStore { | |||
187 | this._goToService(message.data); | 186 | this._goToService(message.data); |
188 | break; | 187 | break; |
189 | default: | 188 | default: |
190 | console.log('Other message received', channel, message); | 189 | debug('Other message received', channel, message); |
191 | if (this.stores.services.isTodosServiceAdded) { | 190 | if (this.stores.services.isTodosServiceAdded) { |
192 | this.actions.service.handleIPCMessage({ | 191 | this.actions.service.handleIPCMessage({ |
193 | serviceId: this.stores.services.isTodosServiceAdded.id, | 192 | serviceId: this.stores.services.isTodosServiceAdded.id, |
@@ -203,7 +202,7 @@ export default class TodoStore extends FeatureStore { | |||
203 | }; | 202 | }; |
204 | 203 | ||
205 | @action _toggleTodosFeatureVisibility = () => { | 204 | @action _toggleTodosFeatureVisibility = () => { |
206 | console.log('_toggleTodosFeatureVisibility'); | 205 | debug('_toggleTodosFeatureVisibility'); |
207 | 206 | ||
208 | this._updateSettings({ | 207 | this._updateSettings({ |
209 | isFeatureEnabledByUser: !this.settings.isFeatureEnabledByUser, | 208 | isFeatureEnabledByUser: !this.settings.isFeatureEnabledByUser, |
@@ -211,14 +210,14 @@ export default class TodoStore extends FeatureStore { | |||
211 | }; | 210 | }; |
212 | 211 | ||
213 | _openDevTools = () => { | 212 | _openDevTools = () => { |
214 | console.log('_openDevTools'); | 213 | debug('_openDevTools'); |
215 | 214 | ||
216 | const webview = document.querySelector('#todos-panel webview'); | 215 | const webview = document.querySelector('#todos-panel webview'); |
217 | if (webview) webview.openDevTools(); | 216 | if (webview) webview.openDevTools(); |
218 | }; | 217 | }; |
219 | 218 | ||
220 | _reload = () => { | 219 | _reload = () => { |
221 | console.log('_reload'); | 220 | debug('_reload'); |
222 | 221 | ||
223 | const webview = document.querySelector('#todos-panel webview'); | 222 | const webview = document.querySelector('#todos-panel webview'); |
224 | if (webview) webview.reload(); | 223 | if (webview) webview.reload(); |
@@ -286,7 +285,7 @@ export default class TodoStore extends FeatureStore { | |||
286 | const { pathname } = this.stores.router.location; | 285 | const { pathname } = this.stores.router.location; |
287 | 286 | ||
288 | if (pathname === TODOS_ROUTES.TARGET) { | 287 | if (pathname === TODOS_ROUTES.TARGET) { |
289 | console.log('Router is on todos route, show todos panel'); | 288 | debug('Router is on todos route, show todos panel'); |
290 | // todosStore.start(stores, actions); | 289 | // todosStore.start(stores, actions); |
291 | this.stores.router.push('/'); | 290 | this.stores.router.push('/'); |
292 | 291 | ||