Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
toger5 committed Aug 21, 2024
1 parent 5bf46eb commit 636e681
Show file tree
Hide file tree
Showing 9 changed files with 213 additions and 44 deletions.
1 change: 1 addition & 0 deletions public/locales/en-GB/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
"feedback_tab_title": "Feedback",
"more_tab_title": "More",
"opt_in_description": "<0></0><1></1>You may withdraw consent by unchecking this box. If you are currently in a call, this setting will take effect at the end of the call.",
"show_debug_view": "",
"speaker_device_selection_label": "Speaker"
},
"star_rating_input_label_one": "{{count}} stars",
Expand Down
28 changes: 28 additions & 0 deletions src/debug/DebugView.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.container {
padding: 0.5em;
z-index: 2;
display: flex;
}
.dataContainer {
background-color: var(--cpd-color-bg-canvas-default);
border-radius: 10px;
overflow: auto;
width: 500px;
}
.hideButton {
background: none;
border: none;
}
.memberContainer {
background-color: var(--cpd-color-bg-subtle-secondary);
border-radius: 10px;
margin: 0.5em;
padding: 0.5em;
}

.encryptionEventContainer {
background-color: var(--cpd-color-bg-subtle-secondary);
border-radius: 10px;
margin: 0.5em;
padding: 0.5em;
}
102 changes: 102 additions & 0 deletions src/debug/DebugView.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
Copyright 2024 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import { MatrixRTCSession } from "matrix-js-sdk/src/matrixrtc/MatrixRTCSession";
import { FC, useState } from "react";
import { Text } from "@vector-im/compound-web";
import { MatrixClient, MatrixEvent } from "matrix-js-sdk";
import { CallMembership } from "matrix-js-sdk/src/matrixrtc/CallMembership";

import styles from "./DebugView.module.css";

interface Props {
rtcSession: MatrixRTCSession;
client: MatrixClient;
}

export const DebugView: FC<Props> = ({ rtcSession, client }) => {
const [isShown, setIsShown] = useState(true);
const room = rtcSession.room;
const events = room
.getLiveTimeline()
.getEvents()
.filter((ev) => ev.getType() === "io.element.call.encryption_keys")
.map((ev: MatrixEvent) => <EncryptionEventContainer event={ev} />);
const listItems = rtcSession.memberships.map((m) => (
<MemberContainer membership={m} />
));
return (
<div className={styles.container}>
{isShown && (
<div className={styles.dataContainer}>
{listItems}
<ul>{events}</ul>
</div>
)}
<button
className={styles.hideButton}
onClick={() => setIsShown(!isShown)}
>
{isShown ? <b>{"<"}</b> : <b>{">"}</b>}
</button>
</div>
);
};

interface MemberContainerProps {
membership: CallMembership;
}
const MemberContainer: FC<MemberContainerProps> = ({ membership }) => {
return (
<div className={styles.memberContainer}>
<Text as="span" size="md" weight="semibold">
{membership.sender}
</Text>
<br />
<Text as="span" size="sm" weight="regular">
Device Id: {membership.deviceId}
</Text>
</div>
);
};

interface EncryptionEventContainerProps {
event: MatrixEvent;
}
const EncryptionEventContainer: FC<EncryptionEventContainerProps> = ({
event,
}) => {
const keys = event
.getContent()
.keys.map((obj: { index: number; key: string }) => (
<>
index {obj.index}: {obj.key}
<br />
</>
));
return (
<div className={styles.memberContainer}>
<Text as="span" size="md" weight="semibold">
{event.sender}
</Text>
<br />
<Text as="span" size="sm" weight="regular">
Keys: {keys}
</Text>
<br />
</div>
);
};
6 changes: 3 additions & 3 deletions src/livekit/MediaDevicesContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export const MediaDevicesProvider: FC<Props> = ({ children }) => {

// On FF we dont need to query the names
// (call enumerateDevices + create meadia stream to trigger permissions)
// for ouput devices because the selector wont be shown on FF.
// for output devices because the selector wont be shown on FF.
const useOutputNames = usingNames && !isFirefox();

const [storedAudioInput, setStoredAudioInput] = useSetting(audioInputSetting);
Expand All @@ -166,8 +166,8 @@ export const MediaDevicesProvider: FC<Props> = ({ children }) => {
}, [setStoredAudioInput, audioInput.selectedId]);

