Put keyboard shortcuts behind settings flag

This commit is contained in:
Erik Johnston 2022-11-14 10:21:24 +00:00
parent c9330debd4
commit b30ef953b4
4 changed files with 29 additions and 0 deletions

View file

@ -42,6 +42,7 @@
"Display name": "Display name", "Display name": "Display name",
"Download debug logs": "Download debug logs", "Download debug logs": "Download debug logs",
"Element Call Home": "Element Call Home", "Element Call Home": "Element Call Home",
"Enable keyboard shortcuts": "Enable keyboard shortcuts",
"Entering room…": "Entering room…", "Entering room…": "Entering room…",
"Exit full screen": "Exit full screen", "Exit full screen": "Exit full screen",
"Fetching group call timed out.": "Fetching group call timed out.", "Fetching group call timed out.": "Fetching group call timed out.",

View file

@ -33,6 +33,7 @@ import { usePageUnload } from "./usePageUnload";
import { PosthogAnalytics } from "../PosthogAnalytics"; import { PosthogAnalytics } from "../PosthogAnalytics";
import { TranslatedError, translatedError } from "../TranslatedError"; import { TranslatedError, translatedError } from "../TranslatedError";
import { ElementWidgetActions, ScreenshareStartData, widget } from "../widget"; import { ElementWidgetActions, ScreenshareStartData, widget } from "../widget";
import { getSetting } from "../settings/useSetting";
export interface UseGroupCallReturnType { export interface UseGroupCallReturnType {
state: GroupCallState; state: GroupCallState;
@ -404,6 +405,12 @@ export function useGroupCall(groupCall: GroupCall): UseGroupCallReturnType {
useEffect(() => { useEffect(() => {
const keyDownListener = (event) => { const keyDownListener = (event) => {
// Check if keyboard shortcuts are enabled
const keyboardShortcuts = getSetting("keyboard-shortcuts", true);
if (!keyboardShortcuts) {
return;
}
if (event.key === "m") { if (event.key === "m") {
toggleMicrophoneMuted(); toggleMicrophoneMuted();
} }
@ -413,6 +420,12 @@ export function useGroupCall(groupCall: GroupCall): UseGroupCallReturnType {
}; };
const keyUpListener = (event) => { const keyUpListener = (event) => {
// Check if keyboard shortcuts are enabled
const keyboardShortcuts = getSetting("keyboard-shortcuts", true);
if (!keyboardShortcuts) {
return;
}
if (event.key === " ") { if (event.key === " ") {
setMicrophoneMuted(true); setMicrophoneMuted(true);
} }

View file

@ -28,6 +28,7 @@ import { ReactComponent as OverflowIcon } from "../icons/Overflow.svg";
import { SelectInput } from "../input/SelectInput"; import { SelectInput } from "../input/SelectInput";
import { useMediaHandler } from "./useMediaHandler"; import { useMediaHandler } from "./useMediaHandler";
import { import {
useKeyboardShortcuts,
useSpatialAudio, useSpatialAudio,
useShowInspector, useShowInspector,
useOptInAnalytics, useOptInAnalytics,
@ -59,6 +60,7 @@ export const SettingsModal = (props: Props) => {
const [spatialAudio, setSpatialAudio] = useSpatialAudio(); const [spatialAudio, setSpatialAudio] = useSpatialAudio();
const [showInspector, setShowInspector] = useShowInspector(); const [showInspector, setShowInspector] = useShowInspector();
const [optInAnalytics, setOptInAnalytics] = useOptInAnalytics(); const [optInAnalytics, setOptInAnalytics] = useOptInAnalytics();
const [keyboardShortcuts, setKeyboardShortcuts] = useKeyboardShortcuts();
const downloadDebugLog = useDownloadDebugLog(); const downloadDebugLog = useDownloadDebugLog();
@ -166,6 +168,17 @@ export const SettingsModal = (props: Props) => {
} }
/> />
</FieldRow> </FieldRow>
<FieldRow>
<InputField
id="keyboardShortcuts"
label={t("Enable keyboard shortcuts")}
type="checkbox"
checked={keyboardShortcuts}
onChange={(event: React.ChangeEvent<HTMLInputElement>) =>
setKeyboardShortcuts(event.target.checked)
}
/>
</FieldRow>
</TabItem> </TabItem>
<TabItem <TabItem
title={ title={

View file

@ -61,3 +61,5 @@ export const getSetting = <T>(name: string, defaultValue: T): T => {
export const useSpatialAudio = () => useSetting("spatial-audio", false); export const useSpatialAudio = () => useSetting("spatial-audio", false);
export const useShowInspector = () => useSetting("show-inspector", false); export const useShowInspector = () => useSetting("show-inspector", false);
export const useOptInAnalytics = () => useSetting("opt-in-analytics", false); export const useOptInAnalytics = () => useSetting("opt-in-analytics", false);
export const useKeyboardShortcuts = () =>
useSetting("keyboard-shortcuts", true);