feat: Introduces iAmVisitor mode.

This commit is contained in:
damencho 2023-02-23 12:43:16 -06:00 committed by Дамян Минков
parent 3c69645169
commit d7f6c2bbf0
10 changed files with 38 additions and 21 deletions

View File

@ -153,7 +153,7 @@ import { createRnnoiseProcessor } from './react/features/stream-effects/rnnoise'
import { endpointMessageReceived } from './react/features/subtitles'; import { endpointMessageReceived } from './react/features/subtitles';
import { handleToggleVideoMuted } from './react/features/toolbox/actions.any'; import { handleToggleVideoMuted } from './react/features/toolbox/actions.any';
import { muteLocal } from './react/features/video-menu/actions.any'; import { muteLocal } from './react/features/video-menu/actions.any';
import { setVisitorsMode } from './react/features/visitors/actions'; import { setIAmVisitor } from './react/features/visitors/actions';
import UIEvents from './service/UI/UIEvents'; import UIEvents from './service/UI/UIEvents';
const logger = Logger.getLogger(__filename); const logger = Logger.getLogger(__filename);
@ -343,7 +343,7 @@ class ConferenceConnector {
case JitsiConferenceErrors.REDIRECTED: { case JitsiConferenceErrors.REDIRECTED: {
generateVisitorConfig(APP.store.getState(), params); generateVisitorConfig(APP.store.getState(), params);
APP.store.dispatch(setVisitorsMode(true)); APP.store.dispatch(setIAmVisitor(true));
connection.disconnect().then(() => { connection.disconnect().then(() => {
connect(this._conference.roomName).then(con => { connect(this._conference.roomName).then(con => {

View File

@ -1,4 +1,5 @@
import { IReduxState } from '../../app/types'; import { IReduxState } from '../../app/types';
import { iAmVisitor } from '../../visitors/functions';
import { IStateful } from '../app/types'; import { IStateful } from '../app/types';
import CONFIG_WHITELIST from '../config/configWhitelist'; import CONFIG_WHITELIST from '../config/configWhitelist';
import { IConfigState } from '../config/reducer'; import { IConfigState } from '../config/reducer';
@ -121,5 +122,5 @@ export function shouldHideShareAudioHelper(state: IReduxState): boolean | undefi
*/ */
export function getHideSelfView(state: IReduxState) { export function getHideSelfView(state: IReduxState) {
return state['features/base/config'].disableSelfView || state['features/base/settings'].disableSelfView return state['features/base/config'].disableSelfView || state['features/base/settings'].disableSelfView
|| state['features/visitors'].enabled; || iAmVisitor(state);
} }

View File

@ -12,6 +12,7 @@ import { ChatButton } from '../../../chat';
import { ReactionsMenuButton } from '../../../reactions/components'; import { ReactionsMenuButton } from '../../../reactions/components';
import { isReactionsEnabled } from '../../../reactions/functions.any'; import { isReactionsEnabled } from '../../../reactions/functions.any';
import { TileViewButton } from '../../../video-layout'; import { TileViewButton } from '../../../video-layout';
import { iAmVisitor } from '../../../visitors/functions';
import { getMovableButtons, isToolboxVisible } from '../../functions.native'; import { getMovableButtons, isToolboxVisible } from '../../functions.native';
import AudioMuteButton from '../AudioMuteButton'; import AudioMuteButton from '../AudioMuteButton';
import HangupButton from '../HangupButton'; import HangupButton from '../HangupButton';
@ -148,7 +149,7 @@ function _mapStateToProps(state: Object): Object {
_endConferenceSupported: Boolean(endConferenceSupported), _endConferenceSupported: Boolean(endConferenceSupported),
_styles: ColorSchemeRegistry.get(state, 'Toolbox'), _styles: ColorSchemeRegistry.get(state, 'Toolbox'),
_visible: isToolboxVisible(state), _visible: isToolboxVisible(state),
_visitorsModeEnabled: state['features/visitors'].enabled, _visitorsModeEnabled: iAmVisitor(state),
_width: state['features/base/responsive-ui'].clientWidth, _width: state['features/base/responsive-ui'].clientWidth,
_reactionsEnabled: isReactionsEnabled(state) _reactionsEnabled: isReactionsEnabled(state)
}; };

View File

@ -101,6 +101,7 @@ import {
import { VideoQualityButton, VideoQualityDialog } from '../../../video-quality/components'; import { VideoQualityButton, VideoQualityDialog } from '../../../video-quality/components';
// @ts-ignore // @ts-ignore
import { VideoBackgroundButton } from '../../../virtual-background'; import { VideoBackgroundButton } from '../../../virtual-background';
import { iAmVisitor } from '../../../visitors/functions';
import WhiteboardButton from '../../../whiteboard/components/web/WhiteboardButton'; import WhiteboardButton from '../../../whiteboard/components/web/WhiteboardButton';
import { isWhiteboardButtonVisible } from '../../../whiteboard/functions'; import { isWhiteboardButtonVisible } from '../../../whiteboard/functions';
import { import {
@ -1565,7 +1566,7 @@ function _mapStateToProps(state: IReduxState, ownProps: Partial<IProps>) {
const { clientWidth } = state['features/base/responsive-ui']; const { clientWidth } = state['features/base/responsive-ui'];
let toolbarButtons = ownProps.toolbarButtons || getToolbarButtons(state); let toolbarButtons = ownProps.toolbarButtons || getToolbarButtons(state);
if (state['features/visitors'].enabled) { if (iAmVisitor(state)) {
toolbarButtons = VISITORS_MODE_BUTTONS.filter(e => toolbarButtons.indexOf(e) > -1); toolbarButtons = VISITORS_MODE_BUTTONS.filter(e => toolbarButtons.indexOf(e) > -1);
} }

View File

@ -12,8 +12,8 @@ export const UPDATE_VISITORS_COUNT = 'UPDATE_VISITORS_COUNT';
* The type of (redux) action which enables/disables visitors UI mode. * The type of (redux) action which enables/disables visitors UI mode.
* *
* { * {
* type: VISITORS_MODE_ENABLED, * type: I_AM_VISITOR_MODE,
* enabled: boolean * enabled: boolean
* } * }
*/ */
export const VISITORS_MODE_ENABLED = 'VISITORS_MODE_ENABLED'; export const I_AM_VISITOR_MODE = 'I_AM_VISITOR_MODE';

View File

@ -1,16 +1,16 @@
import { UPDATE_VISITORS_COUNT, VISITORS_MODE_ENABLED } from './actionTypes'; import { I_AM_VISITOR_MODE, UPDATE_VISITORS_COUNT } from './actionTypes';
/** /**
* Sets Visitors mode on or off. * Sets Visitors mode on or off.
* *
* @param {boolean} enabled - The new visitors mode state. * @param {boolean} enabled - The new visitors mode state.
* @returns {{ * @returns {{
* type: VISITORS_MODE_ENABLED, * type: I_AM_VISITOR_MODE,
* }} * }}
*/ */
export function setVisitorsMode(enabled: boolean) { export function setIAmVisitor(enabled: boolean) {
return { return {
type: VISITORS_MODE_ENABLED, type: I_AM_VISITOR_MODE,
enabled enabled
}; };
} }

View File

@ -7,7 +7,7 @@ import { IconUsers } from '../../../base/icons/svg';
// @ts-ignore // @ts-ignore
import Label from '../../../base/label/components/native/Label'; import Label from '../../../base/label/components/native/Label';
import BaseTheme from '../../../base/ui/components/BaseTheme.native'; import BaseTheme from '../../../base/ui/components/BaseTheme.native';
import { getVisitorsShortText } from '../../functions'; import { getVisitorsShortText, iAmVisitor } from '../../functions';
const styles = { const styles = {
raisedHandsCountLabel: { raisedHandsCountLabel: {
@ -26,7 +26,7 @@ const styles = {
}; };
const VisitorsCountLabel = () => { const VisitorsCountLabel = () => {
const visitorsMode = useSelector((state: IReduxState) => state['features/visitors'].enabled); const visitorsMode = useSelector((state: IReduxState) => iAmVisitor(state));
const visitorsCount = useSelector((state: IReduxState) => const visitorsCount = useSelector((state: IReduxState) =>
state['features/visitors'].count || 0); state['features/visitors'].count || 0);

View File

@ -9,7 +9,7 @@ import Label from '../../../base/label/components/web/Label';
// eslint-disable-next-line lines-around-comment // eslint-disable-next-line lines-around-comment
// @ts-ignore // @ts-ignore
import { Tooltip } from '../../../base/tooltip'; import { Tooltip } from '../../../base/tooltip';
import { getVisitorsShortText } from '../../functions'; import { getVisitorsShortText, iAmVisitor } from '../../functions';
const useStyles = makeStyles()(theme => { const useStyles = makeStyles()(theme => {
return { return {
@ -22,7 +22,7 @@ const useStyles = makeStyles()(theme => {
const VisitorsCountLabel = () => { const VisitorsCountLabel = () => {
const { classes: styles, theme } = useStyles(); const { classes: styles, theme } = useStyles();
const visitorsMode = useSelector((state: IReduxState) => state['features/visitors'].enabled); const visitorsMode = useSelector((state: IReduxState) => iAmVisitor(state));
const visitorsCount = useSelector((state: IReduxState) => const visitorsCount = useSelector((state: IReduxState) =>
state['features/visitors'].count || 0); state['features/visitors'].count || 0);
const { t } = useTranslation(); const { t } = useTranslation();

View File

@ -1,3 +1,6 @@
import { IStateful } from '../base/app/types';
import { toState } from '../base/redux/functions';
/** /**
* A short string to represent the number of visitors. * A short string to represent the number of visitors.
* Over 100 we show numbers like 0.2 K or 9.5 K. * Over 100 we show numbers like 0.2 K or 9.5 K.
@ -9,3 +12,14 @@
export function getVisitorsShortText(visitorsCount: number) { export function getVisitorsShortText(visitorsCount: number) {
return visitorsCount > 100 ? `${Math.round(visitorsCount / 100) / 10} K` : String(visitorsCount); return visitorsCount > 100 ? `${Math.round(visitorsCount / 100) / 10} K` : String(visitorsCount);
} }
/**
* Whether current UI is in visitor mode.
*
* @param {Function|Object} stateful - The redux store or {@code getState}
* function.
* @returns {boolean} Whether iAmVisitor is set.
*/
export function iAmVisitor(stateful: IStateful) {
return toState(stateful)['features/visitors'].iAmVisitor;
}

View File

@ -1,17 +1,17 @@
import ReducerRegistry from '../base/redux/ReducerRegistry'; import ReducerRegistry from '../base/redux/ReducerRegistry';
import { import {
UPDATE_VISITORS_COUNT, I_AM_VISITOR_MODE,
VISITORS_MODE_ENABLED UPDATE_VISITORS_COUNT
} from './actionTypes'; } from './actionTypes';
const DEFAULT_STATE = { const DEFAULT_STATE = {
enabled: false iAmVisitor: false
}; };
export interface IVisitorsState { export interface IVisitorsState {
count?: number; count?: number;
enabled: boolean; iAmVisitor: boolean;
} }
ReducerRegistry.register<IVisitorsState>('features/visitors', (state = DEFAULT_STATE, action): IVisitorsState => { ReducerRegistry.register<IVisitorsState>('features/visitors', (state = DEFAULT_STATE, action): IVisitorsState => {
switch (action.type) { switch (action.type) {
@ -25,10 +25,10 @@ ReducerRegistry.register<IVisitorsState>('features/visitors', (state = DEFAULT_S
count: action.count count: action.count
}; };
} }
case VISITORS_MODE_ENABLED: { case I_AM_VISITOR_MODE: {
return { return {
...state, ...state,
enabled: action.enabled iAmVisitor: action.enabled
}; };
} }
} }