2020-01-24 16:28:47 +00:00
|
|
|
// @flow
|
|
|
|
|
2021-12-08 13:36:41 +00:00
|
|
|
import { isMobileBrowser } from '../base/environment/utils';
|
2021-07-09 12:36:19 +00:00
|
|
|
import { getParticipantCountWithFake } from '../base/participants';
|
2020-05-20 10:57:03 +00:00
|
|
|
import { StateListenerRegistry, equals } 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';
|
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';
|
2020-01-24 16:28:47 +00:00
|
|
|
import { getCurrentLayout, getTileViewGridDimensions, shouldDisplayTileView, LAYOUTS } from '../video-layout';
|
|
|
|
|
2021-08-18 22:34:01 +00:00
|
|
|
import {
|
|
|
|
setHorizontalViewDimensions,
|
|
|
|
setTileViewDimensions,
|
|
|
|
setVerticalViewDimensions
|
2021-08-23 23:02:41 +00:00
|
|
|
} from './actions';
|
2021-01-18 10:17:23 +00:00
|
|
|
import {
|
|
|
|
ASPECT_RATIO_BREAKPOINT,
|
|
|
|
DISPLAY_DRAWER_THRESHOLD,
|
|
|
|
SINGLE_COLUMN_BREAKPOINT,
|
|
|
|
TWO_COLUMN_BREAKPOINT
|
|
|
|
} from './constants';
|
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),
|
2021-12-16 16:55:45 +00:00
|
|
|
disableSelfView: shouldHideSelfView(state)
|
2021-12-07 08:24:00 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
/* listener */ (currentState, store) => {
|
2020-01-24 16:28:47 +00:00
|
|
|
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;
|
|
|
|
|
|
|
|
if (!equals(gridDimensions, oldGridDimensions)) {
|
2021-03-26 20:23:05 +00:00
|
|
|
store.dispatch(setTileViewDimensions(gridDimensions));
|
2020-01-24 16:28:47 +00:00
|
|
|
}
|
|
|
|
}
|
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(
|
|
|
|
/* selector */ state => getCurrentLayout(state),
|
|
|
|
/* listener */ (layout, store) => {
|
|
|
|
const state = store.getState();
|
|
|
|
|
|
|
|
switch (layout) {
|
2021-03-26 20:23:05 +00:00
|
|
|
case LAYOUTS.TILE_VIEW:
|
|
|
|
store.dispatch(setTileViewDimensions(getTileViewGridDimensions(state)));
|
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());
|
2020-01-24 16:28:47 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
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
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Symbol mapping used for the tile view responsiveness computation.
|
|
|
|
*/
|
|
|
|
const responsiveColumnMapping = {
|
2021-03-05 17:31:23 +00:00
|
|
|
multipleColumns: Symbol('multipleColumns'),
|
2021-01-18 10:17:23 +00:00
|
|
|
singleColumn: Symbol('singleColumn'),
|
|
|
|
twoColumns: Symbol('twoColumns'),
|
|
|
|
twoParticipantsSingleColumn: Symbol('twoParticipantsSingleColumn')
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Listens for changes in the screen size to recompute
|
|
|
|
* the dimensions of the tile view grid and the tiles for responsiveness.
|
|
|
|
*/
|
|
|
|
StateListenerRegistry.register(
|
|
|
|
/* selector */ state => {
|
|
|
|
const { clientWidth } = state['features/base/responsive-ui'];
|
|
|
|
|
|
|
|
if (clientWidth < TWO_COLUMN_BREAKPOINT && clientWidth >= ASPECT_RATIO_BREAKPOINT) {
|
|
|
|
// Forcing the recomputation of tiles when screen switches in or out of
|
|
|
|
// the (TWO_COLUMN_BREAKPOINT, ASPECT_RATIO_BREAKPOINT] interval.
|
|
|
|
return responsiveColumnMapping.twoColumns;
|
|
|
|
} else if (clientWidth < ASPECT_RATIO_BREAKPOINT && clientWidth >= SINGLE_COLUMN_BREAKPOINT) {
|
|
|
|
// Forcing the recomputation of tiles when screen switches in or out of
|
|
|
|
// the (ASPECT_RATIO_BREAKPOINT, SINGLE_COLUMN_BREAKPOINT] interval.
|
|
|
|
return responsiveColumnMapping.twoParticipantsSingleColumn;
|
2021-03-05 17:31:23 +00:00
|
|
|
} else if (clientWidth < SINGLE_COLUMN_BREAKPOINT) {
|
|
|
|
// Forcing the recomputation of tiles when screen switches below SINGLE_COLUMN_BREAKPOINT.
|
|
|
|
return responsiveColumnMapping.singleColumn;
|
2021-01-18 10:17:23 +00:00
|
|
|
}
|
|
|
|
|
2021-03-05 17:31:23 +00:00
|
|
|
// Forcing the recomputation of tiles when screen switches above TWO_COLUMN_BREAKPOINT.
|
|
|
|
return responsiveColumnMapping.multipleColumns;
|
2021-01-18 10:17:23 +00:00
|
|
|
},
|
|
|
|
/* listener */ (_, store) => {
|
|
|
|
const state = store.getState();
|
|
|
|
|
|
|
|
if (shouldDisplayTileView(state)) {
|
|
|
|
const gridDimensions = getTileViewGridDimensions(state);
|
2021-03-26 20:23:05 +00:00
|
|
|
|
|
|
|
store.dispatch(setTileViewDimensions(gridDimensions));
|
2021-01-18 10:17:23 +00:00
|
|
|
}
|
|
|
|
});
|