useEffect(() => {
// Skip setting state for ff output. Redundent since it is set to always return 'undefined'
// but makes it clear while debugging that this is not happening on FF. + perf ;)
// Skip setting state for ff output. Redundant since it is set to always return 'undefined'
// but makes it clear while debugging that this is not happening on FF. (+ perf)
if (audioOutput.selectedId !== undefined && !isFirefox())
setStoredAudioOutput(audioOutput.selectedId);
}, [setStoredAudioOutput, audioOutput.selectedId]);
Expand Down
2 changes: 1 addition & 1 deletion src/livekit/useLiveKit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export function useLiveKit(
} catch (e) {
if ((e as DOMException).name === "NotAllowedError") {
logger.error(
"Fatal errror while syncing mute state: resetting",
"Fatal error while syncing mute state: resetting",
e,
);
if (type === MuteDevice.Microphone) {
Expand Down
7 changes: 7 additions & 0 deletions src/room/InCallView.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ limitations under the License.
overflow-y: auto;
}

.debugViewContainer {
display: flex;
flex-direction: row;
height: 100%;
width: 100%;
}

.controlsOverlay {
position: relative;
flex: 1;
Expand Down
92 changes: 52 additions & 40 deletions src/room/InCallView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ import { makeOneOnOneLayout } from "../grid/OneOnOneLayout";
import { makeSpotlightExpandedLayout } from "../grid/SpotlightExpandedLayout";
import { makeSpotlightLandscapeLayout } from "../grid/SpotlightLandscapeLayout";
import { makeSpotlightPortraitLayout } from "../grid/SpotlightPortraitLayout";
import { DebugView } from "../debug/DebugView";
import {
useSetting,
showDebugView as showDebugViewSetting,
} from "../settings/settings";

const canScreenshare = "getDisplayMedia" in (navigator.mediaDevices ?? {});

Expand Down Expand Up @@ -494,47 +499,54 @@ export const InCallView: FC<InCallViewProps> = ({
);
}

const [showDebugView] = useSetting(showDebugViewSetting);

return (
<div className={styles.inRoom} ref={containerRef}>
{windowMode !== "pip" &&
windowMode !== "flat" &&
(hideHeader ? (
// Cosmetic header to fill out space while still affecting the bounds
// of the grid
<div
className={classNames(styles.header, styles.filler)}
ref={headerRef}
/>
) : (
<Header className={styles.header} ref={headerRef}>
<LeftNav>
<RoomHeaderInfo
id={matrixInfo.roomId}
name={matrixInfo.roomName}
avatarUrl={matrixInfo.roomAvatar}
encrypted={matrixInfo.e2eeSystem.kind !== E2eeType.NONE}
participantCount={participantCount}
/>
</LeftNav>
<RightNav>
{!reducedControls && showControls && onShareClick !== null && (
<InviteButton onClick={onShareClick} />
)}
</RightNav>
</Header>
))}
<RoomAudioRenderer />
{renderContent()}
{footer}
{!noControls && <RageshakeRequestModal {...rageshakeRequestModalProps} />}
<SettingsModal
client={client}
roomId={rtcSession.room.roomId}
open={settingsModalOpen}
onDismiss={closeSettings}
tab={settingsTab}
onTabChange={setSettingsTab}
/>
<div className={styles.debugViewContainer}>
{showDebugView && <DebugView rtcSession={rtcSession} client={client} />}
<div className={styles.inRoom} ref={containerRef}>
{windowMode !== "pip" &&
windowMode !== "flat" &&
(hideHeader ? (
// Cosmetic header to fill out space while still affecting the bounds
// of the grid
<div
className={classNames(styles.header, styles.filler)}
ref={headerRef}
/>
) : (
<Header className={styles.header} ref={headerRef}>
<LeftNav>
<RoomHeaderInfo
id={matrixInfo.roomId}
name={matrixInfo.roomName}
avatarUrl={matrixInfo.roomAvatar}
encrypted={matrixInfo.e2eeSystem.kind !== E2eeType.NONE}
participantCount={participantCount}
/>
</LeftNav>
<RightNav>
{!reducedControls && showControls && onShareClick !== null && (
<InviteButton onClick={onShareClick} />
)}
</RightNav>
</Header>
))}
<RoomAudioRenderer />
{renderContent()}
{footer}
{!noControls && (
<RageshakeRequestModal {...rageshakeRequestModalProps} />
)}
<SettingsModal
client={client}
roomId={rtcSession.room.roomId}
open={settingsModalOpen}
onDismiss={closeSettings}
tab={settingsTab}
onTabChange={setSettingsTab}
/>
</div>
</div>
);
};
17 changes: 17 additions & 0 deletions src/settings/SettingsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
optInAnalytics as optInAnalyticsSetting,
developerSettingsTab as developerSettingsTabSetting,
duplicateTiles as duplicateTilesSetting,
showDebugView as showDebugViewSetting,
} from "./settings";
import { isFirefox } from "../Platform";

Expand Down Expand Up @@ -83,6 +84,8 @@ export const SettingsModal: FC<Props> = ({
);
const [duplicateTiles, setDuplicateTiles] = useSetting(duplicateTilesSetting);

const [showDebugView, setShowDebugView] = useSetting(showDebugViewSetting);

// Generate a `SelectInput` with a list of devices for a given device kind.
const generateDeviceSelection = (
devices: MediaDevice,
Expand Down Expand Up @@ -260,6 +263,20 @@ export const SettingsModal: FC<Props> = ({
)}
/>
</FieldRow>
<FieldRow>
<InputField
id="showDebugView"
type="checkbox"
label={t("settings.show_debug_view")}
checked={showDebugView}
onChange={useCallback(
(event: ChangeEvent<HTMLInputElement>): void => {
setShowDebugView(event.target.checked);
},
[setShowDebugView],
)}
/>
</FieldRow>
</TabItem>
);

Expand Down
2 changes: 2 additions & 0 deletions src/settings/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ export const developerSettingsTab = new Setting(

export const duplicateTiles = new Setting("duplicate-tiles", 0);

export const showDebugView = new Setting("show-debug-view", false);

export const audioInput = new Setting<string | undefined>(
"audio-input",
undefined,
Expand Down

0 comments on commit 636e681

Please sign in to comment.