Repository navigation
fix(chunter): clear the other open chat input when a shared draft is sent - #11121
Open
MichaelUray wants to merge 1 commit into
Open
MichaelUray wants to merge 1 commit into
MichaelUray wants to merge 1 commit into
Conversation
…sent A channel open in the main view and in the sidebar shows the same message draft, including the pre-generated message _id. Both inputs took the draft object straight from draftsStore, so they shared one mutable object, and onUpdate() writes into it in place. After a send, the sending editor is cleared before the message is created, and that empty update was written into the shared object. When the other input then saw the created message, its content no longer matched the sent message, so it kept the sent text and only got a new _id. In addition its clear() reset the draft state but not the bound editor content, and the created-message query only ran in inputs that were opened with an existing draft, so sending from the sidebar never reached the main view. Each input now works on its own copy of the stored draft, clear() also resets the editor content, and the created-message query also runs while the input holds unsent content. Whichever input sends the message, the other one is emptied if it still shows the sent content; text typed there afterwards is kept as a new draft. Fixes hcengineering#7363 Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>
This branch has not been deployed
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.
Fixes #7363
Problem and change
A channel open in the main view and in the sidebar shows the same message draft, including the pre-generated message _id. Both inputs took the draft object straight from draftsStore, so they shared one mutable object, and onUpdate() writes into it in place. After a send, the sending editor is cleared before the message is created, and that empty update was written into the shared object. When the other input then saw the created message, its content no longer matched the sent message, so it kept the sent text and only got a new _id. In addition its clear() reset the draft state but not the bound editor content, and the created-message query only ran in inputs that were opened with an existing draft, so sending from the sidebar never reached the main view.
Each input now works on its own copy of the stored draft, clear() also resets the editor content, and the created-message query also runs while the input holds unsent content. Whichever input sends the message, the other one is emptied if it still shows the sent content; text typed there afterwards is kept as a new draft.
Tests
No unit test (Svelte wiring). Checked manually on a self-hosted instance in a real browser, each case twice: with the same channel open in the main view and in the sidebar, sending the draft from either side empties the other input immediately and typing there starts fresh; text added only in the other input after the send is kept and can be sent as a separate message.