From bae9c632654b3fb67c478997b13e3b85874884d7 Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Sun, 12 Nov 2017 21:38:31 +0100 Subject: es6 refactor --- src/webview/plugin.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/webview') diff --git a/src/webview/plugin.js b/src/webview/plugin.js index ffc9084e4..569fa9493 100644 --- a/src/webview/plugin.js +++ b/src/webview/plugin.js @@ -1,11 +1,11 @@ -const { ipcRenderer } = require('electron'); -const path = require('path'); +import { ipcRenderer } from 'electron'; +import path from 'path'; -const RecipeWebview = require('./lib/RecipeWebview'); +import RecipeWebview from './lib/RecipeWebview'; -require('./notifications.js'); -require('./spellchecker.js'); -require('./ime.js'); +import './spellchecker.js'; +import './notifications.js'; +import './ime.js'; ipcRenderer.on('initializeRecipe', (e, data) => { const modulePath = path.join(data.recipe.path, 'webview.js'); -- cgit v1.2.3-70-g09d2 From 430e9a3424a391bc6ebff286408983b993652ecf Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Sun, 12 Nov 2017 22:28:01 +0100 Subject: [wip] share user settings with service --- src/actions/service.js | 4 ++++ src/stores/ServicesStore.js | 21 ++++++++++++++++++++- src/webview/plugin.js | 4 ++++ 3 files changed, 28 insertions(+), 1 deletion(-) (limited to 'src/webview') diff --git a/src/actions/service.js b/src/actions/service.js index 1b918251b..e3100e986 100644 --- a/src/actions/service.js +++ b/src/actions/service.js @@ -50,6 +50,10 @@ export default { channel: PropTypes.string.isRequired, args: PropTypes.object.isRequired, }, + sendIPCMessageToAllServices: { + channel: PropTypes.string.isRequired, + args: PropTypes.object.isRequired, + }, openWindow: { event: PropTypes.object.isRequired, }, diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index 269cd1526..82da9c5f1 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js @@ -37,6 +37,7 @@ export default class ServicesStore extends Store { this.actions.service.toggleService.listen(this._toggleService.bind(this)); this.actions.service.handleIPCMessage.listen(this._handleIPCMessage.bind(this)); this.actions.service.sendIPCMessage.listen(this._sendIPCMessage.bind(this)); + this.actions.service.sendIPCMessageToAllServices.listen(this._sendIPCMessageToAllServices.bind(this)); this.actions.service.setUnreadMessageCount.listen(this._setUnreadMessageCount.bind(this)); this.actions.service.openWindow.listen(this._openWindow.bind(this)); this.actions.service.filter.listen(this._filter.bind(this)); @@ -58,6 +59,7 @@ 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 @@ -330,7 +332,17 @@ export default class ServicesStore extends Store { @action _sendIPCMessage({ serviceId, channel, args }) { const service = this.one(serviceId); - service.webview.send(channel, args); + if (service.webview) { + service.webview.send(channel, args); + } + } + + @action _sendIPCMessageToAllServices({ channel, args }) { + this.all.forEach(s => this.actions.service.sendIPCMessage({ + serviceId: s.id, + channel, + args, + })); } @action _openWindow({ event }) { @@ -495,6 +507,13 @@ export default class ServicesStore extends Store { } } + _shareSettingsWithServiceProcess() { + this.actions.service.sendIPCMessageToAllServices({ + channel: 'settings-update', + args: this.stores.settings.all, + }); + } + _cleanUpTeamIdAndCustomUrl(recipeId, data) { const serviceData = data; const recipe = this.stores.recipes.one(recipeId); diff --git a/src/webview/plugin.js b/src/webview/plugin.js index 569fa9493..fec353f34 100644 --- a/src/webview/plugin.js +++ b/src/webview/plugin.js @@ -19,6 +19,10 @@ ipcRenderer.on('initializeRecipe', (e, data) => { } }); +ipcRenderer.on('settings-update', (e, data) => { + console.log(data); +}); + document.addEventListener('DOMContentLoaded', () => { ipcRenderer.sendToHost('hello'); }, false); -- cgit v1.2.3-70-g09d2 From b15421b0597fa40d961db2e102d6b54059196b27 Mon Sep 17 00:00:00 2001 From: Danny Qiu Date: Tue, 14 Nov 2017 01:39:44 -0500 Subject: Fix application of onNotify --- src/webview/lib/RecipeWebview.js | 2 +- src/webview/notifications.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/webview') diff --git a/src/webview/lib/RecipeWebview.js b/src/webview/lib/RecipeWebview.js index b8acc1258..048beea69 100644 --- a/src/webview/lib/RecipeWebview.js +++ b/src/webview/lib/RecipeWebview.js @@ -66,7 +66,7 @@ class RecipeWebview { onNotify(fn) { if (typeof fn === 'function') { - window.Notification.onNotify = fn; + window.Notification.prototype.onNotify = fn; } } diff --git a/src/webview/notifications.js b/src/webview/notifications.js index 4055b10de..4f602bfdb 100644 --- a/src/webview/notifications.js +++ b/src/webview/notifications.js @@ -10,9 +10,9 @@ class Notification { this.notificationId = uuidV1(); ipcRenderer.sendToHost('notification', this.onNotify({ + title: this.title, + options: this.options, notificationId: this.notificationId, - title, - options, })); ipcRenderer.once(`notification-onclick:${this.notificationId}`, () => { -- cgit v1.2.3-70-g09d2 From dcab45a323f53a10ff5f419daa5ba6442817eebc Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Tue, 14 Nov 2017 21:04:41 +0100 Subject: feat(App): Add option to enable/disable spell checker --- .../settings/navigation/SettingsNavigation.js | 1 - .../settings/settings/EditSettingsForm.js | 33 +++++++++++----- src/config.js | 1 + src/containers/settings/EditSettingsScreen.js | 38 +++++++++++++++--- src/i18n/languages.js | 45 +++++++++++++++++++++- src/i18n/locales/en-US.json | 3 ++ src/i18n/translations.js | 4 +- src/stores/ServicesStore.js | 1 + src/webview/plugin.js | 16 +++++++- src/webview/spellchecker.js | 40 +++++++++++++------ 10 files changed, 149 insertions(+), 33 deletions(-) (limited to 'src/webview') diff --git a/src/components/settings/navigation/SettingsNavigation.js b/src/components/settings/navigation/SettingsNavigation.js index 3b21a7765..fea8d682d 100644 --- a/src/components/settings/navigation/SettingsNavigation.js +++ b/src/components/settings/navigation/SettingsNavigation.js @@ -74,7 +74,6 @@ export default class SettingsNavigation extends Component { {intl.formatMessage(messages.logout)} diff --git a/src/components/settings/settings/EditSettingsForm.js b/src/components/settings/settings/EditSettingsForm.js index e711ad402..601d57c81 100644 --- a/src/components/settings/settings/EditSettingsForm.js +++ b/src/components/settings/settings/EditSettingsForm.js @@ -30,9 +30,9 @@ const messages = defineMessages({ id: 'settings.app.headlineAppearance', defaultMessage: '!!!Appearance', }, - headlineMessaging: { - id: 'settings.app.headlineMessaging', - defaultMessage: '!!!Messaging', + headlineAdvanced: { + id: 'settings.app.headlineAdvanced', + defaultMessage: '!!!Advanced', }, buttonSearchForUpdate: { id: 'settings.app.buttonSearchForUpdate', @@ -58,6 +58,10 @@ const messages = defineMessages({ id: 'settings.app.currentVersion', defaultMessage: '!!!Current version:', }, + restartRequired: { + id: 'settings.app.restartRequired', + defaultMessage: '!!!Changes require restart', + }, }); @observer @@ -120,20 +124,31 @@ export default class EditSettingsForm extends Component { onChange={e => this.submit(e)} id="form" > -

{intl.formatMessage(messages.headlineGeneral)}

+ {/* General */} +

{intl.formatMessage(messages.headlineGeneral)}

{process.platform === 'win32' && ( )} -

{intl.formatMessage(messages.headlineAppearance)}

+ + {/* Appearance */} +

{intl.formatMessage(messages.headlineAppearance)}

-

{intl.formatMessage(messages.headlineMessaging)}

- -

{intl.formatMessage(messages.headlineLanguage)}

+ + {/* Language */} +

{intl.formatMessage(messages.headlineLanguage)}

*/} + + {/* Updates */} +

{intl.formatMessage(messages.headlineUpdates)}

{updateIsReadyToInstall ? (