left-sidebar: Sort pinned streams by lowercase stream name.

The pinned streams were sorted in alphabetic order (i.e. Verona appears
before devel). The reason is that after we plucked pinned streams out from
stream_data.subscribed_streams(), we didn't sort them again, so they
remained in the alphabetic order used in stream_data.

However, we did sort unpinned streams explicitly by using custom compare
function in stream_list.js (by default sort by lowercase stream name,
but when there are more than 40 subscribed streams, sort active streams
first). That's why this issue only relates to pinned streams.

Changes were made to sort pinned streams by lowercase stream name, always,
whether they are active or not (different from unpinned streams).

Tests were added to ensure this overall sort order is correct, i.e.

1. pinned streams are always sorted by lowercase stream name.
2. pinned streams are always before unpinned streams.
3. unpinned streams are sorted by lowercase stream name, if there are more
   than 40 subscribed streams, sort active streams at the top, among active
   and inactive streams, still sorted by lowercase stream name.

Fixes #3701
This commit is contained in:
chao1995
2017-02-19 22:24:27 +08:00
committed by Tim Abbott
parent bd1d545a5a
commit b3119b0d67
2 changed files with 113 additions and 7 deletions

View File

@@ -137,6 +137,8 @@ exports.build_stream_list = function () {
}
});
pinned_streams.sort(util.strcmp);
unpinned_streams.sort(function (a, b) {
if (sort_recent) {
if (stream_data.is_active(b) && ! stream_data.is_active(a)) {