2022-08-09 12:22:18 +00:00
|
|
|
import { PARTICIPANT_LEFT } from '../base/participants/actionTypes';
|
|
|
|
import ReducerRegistry from '../base/redux/ReducerRegistry';
|
2018-02-05 21:52:41 +00:00
|
|
|
|
2018-02-06 09:40:16 +00:00
|
|
|
import {
|
2022-09-27 07:10:28 +00:00
|
|
|
CLEAR_STAGE_PARTICIPANTS,
|
2022-03-29 08:45:09 +00:00
|
|
|
REMOVE_STAGE_PARTICIPANT,
|
2018-02-06 09:40:16 +00:00
|
|
|
SET_FILMSTRIP_ENABLED,
|
2022-09-27 07:10:28 +00:00
|
|
|
SET_FILMSTRIP_HEIGHT,
|
2020-01-24 16:28:47 +00:00
|
|
|
SET_FILMSTRIP_VISIBLE,
|
2022-02-24 12:20:37 +00:00
|
|
|
SET_FILMSTRIP_WIDTH,
|
2020-01-24 16:28:47 +00:00
|
|
|
SET_HORIZONTAL_VIEW_DIMENSIONS,
|
2021-08-18 22:34:01 +00:00
|
|
|
SET_REMOTE_PARTICIPANTS,
|
2022-09-27 07:10:28 +00:00
|
|
|
SET_SCREENSHARE_FILMSTRIP_PARTICIPANT,
|
|
|
|
SET_SCREENSHARING_TILE_DIMENSIONS,
|
2022-03-29 08:45:09 +00:00
|
|
|
SET_STAGE_FILMSTRIP_DIMENSIONS,
|
2022-09-27 07:10:28 +00:00
|
|
|
SET_STAGE_PARTICIPANTS,
|
2021-03-26 20:23:05 +00:00
|
|
|
SET_TILE_VIEW_DIMENSIONS,
|
2022-09-27 07:10:28 +00:00
|
|
|
SET_TOP_PANEL_VISIBILITY,
|
|
|
|
SET_USER_FILMSTRIP_HEIGHT,
|
2022-02-24 12:20:37 +00:00
|
|
|
SET_USER_FILMSTRIP_WIDTH,
|
2022-03-14 11:11:22 +00:00
|
|
|
SET_USER_IS_RESIZING,
|
2021-03-26 20:23:05 +00:00
|
|
|
SET_VERTICAL_VIEW_DIMENSIONS,
|
2021-05-19 23:23:40 +00:00
|
|
|
SET_VISIBLE_REMOTE_PARTICIPANTS,
|
2022-09-27 07:10:28 +00:00
|
|
|
SET_VOLUME
|
2018-02-06 09:40:16 +00:00
|
|
|
} from './actionTypes';
|
2017-05-23 18:58:07 +00:00
|
|
|
|
|
|
|
const DEFAULT_STATE = {
|
2022-03-29 08:45:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The list of participants to be displayed on the stage filmstrip.
|
|
|
|
*/
|
|
|
|
activeParticipants: [],
|
|
|
|
|
2018-02-12 17:42:38 +00:00
|
|
|
/**
|
|
|
|
* The indicator which determines whether the {@link Filmstrip} is enabled.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2018-02-06 09:40:16 +00:00
|
|
|
enabled: true,
|
2018-02-12 17:42:38 +00:00
|
|
|
|
2020-01-24 16:28:47 +00:00
|
|
|
/**
|
|
|
|
* The horizontal view dimensions.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {Object}
|
|
|
|
*/
|
|
|
|
horizontalViewDimensions: {},
|
|
|
|
|
2022-03-14 11:11:22 +00:00
|
|
|
/**
|
|
|
|
* Whether or not the user is actively resizing the filmstrip.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
isResizing: false,
|
|
|
|
|
2021-03-26 20:23:05 +00:00
|
|
|
/**
|
2021-06-30 07:30:38 +00:00
|
|
|
* The custom audio volume levels per participant.
|
2021-03-26 20:23:05 +00:00
|
|
|
*
|
|
|
|
* @type {Object}
|
|
|
|
*/
|
|
|
|
participantsVolume: {},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The ordered IDs of the remote participants displayed in the filmstrip.
|
|
|
|
*
|
2021-08-18 22:34:01 +00:00
|
|
|
* @public
|
|
|
|
* @type {Array<string>}
|
2021-03-26 20:23:05 +00:00
|
|
|
*/
|
|
|
|
remoteParticipants: [],
|
|
|
|
|
2022-06-29 13:59:49 +00:00
|
|
|
/**
|
|
|
|
* The dimensions of the screenshare filmstrip.
|
|
|
|
*/
|
|
|
|
screenshareFilmstripDimensions: {},
|
|
|
|
|
2022-07-29 11:13:02 +00:00
|
|
|
/**
|
|
|
|
* The id of the participant whose screenshare to
|
|
|
|
* display on the screenshare filmstrip.
|
|
|
|
*/
|
|
|
|
screenshareFilmstripParticipantId: null,
|
|
|
|
|
2022-03-29 08:45:09 +00:00
|
|
|
/**
|
|
|
|
* The stage filmstrip view dimensions.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {Object}
|
|
|
|
*/
|
|
|
|
stageFilmstripDimensions: {},
|
|
|
|
|
2020-01-24 16:28:47 +00:00
|
|
|
/**
|
|
|
|
* The tile view dimensions.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {Object}
|
|
|
|
*/
|
|
|
|
tileViewDimensions: {},
|
|
|
|
|
2022-06-29 13:59:49 +00:00
|
|
|
/**
|
|
|
|
* The height of the resizable top panel.
|
|
|
|
*/
|
|
|
|
topPanelHeight: {
|
|
|
|
/**
|
|
|
|
* Current height. Affected by: user top panel resize,
|
|
|
|
* window resize.
|
|
|
|
*/
|
|
|
|
current: null,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Height set by user resize. Used as the preferred height.
|
|
|
|
*/
|
|
|
|
userSet: null
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The indicator determines if the top panel is visible.
|
|
|
|
*/
|
|
|
|
topPanelVisible: true,
|
|
|
|
|
2021-03-26 20:23:05 +00:00
|
|
|
/**
|
|
|
|
* The vertical view dimensions.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {Object}
|
|
|
|
*/
|
|
|
|
verticalViewDimensions: {},
|
|
|
|
|
2018-02-12 17:42:38 +00:00
|
|
|
/**
|
|
|
|
* The indicator which determines whether the {@link Filmstrip} is visible.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2021-05-19 23:23:40 +00:00
|
|
|
visible: true,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The end index in the remote participants array that is visible in the filmstrip.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {number}
|
|
|
|
*/
|
|
|
|
visibleParticipantsEndIndex: 0,
|
|
|
|
|
|
|
|
/**
|
2021-08-18 22:34:01 +00:00
|
|
|
* The start index in the remote participants array that is visible in the filmstrip.
|
2021-05-19 23:23:40 +00:00
|
|
|
*
|
|
|
|
* @public
|
2021-08-18 22:34:01 +00:00
|
|
|
* @type {number}
|
2021-05-19 23:23:40 +00:00
|
|
|
*/
|
2021-08-18 22:34:01 +00:00
|
|
|
visibleParticipantsStartIndex: 0,
|
2021-05-19 23:23:40 +00:00
|
|
|
|
|
|
|
/**
|
2021-08-18 22:34:01 +00:00
|
|
|
* The visible remote participants in the filmstrip.
|
2021-05-19 23:23:40 +00:00
|
|
|
*
|
|
|
|
* @public
|
2021-08-18 22:34:01 +00:00
|
|
|
* @type {Set<string>}
|
2021-05-19 23:23:40 +00:00
|
|
|
*/
|
2022-08-09 12:22:18 +00:00
|
|
|
visibleRemoteParticipants: new Set<string>(),
|
2022-02-24 12:20:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The width of the resizable filmstrip.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @type {Object}
|
|
|
|
*/
|
|
|
|
width: {
|
|
|
|
/**
|
|
|
|
* Current width. Affected by: user filmstrip resize,
|
|
|
|
* window resize, panels open/ close.
|
|
|
|
*/
|
|
|
|
current: null,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Width set by user resize. Used as the preferred width.
|
|
|
|
*/
|
|
|
|
userSet: null
|
|
|
|
}
|
2017-05-23 18:58:07 +00:00
|
|
|
};
|
|
|
|
|
2022-10-20 09:11:27 +00:00
|
|
|
interface IDimensions {
|
2022-08-09 12:22:18 +00:00
|
|
|
height: number;
|
|
|
|
width: number;
|
|
|
|
}
|
|
|
|
|
2022-10-20 09:11:27 +00:00
|
|
|
interface IFilmstripDimensions {
|
2022-08-09 12:22:18 +00:00
|
|
|
filmstripHeight?: number;
|
|
|
|
filmstripWidth?: number;
|
|
|
|
gridDimensions?: {
|
|
|
|
columns: number;
|
|
|
|
rows: number;
|
2022-09-08 09:52:36 +00:00
|
|
|
};
|
2022-08-09 12:22:18 +00:00
|
|
|
hasScroll?: boolean;
|
2022-10-20 09:11:27 +00:00
|
|
|
thumbnailSize?: IDimensions;
|
2022-08-09 12:22:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface IFilmstripState {
|
|
|
|
activeParticipants: Array<{
|
|
|
|
participantId: string;
|
2022-09-08 09:52:36 +00:00
|
|
|
pinned?: boolean;
|
2022-08-09 12:22:18 +00:00
|
|
|
}>;
|
|
|
|
enabled: boolean;
|
|
|
|
horizontalViewDimensions: {
|
|
|
|
hasScroll?: boolean;
|
2022-10-20 09:11:27 +00:00
|
|
|
local?: IDimensions;
|
|
|
|
remote?: IDimensions;
|
|
|
|
remoteVideosContainer?: IDimensions;
|
2022-08-09 12:22:18 +00:00
|
|
|
};
|
|
|
|
isResizing: boolean;
|
|
|
|
participantsVolume: {
|
|
|
|
[participantId: string]: number;
|
|
|
|
};
|
|
|
|
remoteParticipants: string[];
|
|
|
|
screenshareFilmstripDimensions: {
|
|
|
|
filmstripHeight?: number;
|
|
|
|
filmstripWidth?: number;
|
2022-10-20 09:11:27 +00:00
|
|
|
thumbnailSize?: IDimensions;
|
2022-08-09 12:22:18 +00:00
|
|
|
};
|
2022-09-08 09:52:36 +00:00
|
|
|
screenshareFilmstripParticipantId?: string | null;
|
2022-10-20 09:11:27 +00:00
|
|
|
stageFilmstripDimensions: IFilmstripDimensions;
|
|
|
|
tileViewDimensions?: IFilmstripDimensions;
|
2022-08-09 12:22:18 +00:00
|
|
|
topPanelHeight: {
|
2022-09-08 09:52:36 +00:00
|
|
|
current: number | null;
|
|
|
|
userSet: number | null;
|
2022-08-09 12:22:18 +00:00
|
|
|
};
|
|
|
|
topPanelVisible: boolean;
|
|
|
|
verticalViewDimensions: {
|
|
|
|
gridView?: {
|
|
|
|
gridDimensions: {
|
|
|
|
columns: number;
|
|
|
|
rows: number;
|
|
|
|
};
|
|
|
|
hasScroll: boolean;
|
2022-10-20 09:11:27 +00:00
|
|
|
thumbnailSize: IDimensions;
|
2022-08-09 12:22:18 +00:00
|
|
|
};
|
|
|
|
hasScroll?: boolean;
|
2022-10-20 09:11:27 +00:00
|
|
|
local?: IDimensions;
|
|
|
|
remote?: IDimensions;
|
|
|
|
remoteVideosContainer?: IDimensions;
|
2022-08-09 12:22:18 +00:00
|
|
|
};
|
|
|
|
visible: boolean;
|
|
|
|
visibleParticipantsEndIndex: number;
|
|
|
|
visibleParticipantsStartIndex: number;
|
|
|
|
visibleRemoteParticipants: Set<string>;
|
|
|
|
width: {
|
2022-09-08 09:52:36 +00:00
|
|
|
current: number | null;
|
|
|
|
userSet: number | null;
|
|
|
|
};
|
2022-08-09 12:22:18 +00:00
|
|
|
}
|
|
|
|
|
2022-09-05 09:05:07 +00:00
|
|
|
ReducerRegistry.register<IFilmstripState>(
|
2017-05-23 18:58:07 +00:00
|
|
|
'features/filmstrip',
|
2022-09-05 09:05:07 +00:00
|
|
|
(state = DEFAULT_STATE, action): IFilmstripState => {
|
2017-05-23 18:58:07 +00:00
|
|
|
switch (action.type) {
|
2018-02-06 09:40:16 +00:00
|
|
|
case SET_FILMSTRIP_ENABLED:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
enabled: action.enabled
|
|
|
|
};
|
|
|
|
|
2018-02-05 21:52:41 +00:00
|
|
|
case SET_FILMSTRIP_VISIBLE:
|
2017-05-23 18:58:07 +00:00
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
visible: action.visible
|
|
|
|
};
|
2020-01-24 16:28:47 +00:00
|
|
|
|
|
|
|
case SET_HORIZONTAL_VIEW_DIMENSIONS:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
horizontalViewDimensions: action.dimensions
|
|
|
|
};
|
2021-08-18 22:34:01 +00:00
|
|
|
case SET_REMOTE_PARTICIPANTS: {
|
|
|
|
state.remoteParticipants = action.participants;
|
2021-08-20 23:32:38 +00:00
|
|
|
const { visibleParticipantsStartIndex: startIndex, visibleParticipantsEndIndex: endIndex } = state;
|
2021-08-23 23:02:41 +00:00
|
|
|
|
2021-08-20 23:32:38 +00:00
|
|
|
state.visibleRemoteParticipants = new Set(state.remoteParticipants.slice(startIndex, endIndex + 1));
|
2021-08-18 22:34:01 +00:00
|
|
|
|
|
|
|
return { ...state };
|
|
|
|
}
|
2020-01-24 16:28:47 +00:00
|
|
|
case SET_TILE_VIEW_DIMENSIONS:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
tileViewDimensions: action.dimensions
|
|
|
|
};
|
2021-03-26 20:23:05 +00:00
|
|
|
case SET_VERTICAL_VIEW_DIMENSIONS:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
verticalViewDimensions: action.dimensions
|
|
|
|
};
|
|
|
|
case SET_VOLUME:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
participantsVolume: {
|
|
|
|
...state.participantsVolume,
|
|
|
|
|
|
|
|
// NOTE: This would fit better in the features/base/participants. But currently we store
|
|
|
|
// the participants as an array which will make it expensive to search for the volume for
|
|
|
|
// every participant separately.
|
|
|
|
[action.participantId]: action.volume
|
|
|
|
}
|
|
|
|
};
|
2021-08-18 22:34:01 +00:00
|
|
|
case SET_VISIBLE_REMOTE_PARTICIPANTS: {
|
2022-05-06 10:18:57 +00:00
|
|
|
const { endIndex, startIndex } = action;
|
|
|
|
const { remoteParticipants } = state;
|
|
|
|
const visibleRemoteParticipants = new Set(remoteParticipants.slice(startIndex, endIndex + 1));
|
|
|
|
|
2021-05-19 23:23:40 +00:00
|
|
|
return {
|
|
|
|
...state,
|
2022-05-06 10:18:57 +00:00
|
|
|
visibleParticipantsStartIndex: startIndex,
|
|
|
|
visibleParticipantsEndIndex: endIndex,
|
|
|
|
visibleRemoteParticipants
|
2021-05-19 23:23:40 +00:00
|
|
|
};
|
2021-03-26 20:23:05 +00:00
|
|
|
}
|
|
|
|
case PARTICIPANT_LEFT: {
|
|
|
|
const { id, local } = action.participant;
|
|
|
|
|
|
|
|
if (local) {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
delete state.participantsVolume[id];
|
|
|
|
|
2021-08-20 23:32:38 +00:00
|
|
|
return {
|
|
|
|
...state
|
|
|
|
};
|
2021-03-26 20:23:05 +00:00
|
|
|
}
|
2022-06-29 13:59:49 +00:00
|
|
|
case SET_FILMSTRIP_HEIGHT:{
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
topPanelHeight: {
|
|
|
|
...state.topPanelHeight,
|
|
|
|
current: action.height
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2022-02-24 12:20:37 +00:00
|
|
|
case SET_FILMSTRIP_WIDTH: {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
width: {
|
|
|
|
...state.width,
|
|
|
|
current: action.width
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2022-06-29 13:59:49 +00:00
|
|
|
case SET_USER_FILMSTRIP_HEIGHT: {
|
|
|
|
const { height } = action;
|
|
|
|
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
topPanelHeight: {
|
|
|
|
current: height,
|
|
|
|
userSet: height
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2022-02-24 12:20:37 +00:00
|
|
|
case SET_USER_FILMSTRIP_WIDTH: {
|
|
|
|
const { width } = action;
|
|
|
|
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
width: {
|
|
|
|
current: width,
|
|
|
|
userSet: width
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2022-03-14 11:11:22 +00:00
|
|
|
case SET_USER_IS_RESIZING: {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
isResizing: action.resizing
|
|
|
|
};
|
|
|
|
}
|
2022-03-29 08:45:09 +00:00
|
|
|
case SET_STAGE_FILMSTRIP_DIMENSIONS: {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
stageFilmstripDimensions: action.dimensions
|
|
|
|
};
|
|
|
|
}
|
|
|
|
case SET_STAGE_PARTICIPANTS: {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
activeParticipants: action.queue
|
|
|
|
};
|
|
|
|
}
|
|
|
|
case REMOVE_STAGE_PARTICIPANT: {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
activeParticipants: state.activeParticipants.filter(p => p.participantId !== action.participantId)
|
|
|
|
};
|
|
|
|
}
|
2022-04-12 13:19:10 +00:00
|
|
|
case CLEAR_STAGE_PARTICIPANTS: {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
activeParticipants: []
|
|
|
|
};
|
|
|
|
}
|
2022-06-29 13:59:49 +00:00
|
|
|
case SET_SCREENSHARING_TILE_DIMENSIONS: {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
screenshareFilmstripDimensions: action.dimensions
|
|
|
|
};
|
|
|
|
}
|
|
|
|
case SET_TOP_PANEL_VISIBILITY: {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
topPanelVisible: action.visible
|
|
|
|
};
|
|
|
|
}
|
2022-07-29 11:13:02 +00:00
|
|
|
case SET_SCREENSHARE_FILMSTRIP_PARTICIPANT: {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
screenshareFilmstripParticipantId: action.participantId
|
|
|
|
};
|
|
|
|
}
|
2017-05-23 18:58:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return state;
|
|
|
|
});
|