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/chat.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/chat.ts')
-rw-r--r-- | client-web/source/chat.ts | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/client-web/source/chat.ts b/client-web/source/chat.ts index 6025878..5d911c6 100644 --- a/client-web/source/chat.ts +++ b/client-web/source/chat.ts @@ -14,11 +14,10 @@ import { Room } from "./room.ts"; import { LocalUser } from "./user/local.ts"; import { User } from "./user/mod.ts"; -export let GLOBAL_CHAT: Chat; - interface ControlMessage { join?: User, leave?: User, + change_room?: string, } export class Chat { @@ -27,8 +26,9 @@ export class Chat { send_el: HTMLInputElement element: HTMLElement - constructor(public room: Room) { - GLOBAL_CHAT = this; + public room?: Room + + constructor() { const send = document.createElement("input") send.ariaLabel = "send message" send.type = "text" @@ -74,8 +74,10 @@ export class Chat { focus() { this.send_el.focus() } send(msg: ChatMessage) { - this.room.local_user.chat(msg) - this.add_message(this.room.local_user, msg) + if (this.room) { + this.room.local_user.chat(msg) + this.add_message(this.room.local_user, msg) + } } remove_oldest_message() { |