Comment drafts - #2457
Merged
Merged
Conversation
Submitting the new thread form left the editor with no selection at all, dropping the reviewer back to the outline. Wait for the thread to be created instead and select the comments of its subject, highlighting what was just written. The thread id is only known once the create request has come back, so ReviewSession emits a create:thread event the preview message controller reacts to.
Dismissing a popover, changing the selection in the editor or leaving the new thread view discarded whatever had been typed. Store the text as a draft on the review session instead, keyed by subject alone: a draft written about one phrase of a text block is offered again when commenting on another phrase of the same block. The session also represents the create request in flight as a pending draft, which is what disables the form and shows a spinner. Submitting therefore no longer closes the thread list form right away: it stays open until the thread has been created, or becomes editable again with the text still in it when the request failed. Drafts reach the editor sidebar and the frontend popover through the same message relay as the rest of the review state, except that the sidebar writes them directly: its message handler is disposed together with the view, which would drop the draft stored on the way out.
The chain of conditions had grown to five branches, one of them only there to keep drafts from reopening a form the caller suppressed. Everything that used to be the default at the end of the chain is the initial value of the toggle state now, which also means resolving the last thread of a subject no longer invites a new one.
Prepares drafting replies: keys the drafts of a session by thread when one is given, and moves the hook holding a form's drafted text into a module of its own so both comment forms can use it.
Replies now work like new threads: the text is stored as a draft when the form goes away and restored when it comes back, and creating one marks that draft pending, which disables the form and shows a spinner. Two differences to the new thread form. A thread whose reply has been drafted stays expanded, since collapsing hides the form the draft belongs to. And the form outlives its submit, so it empties itself once the session has dropped the draft the reply was created from.
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.
REDMINE-21261