ui: preserve input text until message send succeeds#562
Open
desgua wants to merge 2 commits into
Open
Conversation
Prevents input buffer from clearing immediately upon hitting enter, avoiding message loss during silent network drops. The entry field is now cleared only when SendMessageNotify confirms a successful transmission.
Owner
|
Is there any mechanism preventing the user from sending the same message twice? |
Contributor
Author
|
I think that's a valid point. I will see if I find a way to avoid sending the same message twice and I will update asap. |
Contributor
Author
|
I think a good approach would be to check if the user is trying to send the exact same message in less than a few seconds and in that case skip it. What do you think? |
…ce after changing nchat behavior to keep the input text until message send succeeds
Contributor
Author
|
I added a 5 seconds "cooldown" for messages that are exact the same. |
Contributor
Author
|
Another possible solution would be to show the sent message on history and mark with a signal showing it failed to deliver. That is what web.whatsapp.com does. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prevents input buffer from clearing immediately upon hitting send shortcut, avoiding message loss during silent network drops. The entry field is now cleared only when SendMessageNotify confirms a successful transmission.
Problem
Currently, when a user sends a message, UiModel::Impl::SendMessage() immediately clears the input field buffer (entryStr) before the background network thread ever transmits the payload or receives a confirmation from the backend protocol.
If the user suffers a temporary or silent network disconnection, the message is dropped entirely by the backend, but the text has already vanished from the interface. The user has no way of knowing the message failed to send unless they monitor log traces, and their typed text is permanently lost.
Proposed Solution
This PR shifts the responsibility of clearing the input entry state from the optimistic SendMessage() invocation to the asynchronous protocol response handler.
src/uimodel.cpp (SendMessage): Removed the immediate execution of entryStr.clear(), entryPos = 0, and UpdateEntry().
src/uimodel.cpp (MessageHandler): Inside the SendMessageNotifyType switch case, we now explicitly check the sendMessageNotify->success state.
On Success: The message buffer and cursor position for that specific profileId and chatId are cleared and the UI is updated.
On Failure: The state is left intact. The text remains visible in the input field, allowing the user to easily attempt a re-send once their network stability returns.