fix(ScreenShare): remove listener for native events when app unmounts
This commit is contained in:
parent
9a8b5551be
commit
724391648e
|
@ -5,7 +5,7 @@ import { NativeEventEmitter, NativeModules } from 'react-native';
|
|||
|
||||
import { ENDPOINT_TEXT_MESSAGE_NAME } from '../../../../modules/API/constants';
|
||||
import { appNavigate } from '../../app/actions';
|
||||
import { APP_WILL_MOUNT } from '../../base/app/actionTypes';
|
||||
import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../../base/app/actionTypes';
|
||||
import {
|
||||
CONFERENCE_FAILED,
|
||||
CONFERENCE_JOINED,
|
||||
|
@ -93,6 +93,9 @@ MiddlewareRegistry.register(store => next => action => {
|
|||
case APP_WILL_MOUNT:
|
||||
_registerForNativeEvents(store);
|
||||
break;
|
||||
case APP_WILL_UNMOUNT:
|
||||
_unregisterForNativeEvents();
|
||||
break;
|
||||
case CONFERENCE_FAILED: {
|
||||
const { error, ...data } = action;
|
||||
|
||||
|
@ -349,6 +352,24 @@ function _registerForNativeEvents(store) {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister for events sent from the native side via NativeEventEmitter.
|
||||
*
|
||||
* @private
|
||||
* @returns {void}
|
||||
*/
|
||||
function _unregisterForNativeEvents() {
|
||||
eventEmitter.removeAllListeners(ExternalAPI.HANG_UP);
|
||||
eventEmitter.removeAllListeners(ExternalAPI.SET_AUDIO_MUTED);
|
||||
eventEmitter.removeAllListeners(ExternalAPI.SET_VIDEO_MUTED);
|
||||
eventEmitter.removeAllListeners(ExternalAPI.SEND_ENDPOINT_TEXT_MESSAGE);
|
||||
eventEmitter.removeAllListeners(ExternalAPI.TOGGLE_SCREEN_SHARE);
|
||||
eventEmitter.removeAllListeners(ExternalAPI.RETRIEVE_PARTICIPANTS_INFO);
|
||||
eventEmitter.removeAllListeners(ExternalAPI.OPEN_CHAT);
|
||||
eventEmitter.removeAllListeners(ExternalAPI.CLOSE_CHAT);
|
||||
eventEmitter.removeAllListeners(ExternalAPI.SEND_CHAT_MESSAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers for endpoint messages sent on conference data channel.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue