summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-09-06 23:13:06 +0200
committermetamuffin <metamuffin@disroot.org>2023-09-06 23:13:06 +0200
commit6af298c5a332f865e626e1ca3903a5004ba1527d (patch)
tree7c55bf1ff1a1a08d0e767e357c33eebba8865137
parent865607c4f4e992fd32c2241e896e56e1a4fcfe28 (diff)
downloadkeks-meet-6af298c5a332f865e626e1ca3903a5004ba1527d.tar
keks-meet-6af298c5a332f865e626e1ca3903a5004ba1527d.tar.bz2
keks-meet-6af298c5a332f865e626e1ca3903a5004ba1527d.tar.zst
fix automatic chat control
-rw-r--r--client-web/source/chat.ts4
-rw-r--r--client-web/source/index.ts2
-rw-r--r--client-web/source/keybinds.ts7
-rw-r--r--client-web/source/menu.ts8
4 files changed, 11 insertions, 10 deletions
diff --git a/client-web/source/chat.ts b/client-web/source/chat.ts
index e81c8f6..7721df3 100644
--- a/client-web/source/chat.ts
+++ b/client-web/source/chat.ts
@@ -8,6 +8,7 @@
import { ChatMessage } from "../../common/packets.d.ts";
import { ediv, esection, espan, image_view, notify } from "./helper.ts";
import { log } from "./logger.ts";
+import { chat_control } from "./menu.ts";
import { PREFS } from "./preferences/mod.ts";
import { Room } from "./room.ts";
import { LocalUser } from "./user/local.ts";
@@ -78,8 +79,7 @@ export class Chat {
if (message.text) els.push(espan(message.text, { class: "text" }))
if (message.image) els.push(image_view(message.image, { class: "image" }))
- // TODO! open
- // this.shown = true
+ chat_control(true)
const e = ediv({ class: "message" }, espan(sender.display_name, { class: "author" }), ": ", ...els)
this.messages.append(e)
e.scrollIntoView({ block: "end", behavior: "smooth", inline: "end" })
diff --git a/client-web/source/index.ts b/client-web/source/index.ts
index 9356d14..a01f7a7 100644
--- a/client-web/source/index.ts
+++ b/client-web/source/index.ts
@@ -14,7 +14,7 @@ import { SignalingConnection } from "./protocol/mod.ts";
import { Room } from "./room.ts"
import { control_bar, info_br } from "./menu.ts";
-export const VERSION = "0.1.12"
+export const VERSION = "0.1.13"
export interface ClientConfig {
appearance?: {
diff --git a/client-web/source/keybinds.ts b/client-web/source/keybinds.ts
index 700faeb..aaaefc7 100644
--- a/client-web/source/keybinds.ts
+++ b/client-web/source/keybinds.ts
@@ -5,6 +5,7 @@
*/
/// <reference lib="dom" />
+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";
@@ -15,10 +16,8 @@ export function setup_keybinds(room: Room) {
if (ev.target instanceof HTMLInputElement && !(ev.target.type == "button")) return
if (ev.repeat) return
if (ev.code == "Enter" && ev.ctrlKey) {
- // TODO! show chat
- // room.chat.shown = !room.chat.shown
- // if (room.chat.shown) room.chat.focus()
- // ev.preventDefault() // so focused buttons dont trigger
+ chat_control()
+ 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())
diff --git a/client-web/source/menu.ts b/client-web/source/menu.ts
index f64febb..7bb5b43 100644
--- a/client-web/source/menu.ts
+++ b/client-web/source/menu.ts
@@ -33,6 +33,7 @@ export function info_br() {
)
}
+export let chat_control: (s?: boolean) => void;
export function control_bar(room: Room, side_ui_container: HTMLElement): HTMLElement {
const leave = ebutton("Leave", { class: "leave", onclick() { window.location.href = "/" } })
@@ -44,10 +45,11 @@ export function control_bar(room: Room, side_ui_container: HTMLElement): HTMLEle
ebutton("Screen", { onclick: () => room.local_user.await_add_resource(create_screencast_res()) }),
ebutton("File", { onclick: () => room.local_user.await_add_resource(create_file_res()) }),
]
+ chat_control = chat.set_state;
return enav({ class: "control-bar" }, leave, chat.el, prefs.el, ...local_controls)
}
-export interface SideUI { el: HTMLElement, set_state: (s: boolean) => void }
+export interface SideUI { el: HTMLElement, set_state: (s?: boolean) => void }
export function side_ui(container: HTMLElement, content: HTMLElement, label: string): SideUI {
// TODO: close other side uis
const tray = ediv({ class: "side-tray" }, content)
@@ -68,6 +70,6 @@ export function side_ui(container: HTMLElement, content: HTMLElement, label: str
})
return {
el: elabel(label, { class: "side-ui-control" }, checkbox),
- set_state(s) { checkbox.checked = s }
+ set_state(s) { checkbox.checked = s ?? !checkbox.checked; if (checkbox.onchange) checkbox.onchange(undefined as unknown as Event) }
}
-} \ No newline at end of file
+}