Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(prejoin): Device indicator. #15278

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lang/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@
"joinWithoutAudio": "Join without audio",
"keyboardShortcuts": "Enable Keyboard shortcuts",
"linkCopied": "Link copied to clipboard",
"lookGood": "Everything is working properly",
"lookGood": "Your devices are working properly",
"or": "or",
"premeeting": "Pre meeting",
"proceedAnyway": "Proceed anyway",
Expand Down
47 changes: 11 additions & 36 deletions react/features/prejoin/components/web/preview/DeviceStatus.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,16 @@
import React from 'react';
import { WithTranslation } from 'react-i18next';
import { connect } from 'react-redux';
import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';
import { makeStyles } from 'tss-react/mui';

import { IReduxState } from '../../../../app/types';
import { translate } from '../../../../base/i18n/functions';
import { ColorPalette } from '../../../../base/styles/components/styles/ColorPalette';
import { withPixelLineHeight } from '../../../../base/styles/functions.web';
import {
getDeviceStatusText,
getDeviceStatusType
} from '../../../functions';

export interface IProps extends WithTranslation {

/**
* The text to be displayed in relation to the status of the audio/video devices.
*/
deviceStatusText?: string;

/**
* The type of status for current devices, controlling the background color of the text.
* Can be `ok` or `warning`.
*/
deviceStatusType?: string;
}

const useStyles = makeStyles()(theme => {
const useStyles = makeStyles<{ deviceStatusType?: string; }>()((theme, { deviceStatusType = 'pending' }) => {
return {
deviceStatus: {
display: 'flex',
Expand Down Expand Up @@ -57,7 +42,7 @@ const useStyles = makeStyles()(theme => {
width: '16px',
height: '16px',
borderRadius: '100%',
backgroundColor: theme.palette.success01
backgroundColor: deviceStatusType === 'ok' ? theme.palette.success01 : ColorPalette.darkGrey
}
};
});
Expand All @@ -68,8 +53,11 @@ const useStyles = makeStyles()(theme => {
*
* @returns {ReactElement}
*/
function DeviceStatus({ deviceStatusType, deviceStatusText, t }: IProps) {
const { classes, cx } = useStyles();
function DeviceStatus() {
const { t } = useTranslation();
const deviceStatusType = useSelector(getDeviceStatusType);
const deviceStatusText = useSelector(getDeviceStatusText);
const { classes, cx } = useStyles({ deviceStatusType });
const hasError = deviceStatusType === 'warning';
const containerClassName = cx(classes.deviceStatus, { 'device-status-error': hasError });

Expand All @@ -86,17 +74,4 @@ function DeviceStatus({ deviceStatusType, deviceStatusText, t }: IProps) {
);
}

/**
* Maps (parts of) the redux state to the React {@code Component} props.
*
* @param {Object} state - The redux state.
* @returns {{ deviceStatusText: string, deviceStatusText: string }}
*/
function mapStateToProps(state: IReduxState) {
return {
deviceStatusText: getDeviceStatusText(state),
deviceStatusType: getDeviceStatusType(state)
};
}

export default translate(connect(mapStateToProps)(DeviceStatus));
export default DeviceStatus;
7 changes: 6 additions & 1 deletion react/features/prejoin/functions.any.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ export function isJoinByPhoneButtonVisible(state: IReduxState): boolean {
*/
export function isDeviceStatusVisible(state: IReduxState): boolean {
return !(isAudioMuted(state) && isVideoMutedByUser(state))
&& !state['features/base/config'].startSilent;
&& !state['features/base/config'].startSilent

// This handles the case where disableInitialGUM=true and we haven't yet tried to create any tracks. In this
// case we shouldn't display the the device status indicator. But once we create some tracks we can show it
// because we would know if we created the tracks successfully or not.
&& (!state['features/base/config'].disableInitialGUM || state['features/base/tracks']?.length > 0);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion react/features/prejoin/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
const DEFAULT_STATE = {
country: '',
deviceStatusText: 'prejoin.configuringDevices',
deviceStatusType: 'ok',
deviceStatusType: 'pending',
dialOutCountry: {
name: 'United States',
dialCode: '1',
Expand Down