From 5398846e58d87f5ef54ccc19f4ccb318166ef621 Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Wed, 28 Mar 2018 10:12:03 +0200 Subject: Replace share settings with webviews autorun with single key reaction --- src/stores/ServicesStore.js | 14 +++++++++----- src/webview/plugin.js | 6 +++++- 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index 6dfc114f5..ccb85421a 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js @@ -1,8 +1,5 @@ -// import { remote } from 'electron'; -import { action, computed, observable } from 'mobx'; +import { action, reaction, computed, observable } from 'mobx'; import { debounce, remove } from 'lodash'; -// import path from 'path'; -// import fs from 'fs-extra'; import Store from './lib/Store'; import Request from './lib/Request'; @@ -63,13 +60,20 @@ export default class ServicesStore extends Store { this._mapActiveServiceToServiceModelReaction.bind(this), this._saveActiveService.bind(this), this._logoutReaction.bind(this), - this._shareSettingsWithServiceProcess.bind(this), ]); // Just bind this this._initializeServiceRecipeInWebview.bind(this); } + setup() { + // Single key reactions + reaction( + () => this.stores.settings.all.app.enableSpellchecking, + () => this._shareSettingsWithServiceProcess(), + ); + } + @computed get all() { if (this.stores.user.isLoggedIn) { const services = this.allServicesRequest.execute().result; diff --git a/src/webview/plugin.js b/src/webview/plugin.js index 52b19b3fd..c6530fef6 100644 --- a/src/webview/plugin.js +++ b/src/webview/plugin.js @@ -8,6 +8,8 @@ import RecipeWebview from './lib/RecipeWebview'; import Spellchecker from './spellchecker'; import './notifications'; +const debug = require('debug')('Plugin'); + ipcRenderer.on('initializeRecipe', (e, data) => { const modulePath = path.join(data.recipe.path, 'webview.js'); // Delete module from cache @@ -15,8 +17,9 @@ ipcRenderer.on('initializeRecipe', (e, data) => { try { // eslint-disable-next-line require(modulePath)(new RecipeWebview(), data); + debug('Initialize Recipe'); } catch (err) { - console.error(err); + debug('Recipe initialization failed', err); } }); @@ -31,6 +34,7 @@ new ContextMenuListener((info) => { // eslint-disable-line ipcRenderer.on('settings-update', (e, data) => { spellchecker.toggleSpellchecker(data.enableSpellchecking); + debug('Settings update received', data); }); // initSpellche -- cgit v1.2.3-70-g09d2