From 89b35eb4df8b5b86528b4850530b14f313293d89 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 13 May 2021 19:48:05 +1000 Subject: [PATCH] Disable send button if no peer available Yet keep it enabled if user tries to send a command. Resolves #136 --- CHANGELOG.md | 1 + examples/web-chat/src/MessageInput.tsx | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6593a46674..21178fd88f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - `WakuRelay.getPeers` method. +- Use `WakuRelay.getPeers` in web chat app example to disable send button. ### Changed - Enable passing `string`s to `addPeerToAddressBook`. diff --git a/examples/web-chat/src/MessageInput.tsx b/examples/web-chat/src/MessageInput.tsx index d8a8bfe208..3911bb873b 100644 --- a/examples/web-chat/src/MessageInput.tsx +++ b/examples/web-chat/src/MessageInput.tsx @@ -34,11 +34,15 @@ export default function MessageInput(props: Props) { } }; + // Enable the button if there are relay peers available or the user is sending a command + const activeButton = + (waku && waku.relay.getPeers().size !== 0) || inputText.startsWith('/'); + return (