Skip to content

Fix occasionally sending duplicate messages#871

Open
RxmTaco wants to merge 1 commit intocommetchat:mainfrom
RxmTaco:fix/868
Open

Fix occasionally sending duplicate messages#871
RxmTaco wants to merge 1 commit intocommetchat:mainfrom
RxmTaco:fix/868

Conversation

@RxmTaco
Copy link
Copy Markdown

@RxmTaco RxmTaco commented Mar 27, 2026

This patch fixes #868 by replacing enter key handling in message_input.dart to only happen during KeyDownEvent instead of the global isLogicalKeyPressed state.
In chat.dart the state for the processing flag in sendMessage was already being set, but was not used to guard the operation by checking it's state before processing a new message. This has been changed to return early if a previous message is still being processed while a new sendMessage gets requested.

I was not able to reproduce the error myself and thus wasn't able to verify that the patch works as intended.
However @Katacc originally let me know of the problem and also was able to test and verify that the patch works.

@Katacc
Copy link
Copy Markdown

Katacc commented Mar 27, 2026

I can confirm testing this with @RxmTaco patch.

Previously messages would be sent twice seemingly randomly, but it had to do with sending too quickly after typing. With the patch this couldn't be reproduced anymore.

+1 from me

@Airyzz
Copy link
Copy Markdown
Contributor

Airyzz commented Mar 27, 2026

i believe this was already fixed in #838, which would explain why you couldn't reproduce it. this change might not be necessary

@Katacc
Copy link
Copy Markdown

Katacc commented Mar 27, 2026

i believe this was already fixed in #838, which would explain why you couldn't reproduce it. this change might not be necessary

This is probably not yet in the latest flatpak?

@Airyzz
Copy link
Copy Markdown
Contributor

Airyzz commented Mar 27, 2026

This is probably not yet in the latest flatpak?

that's correct

@RxmTaco
Copy link
Copy Markdown
Author

RxmTaco commented Mar 28, 2026

i believe this was already fixed in #838, which would explain why you couldn't reproduce it. this change might not be necessary

Oops, didn't see that one! Still I would think using the KeyDownEvent would be wiser than relying on a debounce time, since the event only triggers once during a key press mitigating the need for debounce. Guarding the sendMessage with an early exit using the processing flag shouldn't do any harm either, but your choice if you want to add these.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Typing too fast and then pressing enter without pausing sends the message twice.

3 participants