Use message_store rather than all_msg_list to get messages by id.

There are 2 uses of all_msg_list previous to this commit:

(1) The contiguous block of messages to be used for constructing the
initial state of narrows.

(2) A way to look up an arbitrary message by ID that may or may not be
in the home view to check if we have it locally.

We eliminate all applications of use case (2), replacing them with
queries on message_store, since they are in fact wrong -- any messages
that are outside the contiguous time period of all_msg_list would not
appear in all_msg_list and thus would incorrectly not be returned.

(imported from commit e2e2efe919242331bbc44abc6c50b16e3ab1336e)
This commit is contained in:
Tim Abbott 2014-01-31 16:14:57 -05:00
parent 30056197a6
commit 8c733fde8f
3 changed files with 5 additions and 5 deletions

View File

@ -52,7 +52,7 @@ function resend_message(message, row) {
compose.send_message_success(message.local_id, message_id, start_time, true);
// Resend succeeded, so mark as no longer failed
all_msg_list.get(message_id).failed_request = false;
message_store.get(message_id).failed_request = false;
ui.show_failed_message_success(message_id);
}, function error(response) {
exports.message_send_error(message.local_id, response);
@ -271,7 +271,7 @@ exports.process_from_server = function process_from_server(messages) {
exports.message_send_error = function message_send_error(local_id, error_response) {
// Error sending message, show inline
all_msg_list.get(local_id).failed_request = true;
message_store.get(local_id).failed_request = true;
ui.show_message_failed(local_id, error_response);
};

View File

@ -215,7 +215,7 @@ function maybe_add_narrowed_messages(messages, msg_list, messages_are_new) {
exports.update_messages = function update_messages(events) {
_.each(events, function (event) {
var msg = all_msg_list.get(event.message_id);
var msg = exports.get(event.message_id);
if (msg === undefined) {
return;
}
@ -235,7 +235,7 @@ exports.update_messages = function update_messages(events) {
// event.message_ids. event.message_id is still the first message
// where the user initiated the edit.
_.each(event.message_ids, function (id) {
var msg = all_msg_list.get(id);
var msg = message_store.get(id);
if (msg === undefined) {
return;
}

View File

@ -889,7 +889,7 @@ exports.expand_summary_row = function (row) {
exports.collapse_recipient_group = function (row) {
var message_ids = row.attr('data-messages').split(',');
var messages = _.map(message_ids, function (id) {
return all_msg_list.get(id);
return message_store.get(id);
});
_.each(messages, function (msg){