mirror of https://github.com/zulip/zulip.git
compose: Only save as draft when the compose state is about to change.
Up until now, we unconditionally saved any message content as a draft whenever the composebox was `start`ed. This led to a lot of unnecessary saving of drafts even when the composebox stayed undisturbed. To fix this, now we only save the draft when the compose state is about to be overidden, which is by either changing the recipient narrow or by restoring another draft. Fixes: #26976.
This commit is contained in:
parent
895439ad83
commit
4e9c1293e2
|
@ -179,10 +179,6 @@ export function start(msg_type, opts) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We may be able to clear it to change the recipient, so save any
|
|
||||||
// existing content as a draft.
|
|
||||||
drafts.update_draft();
|
|
||||||
|
|
||||||
autosize_message_content();
|
autosize_message_content();
|
||||||
|
|
||||||
if (reload_state.is_in_progress()) {
|
if (reload_state.is_in_progress()) {
|
||||||
|
@ -214,9 +210,13 @@ export function start(msg_type, opts) {
|
||||||
opts.stream_id = subbed_streams[0].stream_id;
|
opts.stream_id = subbed_streams[0].stream_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compose_state.composing() && !same_recipient_as_before(msg_type, opts) && !opts.draft_id) {
|
// If we go to a different narrow or there is new message content to populate the compose box
|
||||||
// Clear the compose box if the existing message is to a different recipient or the new
|
// with (like from a draft), save any existing content as a draft, and clear the compose box.
|
||||||
// content is a draft.
|
if (
|
||||||
|
compose_state.composing() &&
|
||||||
|
(!same_recipient_as_before(msg_type, opts) || opts.content !== undefined)
|
||||||
|
) {
|
||||||
|
drafts.update_draft();
|
||||||
clear_box();
|
clear_box();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue