Skip to content

armgit / meet

Public Imported from GitHub
0

Open source video conferencing app powered by LiveKit. Built with Django and React.

🐛(frontend) fix shortcut handler type to properly handle promises

lebaudantoinebcf551a25c10
diff --git a/src/frontend/src/features/rooms/livekit/components/controls/Device/ToggleDevice.tsx b/src/frontend/src/features/rooms/livekit/components/controls/Device/ToggleDevice.tsx
index a567980e..b6770ca3 100644
--- a/src/frontend/src/features/rooms/livekit/components/controls/Device/ToggleDevice.tsx
+++ b/src/frontend/src/features/rooms/livekit/components/controls/Device/ToggleDevice.tsx
@@ -87,7 +87,7 @@ export const ToggleDevice = <T extends ToggleSource>({
useRegisterKeyboardShortcut({
shortcut: deviceShortcut,
- handler: toggle,
+ handler: async () => await toggle(),
isDisabled: cannotUseDevice,
})
useLongPress({
diff --git a/src/frontend/src/features/shortcuts/useKeyboardShortcuts.ts b/src/frontend/src/features/shortcuts/useKeyboardShortcuts.ts
index 09b471a6..d26fdf19 100644
--- a/src/frontend/src/features/shortcuts/useKeyboardShortcuts.ts
+++ b/src/frontend/src/features/shortcuts/useKeyboardShortcuts.ts
@@ -10,7 +10,7 @@ export const useKeyboardShortcuts = () => {
useEffect(() => {
// This approach handles basic shortcuts but isn't comprehensive.
// Issues might occur. First draft.
- const onKeyDown = (e: KeyboardEvent) => {
+ const onKeyDown = async (e: KeyboardEvent) => {
const { key, metaKey, ctrlKey } = e
if (!key) return
const shortcutKey = formatShortcutKey({
@@ -20,7 +20,7 @@ export const useKeyboardShortcuts = () => {
const shortcut = shortcutsSnap.shortcuts.get(shortcutKey)
if (!shortcut) return
e.preventDefault()
- shortcut()
+ await shortcut()
}
window.addEventListener('keydown', onKeyDown)
diff --git a/src/frontend/src/features/shortcuts/useRegisterKeyboardShortcut.ts b/src/frontend/src/features/shortcuts/useRegisterKeyboardShortcut.ts
index 70b816f7..f39b1141 100644
--- a/src/frontend/src/features/shortcuts/useRegisterKeyboardShortcut.ts
+++ b/src/frontend/src/features/shortcuts/useRegisterKeyboardShortcut.ts
@@ -5,7 +5,7 @@ import { Shortcut } from '@/features/shortcuts/types'
export type useRegisterKeyboardShortcutProps = {
shortcut?: Shortcut
- handler: () => void
+ handler: () => Promise<void | boolean | undefined> | void
isDisabled?: boolean
}