sent_messages: Move MessageState definition before use.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-02-24 14:54:31 -08:00 committed by Tim Abbott
parent cc3d33b386
commit 64b0c3bac3
1 changed files with 18 additions and 18 deletions

View File

@ -29,24 +29,6 @@ function report_send_time(send_time, receive_time, locally_echoed, rendered_chan
});
}
exports.start_tracking_message = function (opts) {
const local_id = opts.local_id;
if (!opts.local_id) {
blueslip.error("You must supply a local_id");
return;
}
if (exports.messages.has(local_id)) {
blueslip.error("We are re-using a local_id");
return;
}
const state = new exports.MessageState(opts);
exports.messages.set(local_id, state);
};
class MessageState {
start = new Date();
@ -120,6 +102,24 @@ class MessageState {
}
exports.MessageState = MessageState;
exports.start_tracking_message = function (opts) {
const local_id = opts.local_id;
if (!opts.local_id) {
blueslip.error("You must supply a local_id");
return;
}
if (exports.messages.has(local_id)) {
blueslip.error("We are re-using a local_id");
return;
}
const state = new exports.MessageState(opts);
exports.messages.set(local_id, state);
}
exports.get_message_state = function (local_id) {
const state = exports.messages.get(local_id);