2022-11-10 08:45:56 +00:00
|
|
|
import { pinParticipant } from '../base/participants/actions';
|
|
|
|
import { getParticipantCountWithFake } from '../base/participants/functions';
|
|
|
|
import StateListenerRegistry from '../base/redux/StateListenerRegistry';
|
2023-01-25 15:02:26 +00:00
|
|
|
import { clientResized, setNarrowLayout } from '../base/responsive-ui/actions';
|
2023-01-27 14:30:47 +00:00
|
|
|
import { getHideSelfView } from '../base/settings/functions.any';
|
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-11-10 08:45:56 +00:00
|
|
|
import { LAYOUTS } from '../video-layout/constants';
|
|
|
|
import { getCurrentLayout, shouldDisplayTileView } from '../video-layout/functions.web';
|
2020-01-24 16:28:47 +00:00
|
|
|
|
2022-11-10 08:45:56 +00:00
|
|
|
import { clearStageParticipants,
|
|
|
|
setFilmstripVisible,
|
2021-08-18 22:34:01 +00:00
|
|
|
setHorizontalViewDimensions,
|
2022-09-27 07:10:28 +00:00
|
|
|
setScreenshareFilmstripParticipant,
|
2022-06-29 13:59:49 +00:00
|
|
|
setScreensharingTileDimensions,
|
2022-03-29 08:45:09 +00:00
|
|
|
setStageFilmstripViewDimensions,
|
2021-08-18 22:34:01 +00:00
|
|
|
setTileViewDimensions,
|
|
|
|
setVerticalViewDimensions
|
2022-07-29 11:13:02 +00:00
|
|
|
} from './actions.web';
|
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 {
|
2022-06-29 13:59:49 +00:00
|
|
|
isFilmstripResizable,
|
|
|
|
isTopPanelEnabled
|
2022-07-29 11:13:02 +00:00
|
|
|
} from './functions.web';
|
2022-03-29 08:45:09 +00:00
|
|
|
|
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),
|
2023-01-27 14:30:47 +00:00
|
|
|
disableSelfView: getHideSelfView(state),
|
2022-04-04 18:57:58 +00:00
|
|
|
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) {
|
2022-08-24 08:26:09 +00:00
|
|
|
case LAYOUTS.TILE_VIEW: {
|
|
|
|
const { pinnedParticipant } = store.getState()['features/base/participants'];
|
|
|
|
|
|
|
|
if (pinnedParticipant) {
|
|
|
|
store.dispatch(pinParticipant(null));
|
|
|
|
}
|
2022-07-20 15:34:46 +00:00
|
|
|
store.dispatch(clearStageParticipants());
|
2022-03-11 00:27:37 +00:00
|
|
|
store.dispatch(setTileViewDimensions());
|
2020-01-24 16:28:47 +00:00
|
|
|
break;
|
2022-08-24 08:26:09 +00:00
|
|
|
}
|
2020-01-24 16:28:47 +00:00
|
|
|
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) => {
|
2023-01-25 15:02:26 +00:00
|
|
|
store.dispatch(setOverflowDrawer(widthBelowThreshold));
|
|
|
|
store.dispatch(setNarrowLayout(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
|
|
|
|
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,
|
2022-05-09 21:35:37 +00:00
|
|
|
clientHeight: state['features/base/responsive-ui'].clientHeight,
|
2022-06-29 13:59:49 +00:00
|
|
|
tileView: state['features/video-layout'].tileViewEnabled,
|
|
|
|
height: state['features/filmstrip'].topPanelHeight?.current
|
2022-03-29 08:45:09 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
/* 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(
|
2022-07-20 15:34:46 +00:00
|
|
|
/* selector */ state => state['features/filmstrip'].activeParticipants,
|
|
|
|
/* listener */(activeParticipants, store) => {
|
|
|
|
if (activeParticipants.length <= 1) {
|
2022-03-29 08:45:09 +00:00
|
|
|
store.dispatch(selectParticipantInLargeVideo());
|
|
|
|
}
|
|
|
|
});
|
2022-06-29 13:59:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Listens for changes to determine the size of the screenshare filmstrip.
|
|
|
|
*/
|
|
|
|
StateListenerRegistry.register(
|
|
|
|
/* selector */ state => {
|
|
|
|
return {
|
|
|
|
length: state['features/video-layout'].remoteScreenShares.length,
|
|
|
|
clientWidth: state['features/base/responsive-ui'].clientWidth,
|
|
|
|
clientHeight: state['features/base/responsive-ui'].clientHeight,
|
|
|
|
height: state['features/filmstrip'].topPanelHeight?.current,
|
|
|
|
width: state['features/filmstrip'].width?.current,
|
|
|
|
visible: state['features/filmstrip'].visible,
|
|
|
|
topPanelVisible: state['features/filmstrip'].topPanelVisible
|
|
|
|
};
|
|
|
|
},
|
|
|
|
/* listener */({ length }, store) => {
|
|
|
|
if (length >= 1 && isTopPanelEnabled(store.getState())) {
|
|
|
|
store.dispatch(setScreensharingTileDimensions());
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
deepEquals: true
|
|
|
|
});
|
|
|
|
|
2022-07-29 11:13:02 +00:00
|
|
|
/**
|
|
|
|
* Listens for changes to clear invalid data.
|
|
|
|
*/
|
|
|
|
StateListenerRegistry.register(
|
|
|
|
/* selector */ state => state['features/video-layout'].remoteScreenShares.length,
|
|
|
|
/* listener */(length, store) => {
|
|
|
|
if (length === 0) {
|
|
|
|
store.dispatch(setScreenshareFilmstripParticipant());
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
deepEquals: true
|
|
|
|
});
|
|
|
|
|