mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 23:43:43 +00:00
Revert rendering window changes related to summarization
This reverts commit c10d9c1a0d23891acce88bf8d79866c08cb75681. This reverts commit 9259a246946cd968a8725c38ff5ef2d4b4793717. (imported from commit 50e9e0136c2487cc63d75ae2b78df0c70a1b0be1)
This commit is contained in:
@@ -297,41 +297,6 @@ MessageList.prototype = {
|
||||
return null;
|
||||
},
|
||||
|
||||
// Counts the number of fully-displayed (not summarized, muted, or hidden)
|
||||
// messages from array position idx1 to idx2
|
||||
count_full_messages_between: function (idx1, idx2) {
|
||||
var i;
|
||||
var count = 0;
|
||||
for (i = idx1; i < idx2; i++) {
|
||||
if (this.summary_adjective(this._items[i]) === null) {
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
},
|
||||
|
||||
// Adjusts an array index backwards by `count` fully-displayed messages
|
||||
idx_full_messages_before: function (idx, count) {
|
||||
while (idx > 0 && count > 0){
|
||||
idx -= 1;
|
||||
if (this.summary_adjective(this._items[idx]) === null) {
|
||||
count -= 1;
|
||||
}
|
||||
}
|
||||
return idx;
|
||||
},
|
||||
|
||||
// Advances an array index forward past `count` fully-displayed messages
|
||||
idx_full_messages_after: function (idx, count) {
|
||||
while (idx < this._items.length && count > 0){
|
||||
if (this.summary_adjective(this._items[idx]) === null) {
|
||||
count -= 1;
|
||||
}
|
||||
idx += 1;
|
||||
}
|
||||
return idx;
|
||||
},
|
||||
|
||||
selected_idx: function MessageList_selected_idx() {
|
||||
return util.lower_bound(this._items, this._selected_id,
|
||||
function (a, b) { return a.id < b; });
|
||||
|
||||
@@ -505,13 +505,14 @@ MessageListView.prototype = {
|
||||
},
|
||||
|
||||
update_render_window: function MessageListView__update_render_window(selected_idx, check_for_changed) {
|
||||
var new_start = this.list.idx_full_messages_before(selected_idx, this._RENDER_WINDOW_SIZE / 2);
|
||||
var new_start = Math.max(selected_idx - this._RENDER_WINDOW_SIZE / 2, 0);
|
||||
if (check_for_changed && new_start === this._render_win_start) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this._render_win_start = new_start;
|
||||
this._render_win_end = this.list.idx_full_messages_after(selected_idx, this._RENDER_WINDOW_SIZE / 2);
|
||||
this._render_win_end = Math.min(this._render_win_start + this._RENDER_WINDOW_SIZE,
|
||||
this.list.num_items());
|
||||
return true;
|
||||
},
|
||||
|
||||
@@ -524,15 +525,17 @@ MessageListView.prototype = {
|
||||
var selected_idx = this.list.selected_idx();
|
||||
|
||||
// We rerender under the following conditions:
|
||||
// * The selected message is within this._RENDER_THRESHOLD visible
|
||||
// messages of the top of the currently rendered window and the top
|
||||
// of the window does not abut the beginning of the message list
|
||||
// * The selected message is within this._RENDER_THRESHOLD visible
|
||||
// messages of the bottom of the currently rendered window and the
|
||||
// bottom of the window does not abut the end of the message list
|
||||
if (! (((this.list.count_full_messages_between(this._render_win_start, selected_idx) < this._RENDER_THRESHOLD)
|
||||
// * The selected message is within this._RENDER_THRESHOLD messages
|
||||
// of the top of the currently rendered window and the top
|
||||
// of the window does not abut the beginning of the message
|
||||
// list
|
||||
// * The selected message is within this._RENDER_THRESHOLD messages
|
||||
// of the bottom of the currently rendered window and the
|
||||
// bottom of the window does not abut the end of the
|
||||
// message list
|
||||
if (! (((selected_idx - this._render_win_start < this._RENDER_THRESHOLD)
|
||||
&& (this._render_win_start !== 0)) ||
|
||||
((this.list.count_full_messages_between(selected_idx, this._render_win_end) <= this._RENDER_THRESHOLD)
|
||||
((this._render_win_end - selected_idx <= this._RENDER_THRESHOLD)
|
||||
&& (this._render_win_end !== this.list.num_items()))))
|
||||
{
|
||||
return false;
|
||||
@@ -571,7 +574,7 @@ MessageListView.prototype = {
|
||||
},
|
||||
|
||||
append: function MessageListView__append(messages, messages_are_new) {
|
||||
var cur_window_size = this.list.count_full_messages_between(this._render_win_start, this._render_win_end);
|
||||
var cur_window_size = this._render_win_end - this._render_win_start;
|
||||
if (cur_window_size < this._RENDER_WINDOW_SIZE) {
|
||||
var slice_to_render = messages.slice(0, this._RENDER_WINDOW_SIZE - cur_window_size);
|
||||
this.render(slice_to_render, 'bottom', messages_are_new);
|
||||
|
||||
@@ -114,28 +114,3 @@ var MessageList = require('js/message_list');
|
||||
assert.equal(list.nth_most_recent_id(3), 10);
|
||||
assert.equal(list.nth_most_recent_id(4), -1);
|
||||
}());
|
||||
|
||||
(function test_message_counting() {
|
||||
global.feature_flags.summarize_read_while_narrowed = true;
|
||||
var list = new MessageList(undefined, {}, {summarize_read: 'home'});
|
||||
|
||||
var summarized_flags = ['summarize_in_home'];
|
||||
var unsummarized_flags = [];
|
||||
|
||||
list.append([
|
||||
{id: 10, flags: unsummarized_flags},
|
||||
{id: 20, flags: unsummarized_flags},
|
||||
{id: 30, flags: summarized_flags},
|
||||
{id: 40, flags: summarized_flags},
|
||||
{id: 50, flags: unsummarized_flags},
|
||||
{id: 60, flags: summarized_flags}
|
||||
]);
|
||||
list.min_id_exempted_from_summaries = 10000;
|
||||
|
||||
assert.equal(list.count_full_messages_between(1, 5), 2);
|
||||
assert.equal(list.idx_full_messages_before(5, 2), 1);
|
||||
assert.equal(list.idx_full_messages_before(5, 10), 0);
|
||||
assert.equal(list.idx_full_messages_after(0, 3), 5);
|
||||
assert.equal(list.idx_full_messages_after(0, 10), 6);
|
||||
|
||||
}());
|
||||
|
||||
Reference in New Issue
Block a user