js: Convert static/js/stream_sort.js to ES6 module.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-02-10 07:50:12 -08:00 committed by Tim Abbott
parent 87f2fe2cce
commit 2771434aad
8 changed files with 14 additions and 20 deletions

View File

@ -272,7 +272,6 @@
"stream_list": false,
"stream_muting": false,
"stream_popover": false,
"stream_sort": false,
"stream_ui_updates": false,
"StripeCheckout": false,
"submessage": false,

View File

@ -608,7 +608,6 @@ run_test("unread_ops", () => {
const topic_list = set_global("topic_list", {});
zrequire("stream_sort");
const stream_list = zrequire("stream_list");
const social_stream = {

View File

@ -117,7 +117,6 @@ rewiremock.proxy(() => zrequire("notifications"), {
zrequire("pm_list");
zrequire("list_cursor");
zrequire("keydown_util");
zrequire("stream_sort");
zrequire("stream_list");
zrequire("topic_list");
zrequire("topic_zoom");

View File

@ -39,7 +39,6 @@ import "../topic_list";
import "../pm_list_dom";
import "../pm_list";
import "../recent_senders";
import "../stream_sort";
import "../topic_generator";
import "../top_left_corner";
import "../stream_list";

View File

@ -138,7 +138,6 @@ declare let stream_events: any;
declare let stream_list: any;
declare let stream_muting: any;
declare let stream_popover: any;
declare let stream_sort: any;
declare let stream_ui_updates: any;
declare let submessage: any;
declare let subs: any;

View File

@ -5,6 +5,8 @@ const _ = require("lodash");
const render_stream_privacy = require("../templates/stream_privacy.hbs");
const render_stream_sidebar_row = require("../templates/stream_sidebar_row.hbs");
const stream_sort = require("./stream_sort");
let has_scrolled = false;
exports.update_count_in_dom = function (unread_count_elem, count) {

View File

@ -1,20 +1,18 @@
"use strict";
const util = require("./util");
import * as util from "./util";
let previous_pinned;
let previous_normal;
let previous_dormant;
let all_streams = [];
exports.get_streams = function () {
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),
);
return sorted_streams;
};
}
function compare_function(a, b) {
const stream_a = stream_data.get_sub_by_id(a);
@ -46,7 +44,7 @@ function filter_streams_by_search(streams, search_term) {
return filtered_streams;
}
exports.sort_groups = function (streams, search_term) {
export function sort_groups(streams, search_term) {
if (streams.length === 0) {
return undefined;
}
@ -97,7 +95,7 @@ exports.sort_groups = function (streams, search_term) {
normal_streams,
dormant_streams,
};
};
}
function maybe_get_stream_id(i) {
if (i < 0 || i >= all_streams.length) {
@ -107,11 +105,11 @@ function maybe_get_stream_id(i) {
return all_streams[i];
}
exports.first_stream_id = function () {
export function first_stream_id() {
return maybe_get_stream_id(0);
};
}
exports.prev_stream_id = function (stream_id) {
export function prev_stream_id(stream_id) {
const i = all_streams.indexOf(stream_id);
if (i < 0) {
@ -119,9 +117,9 @@ exports.prev_stream_id = function (stream_id) {
}
return maybe_get_stream_id(i - 1);
};
}
exports.next_stream_id = function (stream_id) {
export function next_stream_id(stream_id) {
const i = all_streams.indexOf(stream_id);
if (i < 0) {
@ -129,6 +127,4 @@ exports.next_stream_id = function (stream_id) {
}
return maybe_get_stream_id(i + 1);
};
window.stream_sort = exports;
}

View File

@ -1,6 +1,7 @@
"use strict";
const pm_conversations = require("./pm_conversations");
const stream_sort = require("./stream_sort");
exports.next_topic = function (streams, get_topics, has_unread_messages, curr_stream, curr_topic) {
const curr_stream_index = streams.indexOf(curr_stream); // -1 if not found