2020-01-24 16:28:47 +00:00
|
|
|
// @flow
|
|
|
|
|
2021-12-08 13:36:41 +00:00
|
|
|
import { isMobileBrowser } from '../base/environment/utils';
|
2022-04-12 13:19:10 +00:00
|
|
|
import { getParticipantCountWithFake, pinParticipant } from '../base/participants';
|
2022-03-11 00:27:37 +00:00
|
|
|
import { StateListenerRegistry } from '../base/redux';
|
2021-03-23 12:06:43 +00:00
|
|
|
import { clientResized } from '../base/responsive-ui';
|
2021-12-16 16:55:45 +00:00
|
|
|
import { shouldHideSelfView } from '../base/settings';
|
2021-01-18 10:17:23 +00:00
|
|
|
import { setFilmstripVisible } from '../filmstrip/actions';
|
2022-03-29 08:45:09 +00:00
|
|
|
import { selectParticipantInLargeVideo } from '../large-video/actions.any';
|
2021-04-21 13:48:05 +00:00
|
|
|
import { getParticipantsPaneOpen } from '../participants-pane/functions';
|
2021-01-04 13:30:23 +00:00
|
|
|
import { setOverflowDrawer } from '../toolbox/actions.web';
|
2022-03-11 00:27:37 +00:00
|
|
|
import { getCurrentLayout, shouldDisplayTileView, LAYOUTS } from '../video-layout';
|
2020-01-24 16:28:47 +00:00
|
|
|
|
2021-08-18 22:34:01 +00:00
|
|
|
import {
|
2022-04-21 06:15:34 +00:00
|
|
|
clearStageParticipants,
|
2021-08-18 22:34:01 +00:00
|
|
|
setHorizontalViewDimensions,
|
2022-03-29 08:45:09 +00:00
|
|
|
setStageFilmstripViewDimensions,
|
2021-08-18 22:34:01 +00:00
|
|
|
setTileViewDimensions,
|
|
|
|
setVerticalViewDimensions
|
2021-08-23 23:02:41 +00:00
|
|
|
} from './actions';
|
2021-01-18 10:17:23 +00:00
|
|
|
import {
|
|
|
|
ASPECT_RATIO_BREAKPOINT,
|
2022-03-11 00:27:37 +00:00
|
|
|
DISPLAY_DRAWER_THRESHOLD
|
2021-01-18 10:17:23 +00:00
|
|
|
} from './constants';
|
2022-03-29 08:45:09 +00:00
|
|
|
import {
|
|
|
|
isFilmstripResizable,
|
|
|
|
isFilmstripScrollVisible,
|
|
|
|
updateRemoteParticipants
|
|
|
|
} from './functions';
|
|
|
|
|
2021-08-23 23:02:41 +00:00
|
|
|
import './subscriber.any';
|
|
|
|
|
2020-01-24 16:28:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Listens for changes in the number of participants to calculate the dimensions of the tile view grid and the tiles.
|
|
|
|
*/
|
|
|
|
StateListenerRegistry.register(
|
2021-12-07 08:24:00 +00:00
|
|
|
/* selector */ state => {
|
|
|
|
return {
|
|
|
|
numberOfParticipants: getParticipantCountWithFake(state),
|
2022-04-04 18:57:58 +00:00
|
|
|
disableSelfView: shouldHideSelfView(state),
|
|
|
|
localScreenShare: state['features/base/participants'].localScreenShare
|
2021-12-07 08:24:00 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
/* listener */ (currentState, store) => {
|
2020-01-24 16:28:47 +00:00
|
|
|
const state = store.getState();
|
2022-02-24 12:20:37 +00:00
|
|
|
const resizableFilmstrip = isFilmstripResizable(state);
|
2020-01-24 16:28:47 +00:00
|
|
|
|
|
|
|
if (shouldDisplayTileView(state)) {
|
2022-03-11 00:27:37 +00:00
|
|
|
store.dispatch(setTileViewDimensions());
|
2020-01-24 16:28:47 +00:00
|
|
|
}
|
2022-02-24 12:20:37 +00:00
|
|
|
if (resizableFilmstrip) {
|
|
|
|
store.dispatch(setVerticalViewDimensions());
|
|
|
|
}
|
2021-12-07 08:24:00 +00:00
|
|
|
}, {
|
|
|
|
deepEquals: true
|
2020-01-24 16:28:47 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Listens for changes in the selected layout to calculate the dimensions of the tile view grid and horizontal view.
|
|
|
|
*/
|
|
|
|
StateListenerRegistry.register(
|
2022-03-31 09:13:33 +00:00
|
|
|
/* selector */ state => {
|
2022-04-27 21:28:39 +00:00
|
|
|
const { clientHeight, clientWidth } = state['features/base/responsive-ui'];
|
|
|
|
|
|
|
|
return {
|
|
|
|
layout: getCurrentLayout(state),
|
|
|
|
height: clientHeight,
|
|
|
|
width: clientWidth
|
|
|
|
};
|
2022-03-31 09:13:33 +00:00
|
|
|
},
|
|
|
|
/* listener */ ({ layout }, store) => {
|
2020-01-24 16:28:47 +00:00
|
|
|
switch (layout) {
|
2021-03-26 20:23:05 +00:00
|
|
|
case LAYOUTS.TILE_VIEW:
|
2022-03-11 00:27:37 +00:00
|
|
|
store.dispatch(setTileViewDimensions());
|
2020-01-24 16:28:47 +00:00
|
|
|
break;
|
|
|
|
case LAYOUTS.HORIZONTAL_FILMSTRIP_VIEW:
|
2021-03-26 20:23:05 +00:00
|
|
|
store.dispatch(setHorizontalViewDimensions());
|
|
|
|
break;
|
|
|
|
case LAYOUTS.VERTICAL_FILMSTRIP_VIEW:
|
|
|
|
store.dispatch(setVerticalViewDimensions());
|
2022-04-12 13:19:10 +00:00
|
|
|
if (store.getState()['features/filmstrip'].activeParticipants.length > 1) {
|
|
|
|
store.dispatch(clearStageParticipants());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case LAYOUTS.STAGE_FILMSTRIP_VIEW:
|
|
|
|
store.dispatch(pinParticipant(null));
|
2020-01-24 16:28:47 +00:00
|
|
|
break;
|
|
|
|
}
|
2022-03-31 09:13:33 +00:00
|
|
|
}, {
|
|
|
|
deepEquals: true
|
2020-01-24 16:28:47 +00:00
|
|
|
});
|
2020-04-14 22:41:30 +00:00
|
|
|
|
2020-03-09 11:54:54 +00:00
|
|
|
/**
|
2021-03-23 12:06:43 +00:00
|
|
|
* Listens for changes in the chat state to recompute available width.
|
2020-03-09 11:54:54 +00:00
|
|
|
*/
|
|
|
|
StateListenerRegistry.register(
|
|
|
|
/* selector */ state => state['features/chat'].isOpen,
|
|
|
|
/* listener */ (isChatOpen, store) => {
|
2021-03-23 12:06:43 +00:00
|
|
|
const { innerWidth, innerHeight } = window;
|
2020-03-09 11:54:54 +00:00
|
|
|
|
|
|
|
if (isChatOpen) {
|
|
|
|
// $FlowFixMe
|
|
|
|
document.body.classList.add('shift-right');
|
|
|
|
} else {
|
|
|
|
// $FlowFixMe
|
|
|
|
document.body.classList.remove('shift-right');
|
|
|
|
}
|
|
|
|
|
2021-03-23 12:06:43 +00:00
|
|
|
store.dispatch(clientResized(innerWidth, innerHeight));
|
2020-03-09 11:54:54 +00:00
|
|
|
});
|
2021-01-04 13:30:23 +00:00
|
|
|
|
2021-04-21 13:48:05 +00:00
|
|
|
/**
|
|
|
|
* Listens for changes in the participant pane state to calculate the
|
|
|
|
* dimensions of the tile view grid and the tiles.
|
|
|
|
*/
|
|
|
|
StateListenerRegistry.register(
|
|
|
|
/* selector */ getParticipantsPaneOpen,
|
|
|
|
/* listener */ (isOpen, store) => {
|
|
|
|
const { innerWidth, innerHeight } = window;
|
|
|
|
|
|
|
|
store.dispatch(clientResized(innerWidth, innerHeight));
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2021-01-04 13:30:23 +00:00
|
|
|
/**
|
|
|
|
* Listens for changes in the client width to determine whether the overflow menu(s) should be displayed as drawers.
|
|
|
|
*/
|
|
|
|
StateListenerRegistry.register(
|
|
|
|
/* selector */ state => state['features/base/responsive-ui'].clientWidth < DISPLAY_DRAWER_THRESHOLD,
|
|
|
|
/* listener */ (widthBelowThreshold, store) => {
|
2021-12-08 13:36:41 +00:00
|
|
|
if (isMobileBrowser()) {
|
|
|
|
store.dispatch(setOverflowDrawer(widthBelowThreshold));
|
|
|
|
}
|
2021-01-04 13:30:23 +00:00
|
|
|
});
|
2021-01-18 10:17:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gracefully hide/show the filmstrip when going past threshold.
|
|
|
|
*/
|
|
|
|
StateListenerRegistry.register(
|
|
|
|
/* selector */ state => state['features/base/responsive-ui'].clientWidth < ASPECT_RATIO_BREAKPOINT,
|
|
|
|
/* listener */ (widthBelowThreshold, store) => {
|
2021-06-10 09:12:01 +00:00
|
|
|
const state = store.getState();
|
2021-06-15 13:09:01 +00:00
|
|
|
const { disableFilmstripAutohiding } = state['features/base/config'];
|
2021-06-10 09:12:01 +00:00
|
|
|
|
2021-06-15 13:09:01 +00:00
|
|
|
if (!disableFilmstripAutohiding) {
|
2021-06-10 09:12:01 +00:00
|
|
|
store.dispatch(setFilmstripVisible(!widthBelowThreshold));
|
|
|
|
}
|
2021-01-18 10:17:23 +00:00
|
|
|
});
|
|
|
|
|
2022-02-24 12:20:37 +00:00
|
|
|
/**
|
|
|
|
* Listens for changes in the filmstrip width to determine the size of the tiles.
|
|
|
|
*/
|
|
|
|
StateListenerRegistry.register(
|
|
|
|
/* selector */ state => state['features/filmstrip'].width?.current,
|
|
|
|
/* listener */(_, store) => {
|
|
|
|
store.dispatch(setVerticalViewDimensions());
|
|
|
|
});
|
2022-03-02 14:46:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Listens for changes in the filmstrip config to determine the size of the tiles.
|
|
|
|
*/
|
|
|
|
StateListenerRegistry.register(
|
|
|
|
/* selector */ state => state['features/base/config'].filmstrip?.disableResizable,
|
|
|
|
/* listener */(_, store) => {
|
|
|
|
store.dispatch(setVerticalViewDimensions());
|
|
|
|
});
|
2022-03-15 17:34:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Listens for changes in the filmstrip scroll visibility.
|
|
|
|
*/
|
|
|
|
StateListenerRegistry.register(
|
2022-03-29 08:45:09 +00:00
|
|
|
/* selector */ state => isFilmstripScrollVisible(state),
|
2022-03-15 17:34:46 +00:00
|
|
|
/* listener */ (_, store) => updateRemoteParticipants(store));
|
2022-03-29 08:45:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Listens for changes to determine the size of the stage filmstrip tiles.
|
|
|
|
*/
|
|
|
|
StateListenerRegistry.register(
|
|
|
|
/* selector */ state => {
|
|
|
|
return {
|
|
|
|
remoteScreenShares: state['features/video-layout'].remoteScreenShares.length,
|
|
|
|
length: state['features/filmstrip'].activeParticipants.length,
|
|
|
|
width: state['features/filmstrip'].width?.current,
|
|
|
|
visible: state['features/filmstrip'].visible,
|
|
|
|
clientWidth: state['features/base/responsive-ui'].clientWidth,
|
|
|
|
tileView: state['features/video-layout'].tileViewEnabled
|
|
|
|
};
|
|
|
|
},
|
|
|
|
/* listener */(_, store) => {
|
2022-04-12 13:19:10 +00:00
|
|
|
if (getCurrentLayout(store.getState()) === LAYOUTS.STAGE_FILMSTRIP_VIEW) {
|
2022-03-29 08:45:09 +00:00
|
|
|
store.dispatch(setStageFilmstripViewDimensions());
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
deepEquals: true
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Listens for changes in the active participants count determine the stage participant (when
|
|
|
|
* there's just one).
|
|
|
|
*/
|
|
|
|
StateListenerRegistry.register(
|
|
|
|
/* selector */ state => state['features/filmstrip'].activeParticipants.length,
|
|
|
|
/* listener */(length, store) => {
|
|
|
|
if (length <= 1) {
|
|
|
|
store.dispatch(selectParticipantInLargeVideo());
|
|
|
|
}
|
|
|
|
});
|