From 471f3644be6a184d7b439d568c5f53cf54311886 Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Fri, 13 Dec 2024 01:00:05 +0100 Subject: [PATCH] feat: enable and disable message input and send button based on connection status --- zenoh-ts/examples/chat/src/main.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/zenoh-ts/examples/chat/src/main.ts b/zenoh-ts/examples/chat/src/main.ts index 5789ee0..207abe3 100644 --- a/zenoh-ts/examples/chat/src/main.ts +++ b/zenoh-ts/examples/chat/src/main.ts @@ -52,6 +52,8 @@ document.addEventListener('DOMContentLoaded', () => { chatLog.scrollTop = chatLog.scrollHeight; // Scroll to the latest message connectButton.style.display = 'none'; disconnectButton.style.display = 'inline-block'; + messageInput.disabled = false; + sendButton.disabled = false; } function onDisconnect(chatSession: ChatSession) { @@ -59,8 +61,13 @@ document.addEventListener('DOMContentLoaded', () => { chatLog.innerHTML = ''; connectButton.style.display = 'inline-block'; disconnectButton.style.display = 'none'; + messageInput.disabled = true; + sendButton.disabled = true; } + messageInput.disabled = true; + sendButton.disabled = true; + connectButton?.addEventListener('click', () => { log_catch(async () => { let user = ChatUser.fromString(usernameInput.value);