From 09843aa58866a1b8302df8f8beffa2ea3132d4c7 Mon Sep 17 00:00:00 2001 From: Gung Wah <41157464+kresnaputra@users.noreply.github.com> Date: Wed, 24 Feb 2021 03:00:39 +0800 Subject: [PATCH] [FIX] App not sending second argument for EventEmitter.removeListener on some places (#2909) Co-authored-by: Diego Mello --- app/containers/Toast.js | 4 ++-- app/containers/TwoFactor/index.js | 4 ++-- app/views/ChangePasscodeView.js | 4 ++-- app/views/ScreenLockedView.js | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/containers/Toast.js b/app/containers/Toast.js index eed7cfd7..4b982fb4 100644 --- a/app/containers/Toast.js +++ b/app/containers/Toast.js @@ -28,7 +28,7 @@ class Toast extends React.Component { } componentDidMount() { - EventEmitter.addEventListener(LISTENER, this.showToast); + this.listener = EventEmitter.addEventListener(LISTENER, this.showToast); } shouldComponentUpdate(nextProps) { @@ -40,7 +40,7 @@ class Toast extends React.Component { } componentWillUnmount() { - EventEmitter.removeListener(LISTENER); + EventEmitter.removeListener(LISTENER, this.listener); } getToastRef = toast => this.toast = toast; diff --git a/app/containers/TwoFactor/index.js b/app/containers/TwoFactor/index.js index c6ad5467..deb5c25d 100644 --- a/app/containers/TwoFactor/index.js +++ b/app/containers/TwoFactor/index.js @@ -58,9 +58,9 @@ const TwoFactor = React.memo(({ theme, isMasterDetail }) => { const showTwoFactor = args => setData(args); useEffect(() => { - EventEmitter.addEventListener(TWO_FACTOR, showTwoFactor); + const listener = EventEmitter.addEventListener(TWO_FACTOR, showTwoFactor); - return () => EventEmitter.removeListener(TWO_FACTOR); + return () => EventEmitter.removeListener(TWO_FACTOR, listener); }, []); const onCancel = () => { diff --git a/app/views/ChangePasscodeView.js b/app/views/ChangePasscodeView.js index 308e2d78..535ba71d 100644 --- a/app/views/ChangePasscodeView.js +++ b/app/views/ChangePasscodeView.js @@ -63,12 +63,12 @@ const ChangePasscodeView = React.memo(({ theme }) => { if (!isTablet) { Orientation.lockToPortrait(); } - EventEmitter.addEventListener(CHANGE_PASSCODE_EMITTER, showChangePasscode); + const listener = EventEmitter.addEventListener(CHANGE_PASSCODE_EMITTER, showChangePasscode); return (() => { if (!isTablet) { Orientation.unlockAllOrientations(); } - EventEmitter.removeListener(CHANGE_PASSCODE_EMITTER); + EventEmitter.removeListener(CHANGE_PASSCODE_EMITTER, listener); }); }, []); diff --git a/app/views/ScreenLockedView.js b/app/views/ScreenLockedView.js index 88358405..2b036779 100644 --- a/app/views/ScreenLockedView.js +++ b/app/views/ScreenLockedView.js @@ -31,12 +31,12 @@ const ScreenLockedView = ({ theme }) => { if (!isTablet) { Orientation.lockToPortrait(); } - EventEmitter.addEventListener(LOCAL_AUTHENTICATE_EMITTER, showScreenLock); + const listener = EventEmitter.addEventListener(LOCAL_AUTHENTICATE_EMITTER, showScreenLock); return (() => { if (!isTablet) { Orientation.unlockAllOrientations(); } - EventEmitter.removeListener(LOCAL_AUTHENTICATE_EMITTER); + EventEmitter.removeListener(LOCAL_AUTHENTICATE_EMITTER, listener); }); }, []);