2020-01-24 16:28:47 +00:00
|
|
|
// @flow
|
|
|
|
|
2020-05-20 10:57:03 +00:00
|
|
|
import Filmstrip from '../../../modules/UI/videolayout/Filmstrip';
|
2020-01-24 16:28:47 +00:00
|
|
|
import { MiddlewareRegistry } from '../base/redux';
|
|
|
|
import { CLIENT_RESIZED } from '../base/responsive-ui';
|
|
|
|
import {
|
|
|
|
getCurrentLayout,
|
|
|
|
LAYOUTS,
|
|
|
|
shouldDisplayTileView
|
|
|
|
} from '../video-layout';
|
|
|
|
|
|
|
|
import { SET_HORIZONTAL_VIEW_DIMENSIONS, SET_TILE_VIEW_DIMENSIONS } from './actionTypes';
|
2020-03-09 11:54:54 +00:00
|
|
|
import { setHorizontalViewDimensions, setTileViewDimensions } from './actions.web';
|
2020-01-24 16:28:47 +00:00
|
|
|
|
2020-06-04 14:09:13 +00:00
|
|
|
import './subscriber.web';
|
|
|
|
|
2020-01-24 16:28:47 +00:00
|
|
|
/**
|
|
|
|
* The middleware of the feature Filmstrip.
|
|
|
|
*/
|
|
|
|
MiddlewareRegistry.register(store => next => action => {
|
|
|
|
const result = next(action);
|
|
|
|
|
|
|
|
switch (action.type) {
|
|
|
|
case CLIENT_RESIZED: {
|
|
|
|
const state = store.getState();
|
|
|
|
const layout = getCurrentLayout(state);
|
|
|
|
|
|
|
|
switch (layout) {
|
|
|
|
case LAYOUTS.TILE_VIEW: {
|
|
|
|
const { gridDimensions } = state['features/filmstrip'].tileViewDimensions;
|
|
|
|
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(
|
|
|
|
gridDimensions,
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SET_TILE_VIEW_DIMENSIONS: {
|
|
|
|
const state = store.getState();
|
|
|
|
|
|
|
|
if (shouldDisplayTileView(state)) {
|
|
|
|
const { width, height } = state['features/filmstrip'].tileViewDimensions.thumbnailSize;
|
|
|
|
|
|
|
|
// Once the thumbnails are reactified this should be moved there too.
|
|
|
|
Filmstrip.resizeThumbnailsForTileView(width, height, true);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SET_HORIZONTAL_VIEW_DIMENSIONS: {
|
|
|
|
const state = store.getState();
|
|
|
|
|
|
|
|
if (getCurrentLayout(state) === LAYOUTS.HORIZONTAL_FILMSTRIP_VIEW) {
|
|
|
|
const { horizontalViewDimensions = {} } = state['features/filmstrip'];
|
|
|
|
|
|
|
|
// Once the thumbnails are reactified this should be moved there too.
|
|
|
|
Filmstrip.resizeThumbnailsForHorizontalView(horizontalViewDimensions, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
});
|
|
|
|
|