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

Show a warning on unencrypted media #1912

Merged
merged 1 commit into from
Nov 21, 2023
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: 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;
Comment on lines +129 to +132
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps a matter of style/preference, but I'd prefer to explicitly handle undefined instead of performing a comparison that would "convert" it into boolean.

Suggested change
const muted = audioInfo.isMuted !== false;
const encrypted =
audioInfo.publication?.isEncrypted !== false &&
videoInfo.publication?.isEncrypted !== false;
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