fix: minor issues in the web-chat (#218)

* improve condition for message sending, fix clear input issue

* prevent display of empty messages
This commit is contained in:
Sasha 2023-03-02 00:56:20 +01:00 committed by GitHub
parent faf8cf83c8
commit 74b6bd11b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 2 deletions

View File

@ -23,13 +23,14 @@ export default function MessageInput(props: Props) {
const [isActive, setActiveButton] = useState<boolean>(false);
const onMessage = async () => {
if (props.sendMessage) {
if (props.sendMessage && inputText) {
await props.sendMessage(inputText);
setInputText("");
}
};
const onChange = (event: ChangeEvent<HTMLInputElement>) => {
event.preventDefault();
setInputText(event.target.value);
};

View File

@ -22,7 +22,7 @@ export default function Room(props: Props) {
const { storePeers, filterPeers, lightPushPeers } = usePeers({ node });
const onSend = async (text: string) => {
if (!onPush) {
if (!onPush || !text) {
return;
}

View File

@ -46,6 +46,7 @@ export const useMessages = (params: UseMessagesParams): UseMessagesResult => {
.map(Message.fromWakuMessage)
.concat(localMessages)
.filter((v): v is Message => !!v)
.filter((v) => v.payloadAsUtf8 !== "")
.sort(
(left, right) => left.timestamp.getTime() - right.timestamp.getTime()
);