Disable send button if no peer available

Yet keep it enabled if user tries to send a command.

Resolves #136
This commit is contained in:
Franck Royer 2021-05-13 19:48:05 +10:00
parent a8d4d494f8
commit 89b35eb4df
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
2 changed files with 6 additions and 1 deletions

View File

@ -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`.

View File

@ -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 (
<TextComposer
onKeyDown={keyPressHandler}
onChange={messageHandler}
active={!!waku}
active={activeButton}
onButtonClick={sendMessage}
>
<Row align="center">