diff options
author | metamuffin <metamuffin@disroot.org> | 2023-09-16 21:43:56 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-09-16 21:43:56 +0200 |
commit | 51e81cc623dff86768f71a95dc566bb306f287a6 (patch) | |
tree | 677d2381f7d34c91e7ac8575bd26bd67d4ab7cb4 | |
parent | 5ad932401d6949e4234e2a926b9b2323b06b324d (diff) | |
download | keks-meet-51e81cc623dff86768f71a95dc566bb306f287a6.tar keks-meet-51e81cc623dff86768f71a95dc566bb306f287a6.tar.bz2 keks-meet-51e81cc623dff86768f71a95dc566bb306f287a6.tar.zst |
keybind to clear oldest message
-rw-r--r-- | client-web/source/chat.ts | 7 | ||||
-rw-r--r-- | client-web/source/keybinds.ts | 2 |
2 files changed, 9 insertions, 0 deletions
diff --git a/client-web/source/chat.ts b/client-web/source/chat.ts index 9a1af1a..cfcbe64 100644 --- a/client-web/source/chat.ts +++ b/client-web/source/chat.ts @@ -14,6 +14,8 @@ import { Room } from "./room.ts"; import { LocalUser } from "./user/local.ts"; import { User } from "./user/mod.ts"; +export let GLOBAL_CHAT: Chat; + export class Chat { messages: HTMLElement controls: HTMLElement @@ -21,6 +23,7 @@ export class Chat { element: HTMLElement constructor(public room: Room) { + GLOBAL_CHAT = this; const send = document.createElement("input") send.ariaLabel = "send message" send.type = "text" @@ -71,6 +74,10 @@ export class Chat { this.add_message(this.room.local_user, msg) } + remove_oldest_message() { + this.messages.firstChild?.remove() + } + add_message(sender: User, message: ChatMessage) { const els = [] if (message.text) els.push(e("span", { class: "text" }, message.text)) diff --git a/client-web/source/keybinds.ts b/client-web/source/keybinds.ts index 83e05b8..dfc04b4 100644 --- a/client-web/source/keybinds.ts +++ b/client-web/source/keybinds.ts @@ -5,6 +5,7 @@ */ /// <reference lib="dom" /> +import { GLOBAL_CHAT } from "./chat.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" @@ -25,6 +26,7 @@ export function setup_keybinds(room: Room) { 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 == "KeyU") if (window.confirm("really update?")) update_serviceworker() + if (ev.code == "KeyV") GLOBAL_CHAT.remove_oldest_message() } }) } |