code cleanup: Remove obsolete stream_sort code.

I remove an obsolete comment--we use get_streams()
for the `n` key now.

I also remove a guard statement from sort_groups()
that returned `undefined` for empty lists.

That guard statement would break this code:

    const stream_groups = stream_sort.sort_groups(streams, get_search_term());

    if (stream_groups.same_as_before && ...

The calling code prevents the situation anyway:

    const streams = stream_data.subscribed_stream_ids();
    if (streams.length === 0) {
        return;
    }

I modify the "no_subscribed_streams" test to test
the new behavior.  (Even though stream_list currently
short-circuits the call here, that may change in the future.)

I also introduce the test() wrapper to explicitly clear
our data.
This commit is contained in:
Steve Howell
2021-03-13 13:51:32 +00:00
committed by Steve Howell
parent 9c4d7b3bd4
commit bc8647539c
2 changed files with 25 additions and 18 deletions

View File

@@ -7,8 +7,6 @@ let previous_dormant;
let all_streams = [];
export function get_streams() {
// Right now this is only used for testing, but we should
// use it for things like hotkeys that cycle through streams.
const sorted_streams = all_streams.map((stream_id) =>
stream_data.maybe_get_stream_name(stream_id),
);
@@ -46,10 +44,6 @@ function filter_streams_by_search(streams, search_term) {
}
export function sort_groups(streams, search_term) {
if (streams.length === 0) {
return undefined;
}
streams = filter_streams_by_search(streams, search_term);
function is_normal(sub) {