forked from jitsi/jitsi-meet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(conference): require user interaction to unmute in iframe (jitsi#…
…4429) * fix(conference): require user interaction to unmute in iframe * squash: explicitly whitelist react native
- Loading branch information
1 parent
a53a86e
commit e7f9e8e
Showing
8 changed files
with
190 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* 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. | ||
* | ||
* { | ||
* type: USER_INTERACTION_RECEIVED, | ||
* } | ||
*/ | ||
export const USER_INTERACTION_RECEIVED = 'USER_INTERACTION_RECEIVED'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import './middleware'; | ||
import './reducer'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// @flow | ||
|
||
import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../app'; | ||
import { MiddlewareRegistry } from '../redux'; | ||
|
||
import { | ||
SET_USER_INTERACTION_LISTENER, | ||
USER_INTERACTION_RECEIVED | ||
} from './actionTypes'; | ||
|
||
/** | ||
* Implements the entry point of the middleware of the feature base/user-interaction. | ||
* | ||
* @param {Store} store - The redux store. | ||
* @returns {Function} | ||
*/ | ||
MiddlewareRegistry.register(store => next => action => { | ||
switch (action.type) { | ||
case APP_WILL_MOUNT: | ||
_startListeningForUserInteraction(store); | ||
break; | ||
|
||
case APP_WILL_UNMOUNT: | ||
case USER_INTERACTION_RECEIVED: | ||
_stopListeningForUserInteraction(store); | ||
break; | ||
} | ||
|
||
return next(action); | ||
}); | ||
|
||
/** | ||
* Registers listeners to notify redux of any user interaction with the page. | ||
* | ||
* @param {Object} store - The redux store. | ||
* @private | ||
* @returns {void} | ||
*/ | ||
function _startListeningForUserInteraction(store) { | ||
const userInteractionListener = event => { | ||
if (event.isTrusted) { | ||
store.dispatch({ | ||
type: USER_INTERACTION_RECEIVED | ||
}); | ||
|
||
_stopListeningForUserInteraction(store); | ||
} | ||
}; | ||
|
||
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. | ||
* | ||
* @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); | ||
|
||
dispatch({ | ||
type: SET_USER_INTERACTION_LISTENER, | ||
userInteractionListener: undefined | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// @flow | ||
|
||
import { ReducerRegistry } from '../redux'; | ||
|
||
import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../app'; | ||
import { | ||
SET_USER_INTERACTION_LISTENER, | ||
USER_INTERACTION_RECEIVED | ||
} from './actionTypes'; | ||
|
||
ReducerRegistry.register('features/base/user-interaction', (state = {}, action) => { | ||
switch (action.type) { | ||
case APP_WILL_MOUNT: | ||
case APP_WILL_UNMOUNT: { | ||
return { | ||
...state, | ||
interacted: false | ||
}; | ||
} | ||
case SET_USER_INTERACTION_LISTENER: | ||
return { | ||
...state, | ||
userInteractionListener: action.userInteractionListener | ||
}; | ||
|
||
case USER_INTERACTION_RECEIVED: | ||
return { | ||
...state, | ||
interacted: true | ||
}; | ||
} | ||
|
||
return state; | ||
}); |