drafts: Don't update draft count when successfully sending messages.

Fixes #21757.

Previously the draft count would briefly increase between the action
of sending a message and the success of sending that message.
Now the draft count will only increase if the message fails to send.
This commit is contained in:
evykassirer
2022-10-07 09:58:30 -07:00
committed by Tim Abbott
parent cefed552f6
commit 61a782d252
4 changed files with 27 additions and 11 deletions

View File

@@ -11,6 +11,7 @@ import * as compose_fade from "./compose_fade";
import * as compose_state from "./compose_state";
import * as compose_ui from "./compose_ui";
import * as compose_validate from "./compose_validate";
import * as drafts from "./drafts";
import * as echo from "./echo";
import * as flatpickr from "./flatpickr";
import {$t, $t_html} from "./i18n";
@@ -256,6 +257,10 @@ export function send_message(request = create_message_object()) {
}
echo.message_send_error(message.id, response);
// We might not have updated the draft count because we assumed the
// message would send. Ensure that the displayed count is correct.
drafts.sync_count();
}
transmit.send_message(request, success, error);