2020-01-24 16:28:47 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import Filmstrip from '../../../modules/UI/videolayout/Filmstrip';
|
2020-04-14 22:41:30 +00:00
|
|
|
import VideoLayout from '../../../modules/UI/videolayout/VideoLayout';
|
2020-05-20 10:57:03 +00:00
|
|
|
import { StateListenerRegistry, equals } from '../base/redux';
|
2020-01-24 16:28:47 +00:00
|
|
|
import { getCurrentLayout, getTileViewGridDimensions, shouldDisplayTileView, LAYOUTS } from '../video-layout';
|
|
|
|
|
2020-03-09 11:54:54 +00:00
|
|
|
import { setHorizontalViewDimensions, setTileViewDimensions } from './actions.web';
|
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(
|
|
|
|
/* selector */ state => state['features/base/participants'].length,
|
|
|
|
/* listener */ (numberOfParticipants, store) => {
|
|
|
|
const state = store.getState();
|
|
|
|
|
|
|
|
if (shouldDisplayTileView(state)) {
|
2020-03-06 11:43:00 +00:00
|
|
|
const gridDimensions = getTileViewGridDimensions(state);
|
2020-01-24 16:28:47 +00:00
|
|
|
const oldGridDimensions = state['features/filmstrip'].tileViewDimensions.gridDimensions;
|
|
|
|
const { clientHeight, clientWidth } = state['features/base/responsive-ui'];
|
2020-03-09 11:54:54 +00:00
|
|
|
const { isOpen } = state['features/chat'];
|
2020-01-24 16:28:47 +00:00
|
|
|
|
|
|
|
if (!equals(gridDimensions, oldGridDimensions)) {
|
2020-03-09 11:54:54 +00:00
|
|
|
store.dispatch(
|
|
|
|
setTileViewDimensions(
|
|
|
|
gridDimensions,
|
|
|
|
{
|
|
|
|
clientHeight,
|
|
|
|
clientWidth
|
|
|
|
},
|
|
|
|
isOpen
|
|
|
|
)
|
|
|
|
);
|
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(
|
|
|
|
/* selector */ state => getCurrentLayout(state),
|
|
|
|
/* listener */ (layout, store) => {
|
|
|
|
const state = store.getState();
|
|
|
|
|
|
|
|
switch (layout) {
|
|
|
|
case LAYOUTS.TILE_VIEW: {
|
|
|
|
const { clientHeight, clientWidth } = state['features/base/responsive-ui'];
|
2020-03-09 11:54:54 +00:00
|
|
|
const { isOpen } = state['features/chat'];
|
2020-01-24 16:28:47 +00:00
|
|
|
|
2020-03-09 11:54:54 +00:00
|
|
|
store.dispatch(
|
|
|
|
setTileViewDimensions(
|
|
|
|
getTileViewGridDimensions(state),
|
|
|
|
{
|
|
|
|
clientHeight,
|
|
|
|
clientWidth
|
|
|
|
},
|
|
|
|
isOpen
|
|
|
|
)
|
|
|
|
);
|
2020-01-24 16:28:47 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case LAYOUTS.HORIZONTAL_FILMSTRIP_VIEW:
|
|
|
|
store.dispatch(setHorizontalViewDimensions(state['features/base/responsive-ui'].clientHeight));
|
|
|
|
break;
|
|
|
|
case LAYOUTS.VERTICAL_FILMSTRIP_VIEW:
|
|
|
|
// Once the thumbnails are reactified this should be moved there too.
|
|
|
|
Filmstrip.resizeThumbnailsForVerticalView();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
2020-04-14 22:41:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles on stage participant updates.
|
|
|
|
*/
|
|
|
|
StateListenerRegistry.register(
|
|
|
|
/* selector */ state => state['features/large-video'].participantId,
|
|
|
|
/* listener */ (participantId, store, oldParticipantId) => {
|
|
|
|
const newThumbnail = VideoLayout.getSmallVideo(participantId);
|
|
|
|
const oldThumbnail = VideoLayout.getSmallVideo(oldParticipantId);
|
|
|
|
|
|
|
|
if (newThumbnail) {
|
|
|
|
newThumbnail.updateView();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (oldThumbnail) {
|
|
|
|
oldThumbnail.updateView();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
2020-03-09 11:54:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Listens for changes in the chat state to calculate the dimensions of the tile view grid and the tiles.
|
|
|
|
*/
|
|
|
|
StateListenerRegistry.register(
|
|
|
|
/* selector */ state => state['features/chat'].isOpen,
|
|
|
|
/* listener */ (isChatOpen, store) => {
|
|
|
|
const state = store.getState();
|
|
|
|
|
|
|
|
if (isChatOpen) {
|
|
|
|
// $FlowFixMe
|
|
|
|
document.body.classList.add('shift-right');
|
|
|
|
} else {
|
|
|
|
// $FlowFixMe
|
|
|
|
document.body.classList.remove('shift-right');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (shouldDisplayTileView(state)) {
|
|
|
|
const gridDimensions = getTileViewGridDimensions(state);
|
|
|
|
const { clientHeight, clientWidth } = state['features/base/responsive-ui'];
|
|
|
|
|
|
|
|
store.dispatch(
|
|
|
|
setTileViewDimensions(
|
|
|
|
gridDimensions,
|
|
|
|
{
|
|
|
|
clientHeight,
|
|
|
|
clientWidth
|
|
|
|
},
|
|
|
|
isChatOpen
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|