fix(lastn) debounce updating last N
When joining a large meeting every participant join would trigger an attempt of an update. Try to minimize the amount of calls.
This commit is contained in:
parent
5dc03f56f6
commit
a687907105
|
@ -1,5 +1,7 @@
|
|||
// @flow
|
||||
|
||||
import debounce from 'lodash/debounce';
|
||||
|
||||
import { SET_FILMSTRIP_ENABLED } from '../../filmstrip/actionTypes';
|
||||
import { SELECT_LARGE_VIDEO_PARTICIPANT } from '../../large-video/actionTypes';
|
||||
import { APP_STATE_CHANGED } from '../../mobile/background/actionTypes';
|
||||
|
@ -22,29 +24,6 @@ import { setLastN } from './actions';
|
|||
import { limitLastN } from './functions';
|
||||
import logger from './logger';
|
||||
|
||||
declare var APP: Object;
|
||||
|
||||
MiddlewareRegistry.register(store => next => action => {
|
||||
const result = next(action);
|
||||
|
||||
switch (action.type) {
|
||||
case APP_STATE_CHANGED:
|
||||
case CONFERENCE_JOINED:
|
||||
case PARTICIPANT_JOINED:
|
||||
case PARTICIPANT_KICKED:
|
||||
case PARTICIPANT_LEFT:
|
||||
case SCREEN_SHARE_REMOTE_PARTICIPANTS_UPDATED:
|
||||
case SELECT_LARGE_VIDEO_PARTICIPANT:
|
||||
case SET_AUDIO_ONLY:
|
||||
case SET_FILMSTRIP_ENABLED:
|
||||
case SET_TILE_VIEW:
|
||||
_updateLastN(store);
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
});
|
||||
|
||||
/**
|
||||
* Updates the last N value in the conference based on the current state of the redux store.
|
||||
*
|
||||
|
@ -52,15 +31,9 @@ MiddlewareRegistry.register(store => next => action => {
|
|||
* @private
|
||||
* @returns {void}
|
||||
*/
|
||||
function _updateLastN({ dispatch, getState }) {
|
||||
const _updateLastN = debounce(({ dispatch, getState }) => {
|
||||
const state = getState();
|
||||
const { conference } = state['features/base/conference'];
|
||||
const { enabled: audioOnly } = state['features/base/audio-only'];
|
||||
const { appState } = state['features/background'] || {};
|
||||
const { enabled: filmStripEnabled } = state['features/filmstrip'];
|
||||
const config = state['features/base/config'];
|
||||
const { lastNLimits, lastN } = state['features/base/lastn'];
|
||||
const participantCount = getParticipantCount(state);
|
||||
|
||||
if (!conference) {
|
||||
logger.debug('There is no active conference, not updating last N');
|
||||
|
@ -68,6 +41,13 @@ function _updateLastN({ dispatch, getState }) {
|
|||
return;
|
||||
}
|
||||
|
||||
const { enabled: audioOnly } = state['features/base/audio-only'];
|
||||
const { appState } = state['features/background'] || {};
|
||||
const { enabled: filmStripEnabled } = state['features/filmstrip'];
|
||||
const config = state['features/base/config'];
|
||||
const { lastNLimits, lastN } = state['features/base/lastn'];
|
||||
const participantCount = getParticipantCount(state);
|
||||
|
||||
// Select the lastN value based on the following preference order.
|
||||
// 1. The last-n value in redux.
|
||||
// 2. The last-n value from 'startLastN' if it is specified in config.js
|
||||
|
@ -104,4 +84,26 @@ function _updateLastN({ dispatch, getState }) {
|
|||
|
||||
logger.info(`Setting last N to: ${lastNSelected}`);
|
||||
dispatch(setLastN(lastNSelected));
|
||||
}
|
||||
}, 1000); /* Don't send this more often than once a second. */
|
||||
|
||||
|
||||
MiddlewareRegistry.register(store => next => action => {
|
||||
const result = next(action);
|
||||
|
||||
switch (action.type) {
|
||||
case APP_STATE_CHANGED:
|
||||
case CONFERENCE_JOINED:
|
||||
case PARTICIPANT_JOINED:
|
||||
case PARTICIPANT_KICKED:
|
||||
case PARTICIPANT_LEFT:
|
||||
case SCREEN_SHARE_REMOTE_PARTICIPANTS_UPDATED:
|
||||
case SELECT_LARGE_VIDEO_PARTICIPANT:
|
||||
case SET_AUDIO_ONLY:
|
||||
case SET_FILMSTRIP_ENABLED:
|
||||
case SET_TILE_VIEW:
|
||||
_updateLastN(store);
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue