echo: Pass transmit.send_message as a callback.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2023-10-06 10:30:38 -07:00 committed by Tim Abbott
parent b9dd4a14c9
commit 339b1351f8
2 changed files with 9 additions and 6 deletions

View File

@ -21,7 +21,6 @@ import * as sent_messages from "./sent_messages";
import * as stream_data from "./stream_data"; import * as stream_data from "./stream_data";
import * as stream_list from "./stream_list"; import * as stream_list from "./stream_list";
import * as stream_topic_history from "./stream_topic_history"; import * as stream_topic_history from "./stream_topic_history";
import * as transmit from "./transmit";
import * as util from "./util"; import * as util from "./util";
// Docs: https://zulip.readthedocs.io/en/latest/subsystems/sending-messages.html // Docs: https://zulip.readthedocs.io/en/latest/subsystems/sending-messages.html
@ -73,7 +72,7 @@ function failed_message_success(message_id) {
show_failed_message_success(message_id); show_failed_message_success(message_id);
} }
function resend_message(message, $row, on_send_message_success) { function resend_message(message, $row, {on_send_message_success, send_message}) {
message.content = message.raw_content; message.content = message.raw_content;
if (show_retry_spinner($row)) { if (show_retry_spinner($row)) {
// retry already in in progress // retry already in in progress
@ -107,7 +106,7 @@ function resend_message(message, $row, on_send_message_success) {
blueslip.log("Manual resend of message failed"); blueslip.log("Manual resend of message failed");
} }
transmit.send_message(message, on_success, on_error); send_message(message, on_success, on_error);
} }
export function build_display_recipient(message) { export function build_display_recipient(message) {
@ -474,7 +473,7 @@ export function display_slow_send_loading_spinner(message) {
} }
} }
export function initialize({on_send_message_success}) { export function initialize({on_send_message_success, send_message}) {
function on_failed_action(selector, callback) { function on_failed_action(selector, callback) {
$("#main_div").on("click", selector, function (e) { $("#main_div").on("click", selector, function (e) {
e.stopPropagation(); e.stopPropagation();
@ -490,7 +489,7 @@ export function initialize({on_send_message_success}) {
); );
return; return;
} }
callback(message, $row, on_send_message_success); callback(message, $row, {on_send_message_success, send_message});
}); });
} }

View File

@ -123,6 +123,7 @@ import * as tippyjs from "./tippyjs";
import * as topic_list from "./topic_list"; import * as topic_list from "./topic_list";
import * as topic_popover from "./topic_popover"; import * as topic_popover from "./topic_popover";
import * as topic_zoom from "./topic_zoom"; import * as topic_zoom from "./topic_zoom";
import * as transmit from "./transmit";
import * as tutorial from "./tutorial"; import * as tutorial from "./tutorial";
import * as typeahead_helper from "./typeahead_helper"; import * as typeahead_helper from "./typeahead_helper";
import * as typing from "./typing"; import * as typing from "./typing";
@ -597,7 +598,10 @@ export function initialize_everything() {
navbar_alerts.initialize(); navbar_alerts.initialize();
message_list_hover.initialize(); message_list_hover.initialize();
initialize_kitchen_sink_stuff(); initialize_kitchen_sink_stuff();
echo.initialize({on_send_message_success: compose.send_message_success}); echo.initialize({
on_send_message_success: compose.send_message_success,
send_message: transmit.send_message,
});
stream_edit.initialize(); stream_edit.initialize();
user_group_edit.initialize(); user_group_edit.initialize();
stream_edit_subscribers.initialize(); stream_edit_subscribers.initialize();