mirror of https://github.com/zulip/zulip.git
js: Convert static/js/stream_list.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
727208b84c
commit
3e8ddc229b
|
@ -147,7 +147,6 @@
|
||||||
"pointer": false,
|
"pointer": false,
|
||||||
"realm_night_logo": false,
|
"realm_night_logo": false,
|
||||||
"settings_profile_fields": false,
|
"settings_profile_fields": false,
|
||||||
"stream_list": false,
|
|
||||||
"StripeCheckout": false,
|
"StripeCheckout": false,
|
||||||
"subs": false,
|
"subs": false,
|
||||||
"ui": false,
|
"ui": false,
|
||||||
|
|
|
@ -35,7 +35,9 @@ const settings_org = {__esModule: true};
|
||||||
rewiremock("../../static/js/settings_org").with(settings_org);
|
rewiremock("../../static/js/settings_org").with(settings_org);
|
||||||
const settings_streams = {__esModule: true};
|
const settings_streams = {__esModule: true};
|
||||||
rewiremock("../../static/js/settings_streams").with(settings_streams);
|
rewiremock("../../static/js/settings_streams").with(settings_streams);
|
||||||
const stream_list = set_global("stream_list", {});
|
const stream_list = {__esModule: true};
|
||||||
|
|
||||||
|
rewiremock("../../static/js/stream_list").with(stream_list);
|
||||||
|
|
||||||
const server_events_dispatch = zrequire("server_events_dispatch");
|
const server_events_dispatch = zrequire("server_events_dispatch");
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,8 @@ const reactions = {__esModule: true};
|
||||||
rewiremock("../../static/js/reactions").with(reactions);
|
rewiremock("../../static/js/reactions").with(reactions);
|
||||||
const search = {__esModule: true};
|
const search = {__esModule: true};
|
||||||
rewiremock("../../static/js/search").with(search);
|
rewiremock("../../static/js/search").with(search);
|
||||||
const stream_list = set_global("stream_list", {});
|
const stream_list = {__esModule: true};
|
||||||
|
rewiremock("../../static/js/stream_list").with(stream_list);
|
||||||
const subs = set_global("subs", {});
|
const subs = set_global("subs", {});
|
||||||
|
|
||||||
set_global("current_msg_list", {
|
set_global("current_msg_list", {
|
||||||
|
|
|
@ -18,7 +18,8 @@ rewiremock("../../static/js/notifications").with(notifications);
|
||||||
const page_params = set_global("page_params", {});
|
const page_params = set_global("page_params", {});
|
||||||
const pm_list = {__esModule: true};
|
const pm_list = {__esModule: true};
|
||||||
rewiremock("../../static/js/pm_list").with(pm_list);
|
rewiremock("../../static/js/pm_list").with(pm_list);
|
||||||
const stream_list = set_global("stream_list", {});
|
const stream_list = {__esModule: true};
|
||||||
|
rewiremock("../../static/js/stream_list").with(stream_list);
|
||||||
const unread_ui = {__esModule: true};
|
const unread_ui = {__esModule: true};
|
||||||
|
|
||||||
rewiremock("../../static/js/unread_ui").with(unread_ui);
|
rewiremock("../../static/js/unread_ui").with(unread_ui);
|
||||||
|
|
|
@ -47,9 +47,12 @@ const pm_list = {__esModule: true};
|
||||||
rewiremock("../../static/js/pm_list").with(pm_list);
|
rewiremock("../../static/js/pm_list").with(pm_list);
|
||||||
const server_events = {__esModule: true};
|
const server_events = {__esModule: true};
|
||||||
rewiremock("../../static/js/server_events").with(server_events);
|
rewiremock("../../static/js/server_events").with(server_events);
|
||||||
const stream_list = set_global("stream_list", {
|
const stream_list = {
|
||||||
|
__esModule: true,
|
||||||
maybe_scroll_narrow_into_view: () => {},
|
maybe_scroll_narrow_into_view: () => {},
|
||||||
});
|
};
|
||||||
|
|
||||||
|
rewiremock("../../static/js/stream_list").with(stream_list);
|
||||||
|
|
||||||
rewiremock.enable();
|
rewiremock.enable();
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,8 @@ rewiremock("../../static/js/notifications").with(notifications);
|
||||||
set_global("page_params", {});
|
set_global("page_params", {});
|
||||||
const search = {__esModule: true};
|
const search = {__esModule: true};
|
||||||
rewiremock("../../static/js/search").with(search);
|
rewiremock("../../static/js/search").with(search);
|
||||||
const stream_list = set_global("stream_list", {});
|
const stream_list = {__esModule: true};
|
||||||
|
rewiremock("../../static/js/stream_list").with(stream_list);
|
||||||
const message_view_header = {__esModule: true};
|
const message_view_header = {__esModule: true};
|
||||||
rewiremock("../../static/js/message_view_header").with(message_view_header);
|
rewiremock("../../static/js/message_view_header").with(message_view_header);
|
||||||
const top_left_corner = {__esModule: true};
|
const top_left_corner = {__esModule: true};
|
||||||
|
|
|
@ -13,7 +13,7 @@ const noop = () => {};
|
||||||
rewiremock("../../static/js/top_left_corner").with({
|
rewiremock("../../static/js/top_left_corner").with({
|
||||||
narrow_to_recent_topics: noop,
|
narrow_to_recent_topics: noop,
|
||||||
});
|
});
|
||||||
set_global("stream_list", {
|
rewiremock("../../static/js/stream_list").with({
|
||||||
handle_narrow_deactivated: noop,
|
handle_narrow_deactivated: noop,
|
||||||
});
|
});
|
||||||
set_global("compose_actions", {
|
set_global("compose_actions", {
|
||||||
|
|
|
@ -23,7 +23,8 @@ const message_util = {__esModule: true};
|
||||||
rewiremock("../../static/js/message_util").with(message_util);
|
rewiremock("../../static/js/message_util").with(message_util);
|
||||||
const stream_color = {__esModule: true};
|
const stream_color = {__esModule: true};
|
||||||
rewiremock("../../static/js/stream_color").with(stream_color);
|
rewiremock("../../static/js/stream_color").with(stream_color);
|
||||||
const stream_list = set_global("stream_list", {});
|
const stream_list = {__esModule: true};
|
||||||
|
rewiremock("../../static/js/stream_list").with(stream_list);
|
||||||
const stream_muting = {__esModule: true};
|
const stream_muting = {__esModule: true};
|
||||||
rewiremock("../../static/js/stream_muting").with(stream_muting);
|
rewiremock("../../static/js/stream_muting").with(stream_muting);
|
||||||
rewiremock("../../static/js/recent_topics").with({
|
rewiremock("../../static/js/recent_topics").with({
|
||||||
|
|
|
@ -675,10 +675,10 @@ test_ui("rename_stream", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
let count_updated;
|
let count_updated;
|
||||||
stream_list.update_count_in_dom = (li) => {
|
stream_list.__Rewire__("update_count_in_dom", (li) => {
|
||||||
assert.equal(li, li_stub);
|
assert.equal(li, li_stub);
|
||||||
count_updated = true;
|
count_updated = true;
|
||||||
};
|
});
|
||||||
|
|
||||||
stream_list.rename_stream(sub);
|
stream_list.rename_stream(sub);
|
||||||
assert(count_updated);
|
assert(count_updated);
|
||||||
|
@ -706,14 +706,14 @@ test_ui("refresh_pin", () => {
|
||||||
|
|
||||||
stub_templates(() => ({to_$: () => li_stub}));
|
stub_templates(() => ({to_$: () => li_stub}));
|
||||||
|
|
||||||
stream_list.update_count_in_dom = noop;
|
stream_list.__Rewire__("update_count_in_dom", noop);
|
||||||
$("#stream_filters").append = noop;
|
$("#stream_filters").append = noop;
|
||||||
|
|
||||||
let scrolled;
|
let scrolled;
|
||||||
stream_list.scroll_stream_into_view = (li) => {
|
stream_list.__Rewire__("scroll_stream_into_view", (li) => {
|
||||||
assert.equal(li, li_stub);
|
assert.equal(li, li_stub);
|
||||||
scrolled = true;
|
scrolled = true;
|
||||||
};
|
});
|
||||||
|
|
||||||
stream_list.refresh_pinned_or_unpinned_stream(pinned_sub);
|
stream_list.refresh_pinned_or_unpinned_stream(pinned_sub);
|
||||||
assert(scrolled);
|
assert(scrolled);
|
||||||
|
@ -724,14 +724,14 @@ test_ui("create_initial_sidebar_rows", () => {
|
||||||
|
|
||||||
const html_dict = new Map();
|
const html_dict = new Map();
|
||||||
|
|
||||||
stream_list.stream_sidebar = {
|
stream_list.__Rewire__("stream_sidebar", {
|
||||||
has_row_for: () => false,
|
has_row_for: () => false,
|
||||||
set_row(stream_id, widget) {
|
set_row(stream_id, widget) {
|
||||||
html_dict.set(stream_id, widget.get_li().html());
|
html_dict.set(stream_id, widget.get_li().html());
|
||||||
},
|
},
|
||||||
};
|
});
|
||||||
|
|
||||||
stream_list.update_count_in_dom = noop;
|
stream_list.__Rewire__("update_count_in_dom", noop);
|
||||||
|
|
||||||
stub_templates((template_name, data) => {
|
stub_templates((template_name, data) => {
|
||||||
assert.equal(template_name, "stream_sidebar_row");
|
assert.equal(template_name, "stream_sidebar_row");
|
||||||
|
|
|
@ -35,14 +35,14 @@ function expand_sidebar() {
|
||||||
function make_cursor_helper() {
|
function make_cursor_helper() {
|
||||||
const events = [];
|
const events = [];
|
||||||
|
|
||||||
stream_list.stream_cursor = {
|
stream_list.__Rewire__("stream_cursor", {
|
||||||
reset: () => {
|
reset: () => {
|
||||||
events.push("reset");
|
events.push("reset");
|
||||||
},
|
},
|
||||||
clear: () => {
|
clear: () => {
|
||||||
events.push("clear");
|
events.push("clear");
|
||||||
},
|
},
|
||||||
};
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
events,
|
events,
|
||||||
|
@ -102,9 +102,9 @@ run_test("basics", () => {
|
||||||
|
|
||||||
function verify_list_updated(f) {
|
function verify_list_updated(f) {
|
||||||
let updated;
|
let updated;
|
||||||
stream_list.update_streams_sidebar = () => {
|
stream_list.__Rewire__("update_streams_sidebar", () => {
|
||||||
updated = true;
|
updated = true;
|
||||||
};
|
});
|
||||||
|
|
||||||
f();
|
f();
|
||||||
assert(updated);
|
assert(updated);
|
||||||
|
|
|
@ -39,7 +39,8 @@ const overlays = {__esModule: true};
|
||||||
rewiremock("../../static/js/overlays").with(overlays);
|
rewiremock("../../static/js/overlays").with(overlays);
|
||||||
const resize = {__esModule: true};
|
const resize = {__esModule: true};
|
||||||
rewiremock("../../static/js/resize").with(resize);
|
rewiremock("../../static/js/resize").with(resize);
|
||||||
let stream_list = set_global("stream_list", {});
|
let stream_list = {__esModule: true};
|
||||||
|
rewiremock("../../static/js/stream_list").with(stream_list);
|
||||||
let unread_ops = {__esModule: true};
|
let unread_ops = {__esModule: true};
|
||||||
rewiremock("../../static/js/unread_ops").with(unread_ops);
|
rewiremock("../../static/js/unread_ops").with(unread_ops);
|
||||||
const unread_ui = {__esModule: true};
|
const unread_ui = {__esModule: true};
|
||||||
|
@ -696,6 +697,7 @@ run_test("unread_ops", (override) => {
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
rewiremock("../../static/js/stream_list").disable();
|
||||||
stream_list = zrequire("stream_list");
|
stream_list = zrequire("stream_list");
|
||||||
|
|
||||||
const social_stream = {
|
const social_stream = {
|
||||||
|
|
|
@ -115,7 +115,6 @@ const upload = zrequire("upload");
|
||||||
const compose = zrequire("compose");
|
const compose = zrequire("compose");
|
||||||
zrequire("composebox_typeahead");
|
zrequire("composebox_typeahead");
|
||||||
zrequire("narrow");
|
zrequire("narrow");
|
||||||
zrequire("stream_list");
|
|
||||||
|
|
||||||
run_test("initialize_everything", () => {
|
run_test("initialize_everything", () => {
|
||||||
util.is_mobile = () => false;
|
util.is_mobile = () => false;
|
||||||
|
|
|
@ -16,7 +16,6 @@ import "flatpickr/dist/plugins/confirmDate/confirmDate";
|
||||||
import "../i18n";
|
import "../i18n";
|
||||||
import "../fold_dict";
|
import "../fold_dict";
|
||||||
import "../setup";
|
import "../setup";
|
||||||
import "../stream_list";
|
|
||||||
import "../widgetize";
|
import "../widgetize";
|
||||||
import "../message_list";
|
import "../message_list";
|
||||||
import "../narrow";
|
import "../narrow";
|
||||||
|
|
|
@ -30,6 +30,7 @@ import * as server_events from "./server_events";
|
||||||
import * as settings_panel_menu from "./settings_panel_menu";
|
import * as settings_panel_menu from "./settings_panel_menu";
|
||||||
import * as settings_toggle from "./settings_toggle";
|
import * as settings_toggle from "./settings_toggle";
|
||||||
import * as stream_edit from "./stream_edit";
|
import * as stream_edit from "./stream_edit";
|
||||||
|
import * as stream_list from "./stream_list";
|
||||||
import * as stream_popover from "./stream_popover";
|
import * as stream_popover from "./stream_popover";
|
||||||
import * as ui_util from "./ui_util";
|
import * as ui_util from "./ui_util";
|
||||||
import * as unread_ops from "./unread_ops";
|
import * as unread_ops from "./unread_ops";
|
||||||
|
|
|
@ -11,6 +11,7 @@ import * as popovers from "./popovers";
|
||||||
import * as recent_topics from "./recent_topics";
|
import * as recent_topics from "./recent_topics";
|
||||||
import * as rows from "./rows";
|
import * as rows from "./rows";
|
||||||
import * as sent_messages from "./sent_messages";
|
import * as sent_messages from "./sent_messages";
|
||||||
|
import * as stream_list from "./stream_list";
|
||||||
import * as stream_topic_history from "./stream_topic_history";
|
import * as stream_topic_history from "./stream_topic_history";
|
||||||
import * as transmit from "./transmit";
|
import * as transmit from "./transmit";
|
||||||
import * as util from "./util";
|
import * as util from "./util";
|
||||||
|
|
|
@ -18,7 +18,6 @@ declare let narrow: any;
|
||||||
declare let page_params: any;
|
declare let page_params: any;
|
||||||
declare let pointer: any;
|
declare let pointer: any;
|
||||||
declare let settings_profile_fields: any;
|
declare let settings_profile_fields: any;
|
||||||
declare let stream_list: any;
|
|
||||||
declare let subs: any;
|
declare let subs: any;
|
||||||
declare let ui: any;
|
declare let ui: any;
|
||||||
declare let widgetize: any;
|
declare let widgetize: any;
|
||||||
|
|
|
@ -24,6 +24,7 @@ import * as popovers from "./popovers";
|
||||||
import * as reactions from "./reactions";
|
import * as reactions from "./reactions";
|
||||||
import * as recent_topics from "./recent_topics";
|
import * as recent_topics from "./recent_topics";
|
||||||
import * as search from "./search";
|
import * as search from "./search";
|
||||||
|
import * as stream_list from "./stream_list";
|
||||||
import * as stream_popover from "./stream_popover";
|
import * as stream_popover from "./stream_popover";
|
||||||
import * as topic_zoom from "./topic_zoom";
|
import * as topic_zoom from "./topic_zoom";
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ const recent_senders = require("./recent_senders");
|
||||||
const recent_topics = require("./recent_topics");
|
const recent_topics = require("./recent_topics");
|
||||||
const resize = require("./resize");
|
const resize = require("./resize");
|
||||||
const stream_data = require("./stream_data");
|
const stream_data = require("./stream_data");
|
||||||
|
const stream_list = require("./stream_list");
|
||||||
const stream_topic_history = require("./stream_topic_history");
|
const stream_topic_history = require("./stream_topic_history");
|
||||||
const unread = require("./unread");
|
const unread = require("./unread");
|
||||||
const unread_ops = require("./unread_ops");
|
const unread_ops = require("./unread_ops");
|
||||||
|
|
|
@ -9,6 +9,7 @@ import * as pm_list from "./pm_list";
|
||||||
import * as recent_topics from "./recent_topics";
|
import * as recent_topics from "./recent_topics";
|
||||||
import * as server_events from "./server_events";
|
import * as server_events from "./server_events";
|
||||||
import * as stream_data from "./stream_data";
|
import * as stream_data from "./stream_data";
|
||||||
|
import * as stream_list from "./stream_list";
|
||||||
import * as ui_report from "./ui_report";
|
import * as ui_report from "./ui_report";
|
||||||
|
|
||||||
const consts = {
|
const consts = {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import * as overlays from "./overlays";
|
||||||
import * as recent_topics from "./recent_topics";
|
import * as recent_topics from "./recent_topics";
|
||||||
import * as settings_muting from "./settings_muting";
|
import * as settings_muting from "./settings_muting";
|
||||||
import * as stream_data from "./stream_data";
|
import * as stream_data from "./stream_data";
|
||||||
|
import * as stream_list from "./stream_list";
|
||||||
import * as stream_popover from "./stream_popover";
|
import * as stream_popover from "./stream_popover";
|
||||||
import * as unread_ui from "./unread_ui";
|
import * as unread_ui from "./unread_ui";
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ const search = require("./search");
|
||||||
const search_pill = require("./search_pill");
|
const search_pill = require("./search_pill");
|
||||||
const search_pill_widget = require("./search_pill_widget");
|
const search_pill_widget = require("./search_pill_widget");
|
||||||
const stream_data = require("./stream_data");
|
const stream_data = require("./stream_data");
|
||||||
|
const stream_list = require("./stream_list");
|
||||||
const stream_topic_history = require("./stream_topic_history");
|
const stream_topic_history = require("./stream_topic_history");
|
||||||
const top_left_corner = require("./top_left_corner");
|
const top_left_corner = require("./top_left_corner");
|
||||||
const topic_generator = require("./topic_generator");
|
const topic_generator = require("./topic_generator");
|
||||||
|
|
|
@ -16,6 +16,7 @@ import * as panels from "./panels";
|
||||||
import * as people from "./people";
|
import * as people from "./people";
|
||||||
import * as recent_senders from "./recent_senders";
|
import * as recent_senders from "./recent_senders";
|
||||||
import * as stream_data from "./stream_data";
|
import * as stream_data from "./stream_data";
|
||||||
|
import * as stream_list from "./stream_list";
|
||||||
import * as timerender from "./timerender";
|
import * as timerender from "./timerender";
|
||||||
import * as top_left_corner from "./top_left_corner";
|
import * as top_left_corner from "./top_left_corner";
|
||||||
import * as unread from "./unread";
|
import * as unread from "./unread";
|
||||||
|
|
|
@ -41,6 +41,7 @@ import * as settings_users from "./settings_users";
|
||||||
import * as starred_messages from "./starred_messages";
|
import * as starred_messages from "./starred_messages";
|
||||||
import * as stream_data from "./stream_data";
|
import * as stream_data from "./stream_data";
|
||||||
import * as stream_events from "./stream_events";
|
import * as stream_events from "./stream_events";
|
||||||
|
import * as stream_list from "./stream_list";
|
||||||
import * as stream_topic_history from "./stream_topic_history";
|
import * as stream_topic_history from "./stream_topic_history";
|
||||||
import * as submessage from "./submessage";
|
import * as submessage from "./submessage";
|
||||||
import * as typing_events from "./typing_events";
|
import * as typing_events from "./typing_events";
|
||||||
|
|
|
@ -8,6 +8,7 @@ import * as recent_topics from "./recent_topics";
|
||||||
import * as settings_notifications from "./settings_notifications";
|
import * as settings_notifications from "./settings_notifications";
|
||||||
import * as stream_color from "./stream_color";
|
import * as stream_color from "./stream_color";
|
||||||
import * as stream_data from "./stream_data";
|
import * as stream_data from "./stream_data";
|
||||||
|
import * as stream_list from "./stream_list";
|
||||||
import * as stream_muting from "./stream_muting";
|
import * as stream_muting from "./stream_muting";
|
||||||
|
|
||||||
// In theory, this function should apply the account-level defaults,
|
// In theory, this function should apply the account-level defaults,
|
||||||
|
|
|
@ -1,28 +1,28 @@
|
||||||
"use strict";
|
import _ from "lodash";
|
||||||
|
|
||||||
const _ = require("lodash");
|
import render_stream_privacy from "../templates/stream_privacy.hbs";
|
||||||
|
import render_stream_sidebar_row from "../templates/stream_sidebar_row.hbs";
|
||||||
|
|
||||||
const render_stream_privacy = require("../templates/stream_privacy.hbs");
|
import * as hash_util from "./hash_util";
|
||||||
const render_stream_sidebar_row = require("../templates/stream_sidebar_row.hbs");
|
import * as keydown_util from "./keydown_util";
|
||||||
|
import {ListCursor} from "./list_cursor";
|
||||||
|
import * as narrow_state from "./narrow_state";
|
||||||
|
import * as popovers from "./popovers";
|
||||||
|
import * as resize from "./resize";
|
||||||
|
import * as scroll_util from "./scroll_util";
|
||||||
|
import * as stream_color from "./stream_color";
|
||||||
|
import * as stream_data from "./stream_data";
|
||||||
|
import * as stream_popover from "./stream_popover";
|
||||||
|
import * as stream_sort from "./stream_sort";
|
||||||
|
import * as topic_list from "./topic_list";
|
||||||
|
import * as topic_zoom from "./topic_zoom";
|
||||||
|
import * as unread from "./unread";
|
||||||
|
|
||||||
const hash_util = require("./hash_util");
|
export let stream_cursor;
|
||||||
const keydown_util = require("./keydown_util");
|
|
||||||
const {ListCursor} = require("./list_cursor");
|
|
||||||
const narrow_state = require("./narrow_state");
|
|
||||||
const popovers = require("./popovers");
|
|
||||||
const resize = require("./resize");
|
|
||||||
const scroll_util = require("./scroll_util");
|
|
||||||
const stream_color = require("./stream_color");
|
|
||||||
const stream_data = require("./stream_data");
|
|
||||||
const stream_popover = require("./stream_popover");
|
|
||||||
const stream_sort = require("./stream_sort");
|
|
||||||
const topic_list = require("./topic_list");
|
|
||||||
const topic_zoom = require("./topic_zoom");
|
|
||||||
const unread = require("./unread");
|
|
||||||
|
|
||||||
let has_scrolled = false;
|
let has_scrolled = false;
|
||||||
|
|
||||||
exports.update_count_in_dom = function (unread_count_elem, count) {
|
export function update_count_in_dom(unread_count_elem, count) {
|
||||||
const count_span = unread_count_elem.find(".count");
|
const count_span = unread_count_elem.find(".count");
|
||||||
const value_span = count_span.find(".value");
|
const value_span = count_span.find(".value");
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ exports.update_count_in_dom = function (unread_count_elem, count) {
|
||||||
count_span.parent(".subscription_block").addClass("stream-with-count");
|
count_span.parent(".subscription_block").addClass("stream-with-count");
|
||||||
}
|
}
|
||||||
value_span.text(count);
|
value_span.text(count);
|
||||||
};
|
}
|
||||||
|
|
||||||
class StreamSidebar {
|
class StreamSidebar {
|
||||||
rows = new Map(); // stream id -> row widget
|
rows = new Map(); // stream id -> row widget
|
||||||
|
@ -68,7 +68,7 @@ class StreamSidebar {
|
||||||
this.rows.delete(stream_id);
|
this.rows.delete(stream_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.stream_sidebar = new StreamSidebar();
|
export const stream_sidebar = new StreamSidebar();
|
||||||
|
|
||||||
function get_search_term() {
|
function get_search_term() {
|
||||||
const search_box = $(".stream-list-filter");
|
const search_box = $(".stream-list-filter");
|
||||||
|
@ -76,30 +76,30 @@ function get_search_term() {
|
||||||
return search_term;
|
return search_term;
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.add_sidebar_row = function (sub) {
|
export function add_sidebar_row(sub) {
|
||||||
exports.create_sidebar_row(sub);
|
create_sidebar_row(sub);
|
||||||
exports.build_stream_list();
|
build_stream_list();
|
||||||
exports.stream_cursor.redraw();
|
stream_cursor.redraw();
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.remove_sidebar_row = function (stream_id) {
|
export function remove_sidebar_row(stream_id) {
|
||||||
exports.stream_sidebar.remove_row(stream_id);
|
stream_sidebar.remove_row(stream_id);
|
||||||
exports.build_stream_list();
|
build_stream_list();
|
||||||
exports.stream_cursor.redraw();
|
stream_cursor.redraw();
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.create_initial_sidebar_rows = function () {
|
export function create_initial_sidebar_rows() {
|
||||||
// This code is slightly opaque, but it ends up building
|
// This code is slightly opaque, but it ends up building
|
||||||
// up list items and attaching them to the "sub" data
|
// up list items and attaching them to the "sub" data
|
||||||
// structures that are kept in stream_data.js.
|
// structures that are kept in stream_data.js.
|
||||||
const subs = stream_data.subscribed_subs();
|
const subs = stream_data.subscribed_subs();
|
||||||
|
|
||||||
for (const sub of subs) {
|
for (const sub of subs) {
|
||||||
exports.create_sidebar_row(sub);
|
create_sidebar_row(sub);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.build_stream_list = function (force_rerender) {
|
export function build_stream_list(force_rerender) {
|
||||||
// This function assumes we have already created the individual
|
// This function assumes we have already created the individual
|
||||||
// sidebar rows. Our job here is to build the bigger widget,
|
// sidebar rows. Our job here is to build the bigger widget,
|
||||||
// which largely is a matter of arranging the individual rows in
|
// which largely is a matter of arranging the individual rows in
|
||||||
|
@ -121,7 +121,7 @@ exports.build_stream_list = function (force_rerender) {
|
||||||
const elems = [];
|
const elems = [];
|
||||||
|
|
||||||
function add_sidebar_li(stream_id) {
|
function add_sidebar_li(stream_id) {
|
||||||
const sidebar_row = exports.stream_sidebar.get_row(stream_id);
|
const sidebar_row = stream_sidebar.get_row(stream_id);
|
||||||
sidebar_row.update_whether_active();
|
sidebar_row.update_whether_active();
|
||||||
elems.push(sidebar_row.get_li());
|
elems.push(sidebar_row.get_li());
|
||||||
}
|
}
|
||||||
|
@ -154,10 +154,10 @@ exports.build_stream_list = function (force_rerender) {
|
||||||
}
|
}
|
||||||
|
|
||||||
parent.append(elems);
|
parent.append(elems);
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.get_stream_li = function (stream_id) {
|
export function get_stream_li(stream_id) {
|
||||||
const row = exports.stream_sidebar.get_row(stream_id);
|
const row = stream_sidebar.get_row(stream_id);
|
||||||
if (!row) {
|
if (!row) {
|
||||||
// Not all streams are in the sidebar, so we don't report
|
// Not all streams are in the sidebar, so we don't report
|
||||||
// an error here, and it's up for the caller to error if
|
// an error here, and it's up for the caller to error if
|
||||||
|
@ -177,13 +177,13 @@ exports.get_stream_li = function (stream_id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return li;
|
return li;
|
||||||
};
|
}
|
||||||
|
|
||||||
function stream_id_for_elt(elt) {
|
function stream_id_for_elt(elt) {
|
||||||
return Number.parseInt(elt.attr("data-stream-id"), 10);
|
return Number.parseInt(elt.attr("data-stream-id"), 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.zoom_in_topics = function (options) {
|
export function zoom_in_topics(options) {
|
||||||
// This only does stream-related tasks related to zooming
|
// This only does stream-related tasks related to zooming
|
||||||
// in to more topics, which is basically hiding all the
|
// in to more topics, which is basically hiding all the
|
||||||
// other streams.
|
// other streams.
|
||||||
|
@ -208,9 +208,9 @@ exports.zoom_in_topics = function (options) {
|
||||||
elt.hide();
|
elt.hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.zoom_out_topics = function () {
|
export function zoom_out_topics() {
|
||||||
// Show stream list titles and pinned stream splitter
|
// Show stream list titles and pinned stream splitter
|
||||||
$(".stream-filters-label").each(function () {
|
$(".stream-filters-label").each(function () {
|
||||||
$(this).show();
|
$(this).show();
|
||||||
|
@ -221,10 +221,10 @@ exports.zoom_out_topics = function () {
|
||||||
|
|
||||||
$("#streams_list").expectOne().removeClass("zoom-in").addClass("zoom-out");
|
$("#streams_list").expectOne().removeClass("zoom-in").addClass("zoom-out");
|
||||||
$("#stream_filters li.narrow-filter").show();
|
$("#stream_filters li.narrow-filter").show();
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.set_in_home_view = function (stream_id, in_home) {
|
export function set_in_home_view(stream_id, in_home) {
|
||||||
const li = exports.get_stream_li(stream_id);
|
const li = get_stream_li(stream_id);
|
||||||
if (!li) {
|
if (!li) {
|
||||||
blueslip.error("passed in bad stream id " + stream_id);
|
blueslip.error("passed in bad stream id " + stream_id);
|
||||||
return;
|
return;
|
||||||
|
@ -235,7 +235,7 @@ exports.set_in_home_view = function (stream_id, in_home) {
|
||||||
} else {
|
} else {
|
||||||
li.addClass("out_of_home_view");
|
li.addClass("out_of_home_view");
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
function build_stream_sidebar_li(sub) {
|
function build_stream_sidebar_li(sub) {
|
||||||
const name = sub.name;
|
const name = sub.name;
|
||||||
|
@ -279,25 +279,25 @@ class StreamSidebarRow {
|
||||||
|
|
||||||
update_unread_count() {
|
update_unread_count() {
|
||||||
const count = unread.num_unread_for_stream(this.sub.stream_id);
|
const count = unread.num_unread_for_stream(this.sub.stream_id);
|
||||||
exports.update_count_in_dom(this.list_item, count);
|
update_count_in_dom(this.list_item, count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function build_stream_sidebar_row(sub) {
|
function build_stream_sidebar_row(sub) {
|
||||||
exports.stream_sidebar.set_row(sub.stream_id, new StreamSidebarRow(sub));
|
stream_sidebar.set_row(sub.stream_id, new StreamSidebarRow(sub));
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.create_sidebar_row = function (sub) {
|
export function create_sidebar_row(sub) {
|
||||||
if (exports.stream_sidebar.has_row_for(sub.stream_id)) {
|
if (stream_sidebar.has_row_for(sub.stream_id)) {
|
||||||
// already exists
|
// already exists
|
||||||
blueslip.warn("Dup try to build sidebar row for stream " + sub.stream_id);
|
blueslip.warn("Dup try to build sidebar row for stream " + sub.stream_id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
build_stream_sidebar_row(sub);
|
build_stream_sidebar_row(sub);
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.redraw_stream_privacy = function (sub) {
|
export function redraw_stream_privacy(sub) {
|
||||||
const li = exports.get_stream_li(sub.stream_id);
|
const li = get_stream_li(sub.stream_id);
|
||||||
if (!li) {
|
if (!li) {
|
||||||
// We don't want to raise error here, if we can't find stream in subscription
|
// We don't want to raise error here, if we can't find stream in subscription
|
||||||
// stream list. Cause we allow org admin to update stream privacy
|
// stream list. Cause we allow org admin to update stream privacy
|
||||||
|
@ -315,23 +315,23 @@ exports.redraw_stream_privacy = function (sub) {
|
||||||
|
|
||||||
const html = render_stream_privacy(args);
|
const html = render_stream_privacy(args);
|
||||||
div.html(html);
|
div.html(html);
|
||||||
};
|
}
|
||||||
|
|
||||||
function set_stream_unread_count(stream_id, count) {
|
function set_stream_unread_count(stream_id, count) {
|
||||||
const unread_count_elem = exports.get_stream_li(stream_id);
|
const unread_count_elem = get_stream_li(stream_id);
|
||||||
if (!unread_count_elem) {
|
if (!unread_count_elem) {
|
||||||
// This can happen for legitimate reasons, but we warn
|
// This can happen for legitimate reasons, but we warn
|
||||||
// just in case.
|
// just in case.
|
||||||
blueslip.warn("stream id no longer in sidebar: " + stream_id);
|
blueslip.warn("stream id no longer in sidebar: " + stream_id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
exports.update_count_in_dom(unread_count_elem, count);
|
update_count_in_dom(unread_count_elem, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.update_streams_sidebar = function (force_rerender) {
|
export function update_streams_sidebar(force_rerender) {
|
||||||
exports.build_stream_list(force_rerender);
|
build_stream_list(force_rerender);
|
||||||
|
|
||||||
exports.stream_cursor.redraw();
|
stream_cursor.redraw();
|
||||||
|
|
||||||
if (!narrow_state.active()) {
|
if (!narrow_state.active()) {
|
||||||
return;
|
return;
|
||||||
|
@ -339,42 +339,42 @@ exports.update_streams_sidebar = function (force_rerender) {
|
||||||
|
|
||||||
const filter = narrow_state.filter();
|
const filter = narrow_state.filter();
|
||||||
|
|
||||||
exports.update_stream_sidebar_for_narrow(filter);
|
update_stream_sidebar_for_narrow(filter);
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.update_dom_with_unread_counts = function (counts) {
|
export function update_dom_with_unread_counts(counts) {
|
||||||
// counts.stream_count maps streams to counts
|
// counts.stream_count maps streams to counts
|
||||||
for (const [stream_id, count] of counts.stream_count) {
|
for (const [stream_id, count] of counts.stream_count) {
|
||||||
set_stream_unread_count(stream_id, count);
|
set_stream_unread_count(stream_id, count);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.rename_stream = function (sub) {
|
export function rename_stream(sub) {
|
||||||
// The sub object is expected to already have the updated name
|
// The sub object is expected to already have the updated name
|
||||||
build_stream_sidebar_row(sub);
|
build_stream_sidebar_row(sub);
|
||||||
exports.update_streams_sidebar(true); // big hammer
|
update_streams_sidebar(true); // big hammer
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.refresh_pinned_or_unpinned_stream = function (sub) {
|
export function refresh_pinned_or_unpinned_stream(sub) {
|
||||||
// Pinned/unpinned streams require re-ordering.
|
// Pinned/unpinned streams require re-ordering.
|
||||||
// We use kind of brute force now, which is probably fine.
|
// We use kind of brute force now, which is probably fine.
|
||||||
build_stream_sidebar_row(sub);
|
build_stream_sidebar_row(sub);
|
||||||
exports.update_streams_sidebar();
|
update_streams_sidebar();
|
||||||
|
|
||||||
// Only scroll pinned topics into view. If we're unpinning
|
// Only scroll pinned topics into view. If we're unpinning
|
||||||
// a topic, we may be literally trying to get it out of
|
// a topic, we may be literally trying to get it out of
|
||||||
// our sight.
|
// our sight.
|
||||||
if (sub.pin_to_top) {
|
if (sub.pin_to_top) {
|
||||||
const stream_li = exports.get_stream_li(sub.stream_id);
|
const stream_li = get_stream_li(sub.stream_id);
|
||||||
if (!stream_li) {
|
if (!stream_li) {
|
||||||
blueslip.error("passed in bad stream id " + sub.stream_id);
|
blueslip.error("passed in bad stream id " + sub.stream_id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
exports.scroll_stream_into_view(stream_li);
|
scroll_stream_into_view(stream_li);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.get_sidebar_stream_topic_info = function (filter) {
|
export function get_sidebar_stream_topic_info(filter) {
|
||||||
const result = {
|
const result = {
|
||||||
stream_id: undefined,
|
stream_id: undefined,
|
||||||
topic_selected: false,
|
topic_selected: false,
|
||||||
|
@ -402,14 +402,14 @@ exports.get_sidebar_stream_topic_info = function (filter) {
|
||||||
result.topic_selected = op_topic.length === 1;
|
result.topic_selected = op_topic.length === 1;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
};
|
}
|
||||||
|
|
||||||
function deselect_stream_items() {
|
function deselect_stream_items() {
|
||||||
$("ul#stream_filters li").removeClass("active-filter");
|
$("ul#stream_filters li").removeClass("active-filter");
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.update_stream_sidebar_for_narrow = function (filter) {
|
export function update_stream_sidebar_for_narrow(filter) {
|
||||||
const info = exports.get_sidebar_stream_topic_info(filter);
|
const info = get_sidebar_stream_topic_info(filter);
|
||||||
|
|
||||||
deselect_stream_items();
|
deselect_stream_items();
|
||||||
|
|
||||||
|
@ -420,7 +420,7 @@ exports.update_stream_sidebar_for_narrow = function (filter) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const stream_li = exports.get_stream_li(stream_id);
|
const stream_li = get_stream_li(stream_id);
|
||||||
|
|
||||||
if (!stream_li) {
|
if (!stream_li) {
|
||||||
// This is a sanity check. When we narrow to a subscribed
|
// This is a sanity check. When we narrow to a subscribed
|
||||||
|
@ -444,27 +444,27 @@ exports.update_stream_sidebar_for_narrow = function (filter) {
|
||||||
topic_list.rebuild(stream_li, stream_id);
|
topic_list.rebuild(stream_li, stream_id);
|
||||||
|
|
||||||
return stream_li;
|
return stream_li;
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.handle_narrow_activated = function (filter) {
|
export function handle_narrow_activated(filter) {
|
||||||
const stream_li = exports.update_stream_sidebar_for_narrow(filter);
|
const stream_li = update_stream_sidebar_for_narrow(filter);
|
||||||
if (stream_li) {
|
if (stream_li) {
|
||||||
exports.scroll_stream_into_view(stream_li);
|
scroll_stream_into_view(stream_li);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.handle_narrow_deactivated = function () {
|
export function handle_narrow_deactivated() {
|
||||||
deselect_stream_items();
|
deselect_stream_items();
|
||||||
topic_zoom.clear_topics();
|
topic_zoom.clear_topics();
|
||||||
};
|
}
|
||||||
|
|
||||||
function focus_stream_filter(e) {
|
function focus_stream_filter(e) {
|
||||||
exports.stream_cursor.reset();
|
stream_cursor.reset();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}
|
}
|
||||||
|
|
||||||
function keydown_enter_key() {
|
function keydown_enter_key() {
|
||||||
const stream_id = exports.stream_cursor.get_key();
|
const stream_id = stream_cursor.get_key();
|
||||||
|
|
||||||
if (stream_id === undefined) {
|
if (stream_id === undefined) {
|
||||||
// This can happen for empty searches, no need to warn.
|
// This can happen for empty searches, no need to warn.
|
||||||
|
@ -478,28 +478,28 @@ function keydown_enter_key() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.clear_and_hide_search();
|
clear_and_hide_search();
|
||||||
narrow.by("stream", sub.name, {trigger: "sidebar enter key"});
|
narrow.by("stream", sub.name, {trigger: "sidebar enter key"});
|
||||||
}
|
}
|
||||||
|
|
||||||
function actually_update_streams_for_search() {
|
function actually_update_streams_for_search() {
|
||||||
exports.update_streams_sidebar();
|
update_streams_sidebar();
|
||||||
resize.resize_page_components();
|
resize.resize_page_components();
|
||||||
exports.stream_cursor.reset();
|
stream_cursor.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
const update_streams_for_search = _.throttle(actually_update_streams_for_search, 50);
|
const update_streams_for_search = _.throttle(actually_update_streams_for_search, 50);
|
||||||
|
|
||||||
exports.initialize = function () {
|
export function initialize() {
|
||||||
exports.create_initial_sidebar_rows();
|
create_initial_sidebar_rows();
|
||||||
|
|
||||||
// We build the stream_list now. It may get re-built again very shortly
|
// We build the stream_list now. It may get re-built again very shortly
|
||||||
// when new messages come in, but it's fairly quick.
|
// when new messages come in, but it's fairly quick.
|
||||||
exports.build_stream_list();
|
build_stream_list();
|
||||||
exports.set_event_handlers();
|
set_event_handlers();
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.set_event_handlers = function () {
|
export function set_event_handlers() {
|
||||||
$("#stream_filters").on("click", "li .subscription_block", (e) => {
|
$("#stream_filters").on("click", "li .subscription_block", (e) => {
|
||||||
if (e.metaKey || e.ctrlKey) {
|
if (e.metaKey || e.ctrlKey) {
|
||||||
return;
|
return;
|
||||||
|
@ -509,18 +509,18 @@ exports.set_event_handlers = function () {
|
||||||
popovers.hide_all();
|
popovers.hide_all();
|
||||||
narrow.by("stream", sub.name, {trigger: "sidebar"});
|
narrow.by("stream", sub.name, {trigger: "sidebar"});
|
||||||
|
|
||||||
exports.clear_and_hide_search();
|
clear_and_hide_search();
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#clear_search_stream_button").on("click", exports.clear_search);
|
$("#clear_search_stream_button").on("click", clear_search);
|
||||||
|
|
||||||
$("#streams_header")
|
$("#streams_header")
|
||||||
.expectOne()
|
.expectOne()
|
||||||
.on("click", (e) => {
|
.on("click", (e) => {
|
||||||
exports.toggle_filter_displayed(e);
|
toggle_filter_displayed(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
// check for user scrolls on streams list for first time
|
// check for user scrolls on streams list for first time
|
||||||
|
@ -530,12 +530,12 @@ exports.set_event_handlers = function () {
|
||||||
$(this).off("scroll");
|
$(this).off("scroll");
|
||||||
});
|
});
|
||||||
|
|
||||||
exports.stream_cursor = new ListCursor({
|
stream_cursor = new ListCursor({
|
||||||
list: {
|
list: {
|
||||||
scroll_container_sel: "#stream-filters-container",
|
scroll_container_sel: "#stream-filters-container",
|
||||||
find_li(opts) {
|
find_li(opts) {
|
||||||
const stream_id = opts.key;
|
const stream_id = opts.key;
|
||||||
const li = exports.get_stream_li(stream_id);
|
const li = get_stream_li(stream_id);
|
||||||
return li;
|
return li;
|
||||||
},
|
},
|
||||||
first_key: stream_sort.first_stream_id,
|
first_key: stream_sort.first_stream_id,
|
||||||
|
@ -555,59 +555,59 @@ exports.set_event_handlers = function () {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
up_arrow() {
|
up_arrow() {
|
||||||
exports.stream_cursor.prev();
|
stream_cursor.prev();
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
down_arrow() {
|
down_arrow() {
|
||||||
exports.stream_cursor.next();
|
stream_cursor.next();
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
$search_input.on("click", focus_stream_filter);
|
$search_input.on("click", focus_stream_filter);
|
||||||
$search_input.on("focusout", () => exports.stream_cursor.clear());
|
$search_input.on("focusout", () => stream_cursor.clear());
|
||||||
$search_input.on("input", update_streams_for_search);
|
$search_input.on("input", update_streams_for_search);
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.searching = function () {
|
export function searching() {
|
||||||
return $(".stream-list-filter").expectOne().is(":focus");
|
return $(".stream-list-filter").expectOne().is(":focus");
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.escape_search = function () {
|
export function escape_search() {
|
||||||
const filter = $(".stream-list-filter").expectOne();
|
const filter = $(".stream-list-filter").expectOne();
|
||||||
if (filter.val() === "") {
|
if (filter.val() === "") {
|
||||||
exports.clear_and_hide_search();
|
clear_and_hide_search();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
filter.val("");
|
filter.val("");
|
||||||
update_streams_for_search();
|
update_streams_for_search();
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.clear_search = function (e) {
|
export function clear_search(e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
const filter = $(".stream-list-filter").expectOne();
|
const filter = $(".stream-list-filter").expectOne();
|
||||||
if (filter.val() === "") {
|
if (filter.val() === "") {
|
||||||
exports.clear_and_hide_search();
|
clear_and_hide_search();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
filter.val("");
|
filter.val("");
|
||||||
filter.trigger("blur");
|
filter.trigger("blur");
|
||||||
update_streams_for_search();
|
update_streams_for_search();
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.show_search_section = function () {
|
export function show_search_section() {
|
||||||
$(".stream_search_section").expectOne().removeClass("notdisplayed");
|
$(".stream_search_section").expectOne().removeClass("notdisplayed");
|
||||||
resize.resize_stream_filters_container();
|
resize.resize_stream_filters_container();
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.hide_search_section = function () {
|
export function hide_search_section() {
|
||||||
$(".stream_search_section").expectOne().addClass("notdisplayed");
|
$(".stream_search_section").expectOne().addClass("notdisplayed");
|
||||||
resize.resize_stream_filters_container();
|
resize.resize_stream_filters_container();
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.initiate_search = function () {
|
export function initiate_search() {
|
||||||
exports.show_search_section();
|
show_search_section();
|
||||||
|
|
||||||
const filter = $(".stream-list-filter").expectOne();
|
const filter = $(".stream-list-filter").expectOne();
|
||||||
|
|
||||||
|
@ -621,31 +621,31 @@ exports.initiate_search = function () {
|
||||||
}
|
}
|
||||||
filter.trigger("focus");
|
filter.trigger("focus");
|
||||||
|
|
||||||
exports.stream_cursor.reset();
|
stream_cursor.reset();
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.clear_and_hide_search = function () {
|
export function clear_and_hide_search() {
|
||||||
const filter = $(".stream-list-filter");
|
const filter = $(".stream-list-filter");
|
||||||
if (filter.val() !== "") {
|
if (filter.val() !== "") {
|
||||||
filter.val("");
|
filter.val("");
|
||||||
update_streams_for_search();
|
update_streams_for_search();
|
||||||
}
|
}
|
||||||
exports.stream_cursor.clear();
|
stream_cursor.clear();
|
||||||
filter.trigger("blur");
|
filter.trigger("blur");
|
||||||
|
|
||||||
exports.hide_search_section();
|
hide_search_section();
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.toggle_filter_displayed = function (e) {
|
export function toggle_filter_displayed(e) {
|
||||||
if ($(".stream_search_section.notdisplayed").length === 0) {
|
if ($(".stream_search_section.notdisplayed").length === 0) {
|
||||||
exports.clear_and_hide_search();
|
clear_and_hide_search();
|
||||||
} else {
|
} else {
|
||||||
exports.initiate_search();
|
initiate_search();
|
||||||
}
|
}
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.scroll_stream_into_view = function (stream_li) {
|
export function scroll_stream_into_view(stream_li) {
|
||||||
const container = $("#stream-filters-container");
|
const container = $("#stream-filters-container");
|
||||||
|
|
||||||
if (stream_li.length !== 1) {
|
if (stream_li.length !== 1) {
|
||||||
|
@ -654,21 +654,21 @@ exports.scroll_stream_into_view = function (stream_li) {
|
||||||
}
|
}
|
||||||
|
|
||||||
scroll_util.scroll_element_into_container(stream_li, container);
|
scroll_util.scroll_element_into_container(stream_li, container);
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.maybe_scroll_narrow_into_view = function () {
|
export function maybe_scroll_narrow_into_view() {
|
||||||
// we don't want to interfere with user scrolling once the page loads
|
// we don't want to interfere with user scrolling once the page loads
|
||||||
if (has_scrolled) {
|
if (has_scrolled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const stream_li = exports.get_current_stream_li();
|
const stream_li = get_current_stream_li();
|
||||||
if (stream_li) {
|
if (stream_li) {
|
||||||
exports.scroll_stream_into_view(stream_li);
|
scroll_stream_into_view(stream_li);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.get_current_stream_li = function () {
|
export function get_current_stream_li() {
|
||||||
const stream_id = topic_list.active_stream_id();
|
const stream_id = topic_list.active_stream_id();
|
||||||
|
|
||||||
if (!stream_id) {
|
if (!stream_id) {
|
||||||
|
@ -676,7 +676,7 @@ exports.get_current_stream_li = function () {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const stream_li = exports.get_stream_li(stream_id);
|
const stream_li = get_stream_li(stream_id);
|
||||||
|
|
||||||
if (!stream_li) {
|
if (!stream_li) {
|
||||||
// This code path shouldn't ever be reached.
|
// This code path shouldn't ever be reached.
|
||||||
|
@ -685,6 +685,4 @@ exports.get_current_stream_li = function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
return stream_li;
|
return stream_li;
|
||||||
};
|
}
|
||||||
|
|
||||||
window.stream_list = exports;
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ import * as message_util from "./message_util";
|
||||||
import * as message_viewport from "./message_viewport";
|
import * as message_viewport from "./message_viewport";
|
||||||
import * as navigate from "./navigate";
|
import * as navigate from "./navigate";
|
||||||
import * as overlays from "./overlays";
|
import * as overlays from "./overlays";
|
||||||
|
import * as stream_list from "./stream_list";
|
||||||
|
|
||||||
export function update_is_muted(sub, value) {
|
export function update_is_muted(sub, value) {
|
||||||
sub.is_muted = value;
|
sub.is_muted = value;
|
||||||
|
|
|
@ -22,6 +22,7 @@ const search_util = require("./search_util");
|
||||||
const stream_create = require("./stream_create");
|
const stream_create = require("./stream_create");
|
||||||
const stream_data = require("./stream_data");
|
const stream_data = require("./stream_data");
|
||||||
const stream_edit = require("./stream_edit");
|
const stream_edit = require("./stream_edit");
|
||||||
|
const stream_list = require("./stream_list");
|
||||||
const stream_muting = require("./stream_muting");
|
const stream_muting = require("./stream_muting");
|
||||||
const stream_ui_updates = require("./stream_ui_updates");
|
const stream_ui_updates = require("./stream_ui_updates");
|
||||||
const typeahead_helper = require("./typeahead_helper");
|
const typeahead_helper = require("./typeahead_helper");
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import * as popovers from "./popovers";
|
import * as popovers from "./popovers";
|
||||||
|
import * as stream_list from "./stream_list";
|
||||||
import * as topic_list from "./topic_list";
|
import * as topic_list from "./topic_list";
|
||||||
|
|
||||||
let zoomed_in = false;
|
let zoomed_in = false;
|
||||||
|
|
|
@ -56,6 +56,7 @@ import * as starred_messages from "./starred_messages";
|
||||||
import * as stream_color from "./stream_color";
|
import * as stream_color from "./stream_color";
|
||||||
import * as stream_data from "./stream_data";
|
import * as stream_data from "./stream_data";
|
||||||
import * as stream_edit from "./stream_edit";
|
import * as stream_edit from "./stream_edit";
|
||||||
|
import * as stream_list from "./stream_list";
|
||||||
import * as timerender from "./timerender";
|
import * as timerender from "./timerender";
|
||||||
import * as topic_list from "./topic_list";
|
import * as topic_list from "./topic_list";
|
||||||
import * as topic_zoom from "./topic_zoom";
|
import * as topic_zoom from "./topic_zoom";
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import * as activity from "./activity";
|
import * as activity from "./activity";
|
||||||
import * as notifications from "./notifications";
|
import * as notifications from "./notifications";
|
||||||
import * as pm_list from "./pm_list";
|
import * as pm_list from "./pm_list";
|
||||||
|
import * as stream_list from "./stream_list";
|
||||||
import * as top_left_corner from "./top_left_corner";
|
import * as top_left_corner from "./top_left_corner";
|
||||||
import * as topic_list from "./topic_list";
|
import * as topic_list from "./topic_list";
|
||||||
import * as unread from "./unread";
|
import * as unread from "./unread";
|
||||||
|
|
Loading…
Reference in New Issue