diff options
author | metamuffin <metamuffin@disroot.org> | 2024-01-27 19:59:39 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-01-27 19:59:39 +0100 |
commit | 91259369b2b87eb647e9743c874d7e58894149c1 (patch) | |
tree | c717d3c4fb3322bb559a50eab1a2331f9c351a70 /client-web/source/keybinds.ts | |
parent | 0d8a3082fe32e9dd89deea9f051f6e53df591646 (diff) | |
download | keks-meet-91259369b2b87eb647e9743c874d7e58894149c1.tar keks-meet-91259369b2b87eb647e9743c874d7e58894149c1.tar.bz2 keks-meet-91259369b2b87eb647e9743c874d7e58894149c1.tar.zst |
handle room joins without page reload.
Diffstat (limited to 'client-web/source/keybinds.ts')
-rw-r--r-- | client-web/source/keybinds.ts | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/client-web/source/keybinds.ts b/client-web/source/keybinds.ts index dfc04b4..09fbb34 100644 --- a/client-web/source/keybinds.ts +++ b/client-web/source/keybinds.ts @@ -5,13 +5,12 @@ */ /// <reference lib="dom" /> -import { GLOBAL_CHAT } from "./chat.ts"; +import { AppState } from "./index.ts"; import { chat_control } from "./menu.ts"; import { create_camera_res, create_mic_res, create_screencast_res } from "./resource/track.ts"; -import { Room } from "./room.ts" import { update_serviceworker } from "./sw/client.ts"; -export function setup_keybinds(room: Room) { +export function setup_keybinds(state: AppState) { document.body.addEventListener("keydown", ev => { // TODO is there a proper solution? if (ev.target instanceof HTMLInputElement && !(ev.target.type == "button")) return @@ -21,12 +20,12 @@ export function setup_keybinds(room: Room) { ev.preventDefault() // so focused buttons dont trigger } if (ev.shiftKey) { - if (ev.code == "KeyM" || ev.code == "KeyR") room.local_user.await_add_resource(create_mic_res()) - if (ev.code == "KeyS") room.local_user.await_add_resource(create_screencast_res()) - if (ev.code == "KeyC" && !ev.ctrlKey) room.local_user.await_add_resource(create_camera_res()) - if (ev.code == "KeyC" && ev.ctrlKey) room.local_user.resources.forEach(t => t.destroy()) + if (ev.code == "KeyM" || ev.code == "KeyR") state.room?.local_user.await_add_resource(create_mic_res()) + if (ev.code == "KeyS") state.room?.local_user.await_add_resource(create_screencast_res()) + if (ev.code == "KeyC" && !ev.ctrlKey) state.room?.local_user.await_add_resource(create_camera_res()) + if (ev.code == "KeyC" && ev.ctrlKey) state.room?.local_user.resources.forEach(t => t.destroy()) if (ev.code == "KeyU") if (window.confirm("really update?")) update_serviceworker() - if (ev.code == "KeyV") GLOBAL_CHAT.remove_oldest_message() + if (ev.code == "KeyV") state.chat?.remove_oldest_message() } }) } |