Skip to content

Commit

Permalink
Show a warning on unencrypted media
Browse files Browse the repository at this point in the history
  • Loading branch information
robintown committed Nov 21, 2023
1 parent aa8ef57 commit 49a5051
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/room/InCallView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ export const InCallView: FC<InCallViewProps> = ({
data={maximisedParticipant.data}
showSpeakingIndicator={false}
showConnectionStats={showConnectionStats}
matrixInfo={matrixInfo}
/>
);
}
Expand All @@ -310,6 +311,7 @@ export const InCallView: FC<InCallViewProps> = ({
onToggleFullscreen={toggleFullscreen}
showSpeakingIndicator={items.length > 2}
showConnectionStats={showConnectionStats}
matrixInfo={matrixInfo}
{...props}
ref={props.ref as Ref<HTMLDivElement>}
/>
Expand Down
8 changes: 6 additions & 2 deletions src/video-grid/VideoTile.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ limitations under the License.
flex-shrink: 0;
}

.nameTag > svg[data-muted="true"] {
.muteIcon[data-muted="true"] {
color: var(--cpd-color-icon-secondary);
}

.nameTag > svg[data-muted="false"] {
.muteIcon[data-muted="false"] {
color: var(--cpd-color-icon-primary);
}

Expand All @@ -103,6 +103,10 @@ limitations under the License.
padding-inline: var(--cpd-space-2x);
}

.errorIcon {
color: var(--cpd-color-icon-critical-primary);
}

.toolbar {
position: absolute;
top: 0;
Expand Down
48 changes: 40 additions & 8 deletions src/video-grid/VideoTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ import {
} from "matrix-js-sdk/src/models/room-member";
import MicOnSolidIcon from "@vector-im/compound-design-tokens/icons/mic-on-solid.svg?react";
import MicOffSolidIcon from "@vector-im/compound-design-tokens/icons/mic-off-solid.svg?react";
import { Text } from "@vector-im/compound-web";
import ErrorIcon from "@vector-im/compound-design-tokens/icons/error.svg?react";
import { Text, Tooltip } from "@vector-im/compound-web";

import { Avatar } from "../Avatar";
import styles from "./VideoTile.module.css";
import { useReactiveState } from "../useReactiveState";
import { AudioButton, FullscreenButton } from "../button/Button";
import { VideoTileSettingsModal } from "./VideoTileSettingsModal";
import { MatrixInfo } from "../room/VideoPreview";

export interface ItemData {
id: string;
Expand All @@ -68,6 +70,9 @@ interface Props {
style?: ComponentProps<typeof animated.div>["style"];
showSpeakingIndicator: boolean;
showConnectionStats: boolean;
// TODO: This dependency in particular should probably not be here. We can fix
// this with a view model.
matrixInfo: MatrixInfo;
}

export const VideoTile = forwardRef<HTMLDivElement, Props>(
Expand All @@ -83,6 +88,7 @@ export const VideoTile = forwardRef<HTMLDivElement, Props>(
targetHeight,
showSpeakingIndicator,
showConnectionStats,
matrixInfo,
},
tileRef,
) => {
Expand All @@ -108,13 +114,22 @@ export const VideoTile = forwardRef<HTMLDivElement, Props>(
}
}, [member, setDisplayName]);

const muted =
useMediaTrack(
content === TileContent.UserMedia
? Track.Source.Microphone
: Track.Source.ScreenShareAudio,
sfuParticipant,
).isMuted !== false;
const audioInfo = useMediaTrack(
content === TileContent.UserMedia
? Track.Source.Microphone
: Track.Source.ScreenShareAudio,
sfuParticipant,
);
const videoInfo = useMediaTrack(
content === TileContent.UserMedia
? Track.Source.Camera
: Track.Source.ScreenShare,
sfuParticipant,
);
const muted = audioInfo.isMuted !== false;
const encrypted =
audioInfo.publication?.isEncrypted !== false &&
videoInfo.publication?.isEncrypted !== false;

const MicIcon = muted ? MicOffSolidIcon : MicOnSolidIcon;

Expand Down Expand Up @@ -202,12 +217,29 @@ export const VideoTile = forwardRef<HTMLDivElement, Props>(
height={20}
aria-label={muted ? t("microphone_off") : t("microphone_on")}
data-muted={muted}
className={styles.muteIcon}
/>
<Text as="span" size="sm" weight="medium">
{sfuParticipant.isLocal
? t("video_tile.sfu_participant_local")
: displayName}
</Text>
{matrixInfo.roomEncrypted && !encrypted && (
<Tooltip label={t("common.unencrypted")} side="bottom">
<ErrorIcon
width={20}
height={20}
aria-label={t("common.unencrypted")}
className={styles.errorIcon}
// Make the icon focusable so that the tooltip can be opened
// with keyboard navigation
// TODO: Replace this with the solution from
// https://github.com/vector-im/compound-web/pull/130 once it
// lands
tabIndex={0}
/>
</Tooltip>
)}
{showConnectionStats && (
<ConnectionQualityIndicator participant={sfuParticipant} />
)}
Expand Down

0 comments on commit 49a5051

Please sign in to comment.