From b9ac1222ed08239e56c11e4f2597b300e41afccb Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 24 May 2017 15:55:37 +0100 Subject: [PATCH] remove listener on unmount Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/UserSettings.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index 0407c9b43a..5ce0779322 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -201,9 +201,7 @@ module.exports = React.createClass({ if (PlatformPeg.get().isElectron()) { const {ipcRenderer} = require('electron'); - ipcRenderer.once('settings', (ev, settings) => { - this.setState({ electron_settings: settings }); - }); + ipcRenderer.on('settings', this._electronSettings); ipcRenderer.send('settings_get'); } @@ -226,6 +224,15 @@ module.exports = React.createClass({ if (cli) { cli.removeListener("RoomMember.membership", this._onInviteStateChange); } + + if (PlatformPeg.get().isElectron()) { + const {ipcRenderer} = require('electron'); + ipcRenderer.removeListener('settings', this._electronSettings); + } + }, + + _electronSettings: function(ev, settings) { + this.setState({ electron_settings: settings }); }, _refreshFromServer: function() {