streams: Store list of stream ids instead of names for sorting.

We will store list of stream ids to sort streams instead of names.
We have added a compare_function for sorting the list of stream_ids
by comparing stream names.

This change helps us to remove a couple of get_sub calls and using
stream ids instead of name also helps in avoiding bugs caused due
to live update on renaming of stream.
This commit is contained in:
sahil839
2020-07-09 18:38:01 +05:30
committed by Tim Abbott
parent ed96758614
commit dcc24992b9
3 changed files with 36 additions and 38 deletions

View File

@@ -87,7 +87,7 @@ exports.build_stream_list = function () {
// sidebar rows. Our job here is to build the bigger widget,
// which largely is a matter of arranging the individual rows in
// the right order.
const streams = stream_data.subscribed_streams();
const streams = stream_data.subscribed_stream_ids();
if (streams.length === 0) {
return;
}
@@ -103,9 +103,8 @@ exports.build_stream_list = function () {
const parent = $("#stream_filters");
const elems = [];
function add_sidebar_li(stream) {
const sub = stream_data.get_sub(stream);
const sidebar_row = exports.stream_sidebar.get_row(sub.stream_id);
function add_sidebar_li(stream_id) {
const sidebar_row = exports.stream_sidebar.get_row(stream_id);
sidebar_row.update_whether_active();
elems.push(sidebar_row.get_li());
}