mirror of https://github.com/zulip/zulip.git
refactor: Have try_deliver_locally() return a message.
This will allow us access to the float version of the message's id in an upcoming commit, without us having to do possibly brittle string-to-float translations.
This commit is contained in:
parent
dccbb25a49
commit
f4f403decb
|
@ -305,12 +305,13 @@ exports.send_message = function send_message(request) {
|
|||
let local_id;
|
||||
let locally_echoed;
|
||||
|
||||
local_id = echo.try_deliver_locally(request);
|
||||
if (local_id) {
|
||||
const message = echo.try_deliver_locally(request);
|
||||
if (message) {
|
||||
// We are rendering this message locally with an id
|
||||
// like 92l99.01 that corresponds to a reasonable
|
||||
// approximation of the id we'll get from the server
|
||||
// in terms of sorting messages.
|
||||
local_id = message.local_id;
|
||||
locally_echoed = true;
|
||||
} else {
|
||||
// We are not rendering this message locally, but we
|
||||
|
|
|
@ -133,7 +133,7 @@ exports.insert_local_message = function (message_request, local_id_float) {
|
|||
|
||||
message.display_recipient = echo.build_display_recipient(message);
|
||||
local_message.insert_message(message);
|
||||
return message.local_id;
|
||||
return message;
|
||||
};
|
||||
|
||||
exports.is_slash_command = function (content) {
|
||||
|
@ -174,7 +174,8 @@ exports.try_deliver_locally = function (message_request) {
|
|||
return;
|
||||
}
|
||||
|
||||
return exports.insert_local_message(message_request, local_id_float);
|
||||
const message = exports.insert_local_message(message_request, local_id_float);
|
||||
return message;
|
||||
};
|
||||
|
||||
exports.edit_locally = function (message, request) {
|
||||
|
|
Loading…
Reference in New Issue