From 6ca7ce492a279d338708e163c08c31a685a84c06 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Sun, 5 May 2024 11:28:16 +1200 Subject: [PATCH] disable send button when can't send message --- public/index.html | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/public/index.html b/public/index.html index 8f1638c..af0ad43 100644 --- a/public/index.html +++ b/public/index.html @@ -344,7 +344,7 @@ - @@ -612,9 +612,8 @@ }, async sendMessage() { - // do nothing if empty message - const messageText = this.newMessageText.trim(); - if(messageText == null || messageText === ""){ + // do nothing if can't send message + if(!this.canSendMessage){ return; } @@ -1050,7 +1049,18 @@ // no peer, so no chat items! return []; - } + }, + canSendMessage() { + + // can't send if empty message + const messageText = this.newMessageText.trim(); + if(messageText == null || messageText === ""){ + return false; + } + + return true; + + }, }, }).mount('#app');