mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 07:23:22 +00:00
Only re-render the streams list when the sort order has changed
(imported from commit 8122785097e2470e9e85f1f4c40bf1cd63264fa4)
This commit is contained in:
@@ -2,6 +2,7 @@ var stream_list = (function () {
|
||||
|
||||
var exports = {};
|
||||
|
||||
var previous_sort_order;
|
||||
exports.sort_narrow_list = function () {
|
||||
var streams = subs.subscribed_streams();
|
||||
if (streams.length === 0) {
|
||||
@@ -23,6 +24,13 @@ exports.sort_narrow_list = function () {
|
||||
return util.strcmp(a, b);
|
||||
});
|
||||
|
||||
if (previous_sort_order !== undefined
|
||||
&& util.array_compare(previous_sort_order, streams)) {
|
||||
return;
|
||||
}
|
||||
|
||||
previous_sort_order = streams;
|
||||
|
||||
var parent = $('#stream_filters');
|
||||
parent.empty();
|
||||
|
||||
|
||||
@@ -227,5 +227,18 @@ exports.strcmp = (function () {
|
||||
};
|
||||
}());
|
||||
|
||||
exports.array_compare = function util_array_compare(a, b) {
|
||||
if (a.length !== b.length) {
|
||||
return false;
|
||||
}
|
||||
var i;
|
||||
for (i = 0; i < a.length; ++i) {
|
||||
if (a[i] !== b[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
return exports;
|
||||
}());
|
||||
|
||||
Reference in New Issue
Block a user