Skip to content

Commit

Permalink
feat: enable and disable message input and send button based on conne…
Browse files Browse the repository at this point in the history
…ction status
  • Loading branch information
milyin committed Dec 13, 2024
1 parent 370a8fd commit 471f364
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions zenoh-ts/examples/chat/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,22 @@ 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) {
usersList.innerHTML = '';
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);
Expand Down

0 comments on commit 471f364

Please sign in to comment.