2020-01-24 16:28:47 +00:00
|
|
|
// @flow
|
2021-03-26 20:23:05 +00:00
|
|
|
import type { Dispatch } from 'redux';
|
2020-01-24 16:28:47 +00:00
|
|
|
|
2021-08-19 19:41:17 +00:00
|
|
|
import { getLocalParticipant, getParticipantById, pinParticipant } from '../base/participants';
|
2020-03-09 11:54:54 +00:00
|
|
|
|
2021-03-26 20:23:05 +00:00
|
|
|
import {
|
|
|
|
SET_HORIZONTAL_VIEW_DIMENSIONS,
|
|
|
|
SET_TILE_VIEW_DIMENSIONS,
|
|
|
|
SET_VERTICAL_VIEW_DIMENSIONS,
|
|
|
|
SET_VOLUME
|
|
|
|
} from './actionTypes';
|
|
|
|
import {
|
|
|
|
HORIZONTAL_FILMSTRIP_MARGIN,
|
|
|
|
SCROLL_SIZE,
|
|
|
|
STAGE_VIEW_THUMBNAIL_HORIZONTAL_BORDER,
|
|
|
|
STAGE_VIEW_THUMBNAIL_VERTICAL_BORDER,
|
|
|
|
TILE_HORIZONTAL_MARGIN,
|
|
|
|
TILE_VERTICAL_MARGIN,
|
|
|
|
VERTICAL_FILMSTRIP_VERTICAL_MARGIN
|
|
|
|
} from './constants';
|
|
|
|
import {
|
|
|
|
calculateThumbnailSizeForHorizontalView,
|
|
|
|
calculateThumbnailSizeForTileView,
|
|
|
|
calculateThumbnailSizeForVerticalView
|
|
|
|
} from './functions';
|
2021-12-07 08:24:00 +00:00
|
|
|
import { getDisableSelfView } from './functions.any';
|
2020-01-24 16:28:47 +00:00
|
|
|
|
2021-08-23 23:02:41 +00:00
|
|
|
export * from './actions.any';
|
2021-08-18 22:34:01 +00:00
|
|
|
|
2020-01-24 16:28:47 +00:00
|
|
|
/**
|
|
|
|
* Sets the dimensions of the tile view grid.
|
|
|
|
*
|
|
|
|
* @param {Object} dimensions - Whether the filmstrip is visible.
|
2021-01-26 08:33:31 +00:00
|
|
|
* @param {Object | Function} stateful - An object or function that can be
|
|
|
|
* resolved to Redux state using the {@code toState} function.
|
2021-03-26 20:23:05 +00:00
|
|
|
* @returns {Function}
|
2020-01-24 16:28:47 +00:00
|
|
|
*/
|
2021-03-26 20:23:05 +00:00
|
|
|
export function setTileViewDimensions(dimensions: Object) {
|
|
|
|
return (dispatch: Dispatch<any>, getState: Function) => {
|
|
|
|
const state = getState();
|
|
|
|
const { clientHeight, clientWidth } = state['features/base/responsive-ui'];
|
|
|
|
const { disableResponsiveTiles } = state['features/base/config'];
|
|
|
|
const {
|
|
|
|
height,
|
|
|
|
width
|
|
|
|
} = calculateThumbnailSizeForTileView({
|
|
|
|
...dimensions,
|
|
|
|
clientWidth,
|
|
|
|
clientHeight,
|
|
|
|
disableResponsiveTiles
|
|
|
|
});
|
|
|
|
const { columns, rows } = dimensions;
|
|
|
|
const thumbnailsTotalHeight = rows * (TILE_VERTICAL_MARGIN + height);
|
|
|
|
const hasScroll = clientHeight < thumbnailsTotalHeight;
|
|
|
|
const filmstripWidth = (columns * (TILE_HORIZONTAL_MARGIN + width)) + (hasScroll ? SCROLL_SIZE : 0);
|
|
|
|
const filmstripHeight = Math.min(clientHeight, thumbnailsTotalHeight);
|
2020-03-09 11:54:54 +00:00
|
|
|
|
2021-03-26 20:23:05 +00:00
|
|
|
dispatch({
|
|
|
|
type: SET_TILE_VIEW_DIMENSIONS,
|
|
|
|
dimensions: {
|
|
|
|
gridDimensions: dimensions,
|
|
|
|
thumbnailSize: {
|
|
|
|
height,
|
|
|
|
width
|
|
|
|
},
|
|
|
|
filmstripHeight,
|
|
|
|
filmstripWidth
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
2020-01-24 16:28:47 +00:00
|
|
|
|
2021-03-26 20:23:05 +00:00
|
|
|
/**
|
|
|
|
* Sets the dimensions of the thumbnails in vertical view.
|
|
|
|
*
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function setVerticalViewDimensions() {
|
|
|
|
return (dispatch: Dispatch<any>, getState: Function) => {
|
|
|
|
const state = getState();
|
|
|
|
const { clientHeight = 0, clientWidth = 0 } = state['features/base/responsive-ui'];
|
2021-12-07 08:24:00 +00:00
|
|
|
const disableSelfView = getDisableSelfView(state);
|
2021-03-26 20:23:05 +00:00
|
|
|
const thumbnails = calculateThumbnailSizeForVerticalView(clientWidth);
|
|
|
|
|
|
|
|
dispatch({
|
|
|
|
type: SET_VERTICAL_VIEW_DIMENSIONS,
|
|
|
|
dimensions: {
|
|
|
|
...thumbnails,
|
|
|
|
remoteVideosContainer: {
|
|
|
|
width: thumbnails?.local?.width
|
|
|
|
+ TILE_HORIZONTAL_MARGIN + STAGE_VIEW_THUMBNAIL_HORIZONTAL_BORDER + SCROLL_SIZE,
|
2021-12-07 08:24:00 +00:00
|
|
|
height: clientHeight - (disableSelfView ? 0 : thumbnails?.local?.height)
|
|
|
|
- VERTICAL_FILMSTRIP_VERTICAL_MARGIN
|
2021-03-26 20:23:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
2020-01-24 16:28:47 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the dimensions of the thumbnails in horizontal view.
|
|
|
|
*
|
2021-03-26 20:23:05 +00:00
|
|
|
* @returns {Function}
|
2020-01-24 16:28:47 +00:00
|
|
|
*/
|
2021-03-26 20:23:05 +00:00
|
|
|
export function setHorizontalViewDimensions() {
|
|
|
|
return (dispatch: Dispatch<any>, getState: Function) => {
|
|
|
|
const state = getState();
|
|
|
|
const { clientHeight = 0, clientWidth = 0 } = state['features/base/responsive-ui'];
|
2021-12-07 08:24:00 +00:00
|
|
|
const disableSelfView = getDisableSelfView(state);
|
2021-03-26 20:23:05 +00:00
|
|
|
const thumbnails = calculateThumbnailSizeForHorizontalView(clientHeight);
|
|
|
|
|
|
|
|
dispatch({
|
|
|
|
type: SET_HORIZONTAL_VIEW_DIMENSIONS,
|
|
|
|
dimensions: {
|
|
|
|
...thumbnails,
|
|
|
|
remoteVideosContainer: {
|
2021-12-07 08:24:00 +00:00
|
|
|
width: clientWidth - (disableSelfView ? 0 : thumbnails?.local?.width) - HORIZONTAL_FILMSTRIP_MARGIN,
|
2021-03-26 20:23:05 +00:00
|
|
|
height: thumbnails?.local?.height
|
|
|
|
+ TILE_VERTICAL_MARGIN + STAGE_VIEW_THUMBNAIL_VERTICAL_BORDER + SCROLL_SIZE
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2020-01-24 16:28:47 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-01-21 20:46:47 +00:00
|
|
|
/**
|
|
|
|
* Emulates a click on the n-th video.
|
|
|
|
*
|
|
|
|
* @param {number} n - Number that identifies the video.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function clickOnVideo(n: number) {
|
|
|
|
return (dispatch: Function, getState: Function) => {
|
2021-07-09 12:36:19 +00:00
|
|
|
const state = getState();
|
2021-08-19 19:41:17 +00:00
|
|
|
const { id: localId } = getLocalParticipant(state);
|
|
|
|
|
2021-08-19 21:56:45 +00:00
|
|
|
// Use the list that correctly represents the current order of the participants as visible in the UI.
|
2021-08-19 19:41:17 +00:00
|
|
|
const { remoteParticipants } = state['features/filmstrip'];
|
|
|
|
const participants = [ localId, ...remoteParticipants ];
|
|
|
|
const { id, pinned } = getParticipantById(state, participants[n]);
|
2021-01-21 20:46:47 +00:00
|
|
|
|
|
|
|
dispatch(pinParticipant(pinned ? null : id));
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-03-26 20:23:05 +00:00
|
|
|
/**
|
2021-06-30 07:30:38 +00:00
|
|
|
* Sets the volume for a thumbnail's audio.
|
2021-03-26 20:23:05 +00:00
|
|
|
*
|
|
|
|
* @param {string} participantId - The participant ID asociated with the audio.
|
|
|
|
* @param {string} volume - The volume level.
|
|
|
|
* @returns {{
|
|
|
|
* type: SET_VOLUME,
|
|
|
|
* participantId: string,
|
|
|
|
* volume: number
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function setVolume(participantId: string, volume: number) {
|
|
|
|
return {
|
|
|
|
type: SET_VOLUME,
|
|
|
|
participantId,
|
|
|
|
volume
|
|
|
|
};
|
|
|
|
}
|