Files
jitsi-meet/react/features/conference/components/AbstractInsecureRoomNameLabel.tsx

59 lines
1.4 KiB
TypeScript
Raw Normal View History

import React, { PureComponent } from 'react';
import { WithTranslation } from 'react-i18next';
2020-05-18 14:07:09 +02:00
import { IReduxState } from '../../app/types';
2020-05-18 14:07:09 +02:00
import isInsecureRoomName from '../../base/util/isInsecureRoomName';
import { isUnsafeRoomWarningEnabled } from '../../prejoin/functions';
2020-05-18 14:07:09 +02:00
interface IProps extends WithTranslation {
2020-05-18 14:07:09 +02:00
/**
* True of the label should be visible.
*/
_visible: boolean;
}
2020-05-18 14:07:09 +02:00
/**
* Abstract class for the {@Code InsecureRoomNameLabel} component.
2020-05-18 14:07:09 +02:00
*/
export default class AbstractInsecureRoomNameLabel extends PureComponent<IProps> {
2020-05-18 14:07:09 +02:00
/**
* Implements {@code Component#render}.
*
* @inheritdoc
*/
override render() {
2020-05-18 14:07:09 +02:00
if (!this.props._visible) {
return null;
}
return this._render();
}
/**
* Renders the platform dependent content.
2020-05-18 14:07:09 +02:00
*
* @returns {ReactElement}
*/
_render() {
return <></>;
}
2020-05-18 14:07:09 +02:00
}
/**
* Maps part of the Redux state to the props of this component.
*
* @param {Object} state - The Redux state.
* @returns {IProps}
2020-05-18 14:07:09 +02:00
*/
export function _mapStateToProps(state: IReduxState) {
const { locked, room } = state['features/base/conference'];
const { lobbyEnabled } = state['features/lobby'];
2020-05-18 14:07:09 +02:00
return {
_visible: Boolean(isUnsafeRoomWarningEnabled(state)
&& room && isInsecureRoomName(room)
&& !(lobbyEnabled || Boolean(locked)))
2020-05-18 14:07:09 +02:00
};
}