mirror of https://github.com/waku-org/js-waku.git
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:
parent
a8d4d494f8
commit
89b35eb4df
|
@ -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`.
|
||||
|
|
|
@ -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">
|
||||
|
|
Loading…
Reference in New Issue