From efe1c767f03c2451215cca3951750f8825def864 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 3 May 2016 11:36:44 +0100 Subject: [PATCH] Un-inline onChange --- .../views/settings/Notifications.js | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/src/components/views/settings/Notifications.js b/src/components/views/settings/Notifications.js index 2a66fff420..2f445cadd6 100644 --- a/src/components/views/settings/Notifications.js +++ b/src/components/views/settings/Notifications.js @@ -107,6 +107,26 @@ module.exports = React.createClass({ UserSettingsStore.setEnableNotifications(event.target.checked); }, + onEnableEmailNotificationsChange: function(address, event) { + var emailPusherPromise; + if (event.target.checked) { + emailPusherPromise = UserSettingsStore.addEmailPusher(address); + } else { + var emailPusher = UserSettingsStore.getEmailPusher(this.state.pushers, address); + emailPusher.kind = null; + emailPusherPromise = MatrixClientPeg.get().setPusher(emailPusher); + } + emailPusherPromise.done(() => { + this._refreshFromServer(); + }, (error) => { + var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); + Modal.createDialog(ErrorDialog, { + title: "Error saving email notification preferences", + description: "Vector was unable to save your email notification preferences.", + }); + }); + }, + onNotifStateButtonClicked: function(event) { // FIXME: use .bind() rather than className metadata here surely var vectorRuleId = event.target.className.split("-")[0]; @@ -632,25 +652,8 @@ module.exports = React.createClass({ ref="enableEmailNotifications_{address}" type="checkbox" checked={ UserSettingsStore.hasEmailPusher(this.state.pushers, address) } - onChange={ (e) => { - var emailPusherPromise; - if (e.target.checked) { - emailPusherPromise = UserSettingsStore.addEmailPusher(address); - } else { - var emailPusher = UserSettingsStore.getEmailPusher(this.state.pushers, address); - emailPusher.kind = null; - emailPusherPromise = MatrixClientPeg.get().setPusher(emailPusher); - } - emailPusherPromise.done(() => { - this._refreshFromServer(); - }, (error) => { - var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); - Modal.createDialog(ErrorDialog, { - title: "Error saving email notification preferences", - description: "Vector was unable to save your email notification preferences.", - }); - }); - }} /> + onChange={ this.onEnableEmailNotificationsChange.bind(this, address) } + />