Rename all function on MessageList to all_messages.

This commit is contained in:
Vishnu Ks
2016-04-23 04:26:44 +05:30
committed by Tim Abbott
parent cbba7202e6
commit ae49ad383d
7 changed files with 19 additions and 22 deletions

View File

@@ -61,7 +61,7 @@ var MessageList = require('js/message_list').MessageList;
assert.equal(list.closest_id(60), 60);
assert.equal(list.closest_id(61), 60);
assert.deepEqual(list.all(), messages);
assert.deepEqual(list.all_messages(), messages);
global.$.Event = function (ev) {
assert.equal(ev, 'message_selected.zulip');
@@ -96,13 +96,13 @@ var MessageList = require('js/message_list').MessageList;
list.view.clear_table = function () {};
list.remove_and_rerender([{id: 60}]);
var removed = list.all().filter(function (msg) {
var removed = list.all_messages().filter(function (msg) {
return msg.id !== 60;
});
assert.deepEqual(list.all(), removed);
assert.deepEqual(list.all_messages(), removed);
list.clear();
assert.deepEqual(list.all(), []);
assert.deepEqual(list.all_messages(), []);
}());

View File

@@ -46,7 +46,7 @@ var zero_counts = {
narrow.active = function () {
return true;
};
current_msg_list.all = function () {
current_msg_list.all_messages = function () {
return [];
};
@@ -58,7 +58,7 @@ var zero_counts = {
narrow.active = function () {
return false;
};
current_msg_list.all = function () {
current_msg_list.all_messages = function () {
return [];
};
@@ -363,7 +363,7 @@ var zero_counts = {
var message = {
id: 15
};
current_msg_list.all = function () {
current_msg_list.all_messages = function () {
return [message];
};

View File

@@ -523,7 +523,7 @@ exports.MessageList.prototype = {
this.rerender();
},
all: function MessageList_all() {
all_messages: function MessageList_all_messages() {
return this._items;
},

View File

@@ -697,8 +697,7 @@ MessageListView.prototype = {
}
this.clear_table();
this.render(this.list.all().slice(this._render_win_start,
this._render_win_end), 'bottom');
this.render(this.list.all_messages().slice(this._render_win_start, this._render_win_end), 'bottom');
// If we could see the newly selected message, scroll the
// window such that the newly selected message is at the
@@ -829,8 +828,7 @@ MessageListView.prototype = {
this.update_render_window(this.list.selected_idx(), false);
this.render(this.list.all().slice(this._render_win_start,
this._render_win_end), 'bottom');
this.render(this.list.all_messages().slice(this._render_win_start, this._render_win_end), 'bottom');
},
clear_table: function MessageListView_clear_table() {

View File

@@ -263,8 +263,7 @@ exports.activate = function (raw_operators, opts) {
if (! narrowed_msg_list.empty()) {
if (opts.select_first_unread) {
then_select_id = narrowed_msg_list.last().id;
var first_unread = _.find(narrowed_msg_list.all(),
unread.message_unread);
var first_unread = _.find(narrowed_msg_list.all_messages(), unread.message_unread);
if (first_unread) {
then_select_id = first_unread.id;
}
@@ -295,7 +294,7 @@ exports.activate = function (raw_operators, opts) {
// the message we want anyway or if the filter can't be applied
// locally.
if (message_list.all.get(then_select_id) !== undefined && current_filter.can_apply_locally()) {
message_store.add_messages(message_list.all.all(), narrowed_msg_list, {delay_render: true});
message_store.add_messages(message_list.all.all_messages(), narrowed_msg_list, {delay_render: true});
}
var defer_selecting_closest = narrowed_msg_list.empty();
@@ -471,7 +470,7 @@ exports.deactivate = function () {
// We read some unread messages in a narrow. Instead of going back to
// where we were before the narrow, go to our first unread message (or
// the bottom of the feed, if there are no unread messages).
var first_unread = _.find(current_msg_list.all(), unread.message_unread);
var first_unread = _.find(current_msg_list.all_messages(), unread.message_unread);
if (first_unread) {
message_id_to_select = first_unread.id;
} else {

View File

@@ -106,7 +106,7 @@ function update_in_home_view(sub, value) {
home_msg_list.clear({clear_selected_id: false});
// Recreate the home_msg_list with the newly filtered message_list.all
message_store.add_messages(message_list.all.all(), home_msg_list);
message_store.add_messages(message_list.all.all_messages(), home_msg_list);
// Ensure we're still at the same scroll position
if (ui.home_tab_obscured()) {
@@ -129,7 +129,7 @@ function update_in_home_view(sub, value) {
pointer.suppress_scroll_pointer_update = true;
if (! home_msg_list.empty()) {
process_loaded_for_unread(home_msg_list.all());
process_loaded_for_unread(home_msg_list.all_messages());
}
}, 0);
@@ -343,7 +343,7 @@ exports.mark_subscribed = function (stream_name, attrs) {
// Update unread counts as the new stream in sidebar might
// need its unread counts re-calculated
process_loaded_for_unread(message_list.all.all());
process_loaded_for_unread(message_list.all.all_messages());
$(document).trigger($.Event('subscription_add_done.zulip', {sub: sub}));
};

View File

@@ -93,7 +93,7 @@ exports.declare_bankruptcy = function () {
exports.num_unread_current_messages = function () {
var num_unread = 0;
_.each(current_msg_list.all(), function (msg) {
_.each(current_msg_list.all_messages(), function (msg) {
if ((msg.id > current_msg_list.selected_id()) && exports.message_unread(msg)) {
num_unread += 1;
}
@@ -195,7 +195,7 @@ exports.enable = function enable() {
};
exports.mark_all_as_read = function mark_all_as_read(cont) {
_.each(message_list.all.all(), function (msg) {
_.each(message_list.all.all_messages(), function (msg) {
msg.flags = msg.flags || [];
msg.flags.push('read');
});
@@ -269,7 +269,7 @@ exports.process_visible = function process_visible(update_cursor) {
};
exports.mark_current_list_as_read = function mark_current_list_as_read(options) {
exports.mark_messages_as_read(current_msg_list.all(), options);
exports.mark_messages_as_read(current_msg_list.all_messages(), options);
};
return exports;