Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
ref(user-interaction): do not store listener, move browser check to lib (#4441)
virtuacoplennyada57ebcd039
diff --git a/package-lock.json b/package-lock.jsonindex 82c1073b9e..6688952307 100644--- a/package-lock.json+++ b/package-lock.json@@ -9042,8 +9042,8 @@}},"lib-jitsi-meet": {- "version": "github:jitsi/lib-jitsi-meet#24bda8e941c346ccfde6bc1e1bb5dcdbd9450bab",- "from": "github:jitsi/lib-jitsi-meet#24bda8e941c346ccfde6bc1e1bb5dcdbd9450bab",+ "version": "github:jitsi/lib-jitsi-meet#d4682073558205289ec89720b452275c325ad652",+ "from": "github:jitsi/lib-jitsi-meet#d4682073558205289ec89720b452275c325ad652","requires": {"@jitsi/sdp-interop": "0.1.14","@jitsi/sdp-simulcast": "0.2.1",diff --git a/package.json b/package.jsonindex 5f1ae4a69d..4d66615150 100644--- a/package.json+++ b/package.json@@ -54,7 +54,7 @@"js-utils": "github:jitsi/js-utils#192b1c996e8c05530eb1f19e82a31069c3021e31","jsrsasign": "8.0.12","jwt-decode": "2.2.0",- "lib-jitsi-meet": "github:jitsi/lib-jitsi-meet#24bda8e941c346ccfde6bc1e1bb5dcdbd9450bab",+ "lib-jitsi-meet": "github:jitsi/lib-jitsi-meet#d4682073558205289ec89720b452275c325ad652","libflacjs": "github:mmig/libflac.js#93d37e7f811f01cf7d8b6a603e38bd3c3810907d","lodash": "4.17.11","moment": "2.19.4",diff --git a/react/features/base/tracks/functions.js b/react/features/base/tracks/functions.jsindex ea4784d6cb..34dcff8de6 100644--- a/react/features/base/tracks/functions.js+++ b/react/features/base/tracks/functions.js@@ -1,7 +1,7 @@/* global APP */import { getBlurEffect } from '../../blur';-import JitsiMeetJS, { JitsiTrackErrors } from '../lib-jitsi-meet';+import JitsiMeetJS, { JitsiTrackErrors, browser } from '../lib-jitsi-meet';import { MEDIA_TYPE } from '../media';import {getUserSelectedCameraDeviceId,@@ -236,12 +236,7 @@ export function isRemoteTrackMuted(tracks, mediaType, participantId) {* @returns {boolean}*/export function isUserInteractionRequiredForUnmute(state) {- const { browser } = JitsiMeetJS.util;-- return !browser.isReactNative()- && !browser.isChrome()- && !browser.isChromiumBased()- && !browser.isElectron()+ return browser.isUserInteractionRequiredForUnmute()&& window&& window.self !== window.top&& !state['features/base/user-interaction'].interacted;diff --git a/react/features/base/user-interaction/actionTypes.js b/react/features/base/user-interaction/actionTypes.jsindex 29cb8bca4b..f0cfb67fbd 100644--- a/react/features/base/user-interaction/actionTypes.js+++ b/react/features/base/user-interaction/actionTypes.js@@ -1,14 +1,3 @@-/**- * The type of (redux) action which signals that an event listener has been- * added to listen for any user interaction with the page.- *- * {- * type: SET_USER_INTERACTION_LISTENER,- * userInteractionListener: Function- * }- */-export const SET_USER_INTERACTION_LISTENER = 'SET_USER_INTERACTION_LISTENER';-/*** The type of (redux) action which signals the user has interacted with the* page.diff --git a/react/features/base/user-interaction/middleware.js b/react/features/base/user-interaction/middleware.jsindex 3080cc81d0..eb56004922 100644--- a/react/features/base/user-interaction/middleware.js+++ b/react/features/base/user-interaction/middleware.js@@ -3,10 +3,15 @@import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../app';import { MiddlewareRegistry } from '../redux';-import {- SET_USER_INTERACTION_LISTENER,- USER_INTERACTION_RECEIVED-} from './actionTypes';+import { USER_INTERACTION_RECEIVED } from './actionTypes';++/**+ * Reference to any callback that has been created to be invoked on user+ * interaction.+ *+ * @type {Function|null}+ */+let userInteractionListener = null;/*** Implements the entry point of the middleware of the feature base/user-interaction.@@ -21,14 +26,31 @@ MiddlewareRegistry.register(store => next => action => {break;case APP_WILL_UNMOUNT:- case USER_INTERACTION_RECEIVED:- _stopListeningForUserInteraction(store);+ _stopListeningForUserInteraction();break;}return next(action);});+/**+ * Callback invoked when the user interacts with the page.+ *+ * @param {Function} dispatch - The redux dispatch function.+ * @param {Object} event - The DOM event for a user interacting with the page.+ * @private+ * @returns {void}+ */+function _onUserInteractionReceived(dispatch, event) {+ if (event.isTrusted) {+ dispatch({+ type: USER_INTERACTION_RECEIVED+ });++ _stopListeningForUserInteraction();+ }+}+/*** Registers listeners to notify redux of any user interaction with the page.*@@ -36,44 +58,24 @@ MiddlewareRegistry.register(store => next => action => {* @private* @returns {void}*/-function _startListeningForUserInteraction(store) {- const userInteractionListener = event => {- if (event.isTrusted) {- store.dispatch({- type: USER_INTERACTION_RECEIVED- });+function _startListeningForUserInteraction({ dispatch }) {+ _stopListeningForUserInteraction();- _stopListeningForUserInteraction(store);- }- };+ userInteractionListener = _onUserInteractionReceived.bind(null, dispatch);window.addEventListener('mousedown', userInteractionListener);window.addEventListener('keydown', userInteractionListener);-- store.dispatch({- type: SET_USER_INTERACTION_LISTENER,- userInteractionListener- });}/**- * Un-registers listeners intended to notify when the user has interacted with- * the page.+ * De-registers listeners for user interaction with the page.*- * @param {Object} store - The redux store.* @private* @returns {void}*/-function _stopListeningForUserInteraction({ getState, dispatch }) {- const { userInteractionListener } = getState()['features/base/app'];-- if (userInteractionListener) {- window.removeEventListener('mousedown', userInteractionListener);- window.removeEventListener('keydown', userInteractionListener);+function _stopListeningForUserInteraction() {+ window.removeEventListener('mousedown', userInteractionListener);+ window.removeEventListener('keydown', userInteractionListener);- dispatch({- type: SET_USER_INTERACTION_LISTENER,- userInteractionListener: undefined- });- }+ userInteractionListener = null;}diff --git a/react/features/base/user-interaction/reducer.js b/react/features/base/user-interaction/reducer.jsindex 4409907b9e..ff27f65f94 100644--- a/react/features/base/user-interaction/reducer.js+++ b/react/features/base/user-interaction/reducer.js@@ -3,25 +3,16 @@import { ReducerRegistry } from '../redux';import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../app';-import {- SET_USER_INTERACTION_LISTENER,- USER_INTERACTION_RECEIVED-} from './actionTypes';+import { USER_INTERACTION_RECEIVED } from './actionTypes';ReducerRegistry.register('features/base/user-interaction', (state = {}, action) => {switch (action.type) {case APP_WILL_MOUNT:- case APP_WILL_UNMOUNT: {+ case APP_WILL_UNMOUNT:return {...state,interacted: false};- }- case SET_USER_INTERACTION_LISTENER:- return {- ...state,- userInteractionListener: action.userInteractionListener- };case USER_INTERACTION_RECEIVED:return {