mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 06:23:38 +00:00
js: Convert static/js/narrow_state.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
a1e9be884d
commit
b830f53eb5
@@ -178,7 +178,6 @@
|
||||
"message_store": false,
|
||||
"message_util": false,
|
||||
"narrow": false,
|
||||
"narrow_state": false,
|
||||
"navigate": false,
|
||||
"night_mode": false,
|
||||
"notifications": false,
|
||||
|
||||
@@ -39,9 +39,12 @@ rewiremock("../../static/js/drafts").with({
|
||||
update_draft: noop,
|
||||
});
|
||||
|
||||
const narrow_state = set_global("narrow_state", {
|
||||
const narrow_state = {
|
||||
__esModule: true,
|
||||
set_compose_defaults: noop,
|
||||
});
|
||||
};
|
||||
|
||||
rewiremock("../../static/js/narrow_state").with(narrow_state);
|
||||
|
||||
set_global("unread_ops", {
|
||||
notify_server_message_read: noop,
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
const {strict: assert} = require("assert");
|
||||
|
||||
const rewiremock = require("rewiremock/node");
|
||||
|
||||
const {set_global, zrequire} = require("../zjsunit/namespace");
|
||||
const {make_stub} = require("../zjsunit/stub");
|
||||
const {run_test} = require("../zjsunit/test");
|
||||
@@ -15,12 +17,15 @@ const compose_fade = set_global("compose_fade", {});
|
||||
const stream_events = set_global("stream_events", {});
|
||||
const subs = set_global("subs", {});
|
||||
|
||||
rewiremock.enable();
|
||||
|
||||
const peer_data = zrequire("peer_data");
|
||||
const people = zrequire("people");
|
||||
const stream_data = zrequire("stream_data");
|
||||
|
||||
set_global("current_msg_list", {});
|
||||
const narrow_state = set_global("narrow_state", {});
|
||||
const narrow_state = {__esModule: true};
|
||||
rewiremock("../../static/js/narrow_state").with(narrow_state);
|
||||
const page_params = set_global("page_params", {});
|
||||
const overlays = set_global("overlays", {});
|
||||
const settings_org = set_global("settings_org", {});
|
||||
@@ -266,3 +271,4 @@ test("stream delete (special streams)", (override) => {
|
||||
assert.equal(page_params.realm_notifications_stream_id, -1);
|
||||
assert.equal(page_params.realm_signup_notifications_stream_id, -1);
|
||||
});
|
||||
rewiremock.disable();
|
||||
|
||||
@@ -41,7 +41,8 @@ set_global("message_scroll", {
|
||||
});
|
||||
const message_util = set_global("message_util", {});
|
||||
const message_store = set_global("message_store", {});
|
||||
const narrow_state = set_global("narrow_state", {});
|
||||
const narrow_state = {__esModule: true};
|
||||
rewiremock("../../static/js/narrow_state").with(narrow_state);
|
||||
const pm_list = {__esModule: true};
|
||||
rewiremock("../../static/js/pm_list").with(pm_list);
|
||||
const server_events = set_global("server_events", {});
|
||||
|
||||
@@ -26,7 +26,8 @@ set_global("document", {
|
||||
},
|
||||
});
|
||||
|
||||
const narrow_state = set_global("narrow_state", {});
|
||||
const narrow_state = {__esModule: true};
|
||||
rewiremock("../../static/js/narrow_state").with(narrow_state);
|
||||
const stream_data = set_global("stream_data", {});
|
||||
set_global("recent_topics", {
|
||||
is_visible: () => false,
|
||||
|
||||
@@ -67,7 +67,7 @@ function test_with(fixture) {
|
||||
},
|
||||
};
|
||||
|
||||
narrow_state.get_first_unread_info = () => fixture.unread_info;
|
||||
narrow_state.__Rewire__("get_first_unread_info", () => fixture.unread_info);
|
||||
|
||||
narrow.maybe_add_local_messages({
|
||||
id_info,
|
||||
|
||||
@@ -204,7 +204,7 @@ run_test("defensive code", () => {
|
||||
// _possible_unread_message_ids for any case where we
|
||||
// couldn't compute the unread message ids, but that
|
||||
// invariant is hard to future-proof.
|
||||
narrow_state._possible_unread_message_ids = () => undefined;
|
||||
narrow_state.__Rewire__("_possible_unread_message_ids", () => undefined);
|
||||
const terms = [{operator: "some-unhandled-case", operand: "whatever"}];
|
||||
set_filter(terms);
|
||||
assert_unread_info({
|
||||
|
||||
@@ -8,7 +8,8 @@ const {set_global, with_field, zrequire} = require("../zjsunit/namespace");
|
||||
const {run_test} = require("../zjsunit/test");
|
||||
const $ = require("../zjsunit/zjquery");
|
||||
|
||||
const narrow_state = set_global("narrow_state", {});
|
||||
const narrow_state = {__esModule: true};
|
||||
rewiremock("../../static/js/narrow_state").with(narrow_state);
|
||||
set_global("ui", {
|
||||
get_content_element: (element) => element,
|
||||
});
|
||||
|
||||
@@ -46,7 +46,6 @@ rewiremock.enable();
|
||||
|
||||
zrequire("hash_util");
|
||||
zrequire("narrow");
|
||||
zrequire("narrow_state");
|
||||
const people = zrequire("people");
|
||||
zrequire("presence");
|
||||
zrequire("buddy_data");
|
||||
|
||||
@@ -168,7 +168,6 @@ set_global("stream_data", {
|
||||
rewiremock.enable();
|
||||
|
||||
zrequire("message_util");
|
||||
zrequire("narrow_state");
|
||||
const people = zrequire("people");
|
||||
let rt = zrequire("recent_topics");
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
const {strict: assert} = require("assert");
|
||||
|
||||
const rewiremock = require("rewiremock/node");
|
||||
|
||||
const {set_global, zrequire} = require("../zjsunit/namespace");
|
||||
const {run_test} = require("../zjsunit/test");
|
||||
const $ = require("../zjsunit/zjquery");
|
||||
@@ -12,7 +14,11 @@ set_global("page_params", {
|
||||
|
||||
const noop = () => {};
|
||||
|
||||
const narrow_state = set_global("narrow_state", {filter: () => false});
|
||||
const narrow_state = {
|
||||
__esModule: true,
|
||||
filter: () => false,
|
||||
};
|
||||
rewiremock("../../static/js/narrow_state").with(narrow_state);
|
||||
const search_suggestion = set_global("search_suggestion", {});
|
||||
set_global("ui_util", {
|
||||
change_tab_to: noop,
|
||||
@@ -27,6 +33,8 @@ set_global("search_pill_widget", {
|
||||
|
||||
set_global("setTimeout", (func) => func());
|
||||
|
||||
rewiremock.enable();
|
||||
|
||||
const search = zrequire("search");
|
||||
const search_pill = zrequire("search_pill");
|
||||
const {Filter} = zrequire("Filter", "js/filter");
|
||||
@@ -341,3 +349,4 @@ run_test("initiate_search", () => {
|
||||
assert(is_searchbox_text_selected);
|
||||
assert(is_searchbox_focused);
|
||||
});
|
||||
rewiremock.disable();
|
||||
|
||||
@@ -14,7 +14,8 @@ set_global("page_params", {
|
||||
|
||||
const noop = () => {};
|
||||
|
||||
const narrow_state = set_global("narrow_state", {});
|
||||
const narrow_state = {__esModule: true};
|
||||
rewiremock("../../static/js/narrow_state").with(narrow_state);
|
||||
const search_suggestion = set_global("search_suggestion", {});
|
||||
set_global("ui_util", {
|
||||
change_tab_to: noop,
|
||||
|
||||
@@ -88,7 +88,7 @@ run_test("basic_get_suggestions", () => {
|
||||
|
||||
stream_data.subscribed_streams = () => [];
|
||||
|
||||
narrow_state.stream = () => "office";
|
||||
narrow_state.__Rewire__("stream", () => "office");
|
||||
|
||||
const suggestions = get_suggestions("", query);
|
||||
|
||||
@@ -102,7 +102,7 @@ run_test("subset_suggestions", () => {
|
||||
|
||||
stream_data.subscribed_streams = () => [];
|
||||
|
||||
narrow_state.stream = () => {};
|
||||
narrow_state.__Rewire__("stream", () => {});
|
||||
|
||||
const suggestions = get_suggestions(base_query, query);
|
||||
|
||||
@@ -114,7 +114,7 @@ run_test("subset_suggestions", () => {
|
||||
run_test("private_suggestions", () => {
|
||||
stream_data.subscribed_streams = () => [];
|
||||
|
||||
narrow_state.stream = () => {};
|
||||
narrow_state.__Rewire__("stream", () => {});
|
||||
|
||||
let query = "is:private";
|
||||
let suggestions = get_suggestions("", query);
|
||||
@@ -231,7 +231,7 @@ run_test("private_suggestions", () => {
|
||||
run_test("group_suggestions", () => {
|
||||
stream_data.subscribed_streams = () => [];
|
||||
|
||||
narrow_state.stream = () => {};
|
||||
narrow_state.__Rewire__("stream", () => {});
|
||||
|
||||
// Entering a comma in a pm-with query should immediately generate
|
||||
// suggestions for the next person.
|
||||
@@ -372,7 +372,7 @@ run_test("empty_query_suggestions", () => {
|
||||
|
||||
stream_data.subscribed_streams = () => ["devel", "office"];
|
||||
|
||||
narrow_state.stream = () => {};
|
||||
narrow_state.__Rewire__("stream", () => {});
|
||||
|
||||
const suggestions = get_suggestions("", query);
|
||||
|
||||
@@ -413,7 +413,7 @@ run_test("has_suggestions", () => {
|
||||
// default suggestion when suggesting `has` operator.
|
||||
let query = "h";
|
||||
stream_data.subscribed_streams = () => ["devel", "office"];
|
||||
narrow_state.stream = () => {};
|
||||
narrow_state.__Rewire__("stream", () => {});
|
||||
|
||||
let suggestions = get_suggestions("", query);
|
||||
let expected = ["h", "has:link", "has:image", "has:attachment"];
|
||||
@@ -467,7 +467,7 @@ run_test("has_suggestions", () => {
|
||||
run_test("check_is_suggestions", () => {
|
||||
let query = "i";
|
||||
stream_data.subscribed_streams = () => ["devel", "office"];
|
||||
narrow_state.stream = () => {};
|
||||
narrow_state.__Rewire__("stream", () => {});
|
||||
|
||||
let suggestions = get_suggestions("", query);
|
||||
let expected = [
|
||||
@@ -571,7 +571,7 @@ run_test("check_is_suggestions", () => {
|
||||
run_test("sent_by_me_suggestions", () => {
|
||||
stream_data.subscribed_streams = () => [];
|
||||
|
||||
narrow_state.stream = () => {};
|
||||
narrow_state.__Rewire__("stream", () => {});
|
||||
|
||||
let query = "";
|
||||
let suggestions = get_suggestions("", query);
|
||||
@@ -650,7 +650,7 @@ run_test("topic_suggestions", () => {
|
||||
|
||||
stream_data.subscribed_streams = () => ["office"];
|
||||
|
||||
narrow_state.stream = () => "office";
|
||||
narrow_state.__Rewire__("stream", () => "office");
|
||||
|
||||
const devel_id = 44;
|
||||
const office_id = 77;
|
||||
@@ -739,7 +739,7 @@ run_test("whitespace_glitch", () => {
|
||||
|
||||
stream_data.subscribed_streams = () => ["office"];
|
||||
|
||||
narrow_state.stream = () => {};
|
||||
narrow_state.__Rewire__("stream", () => {});
|
||||
|
||||
stream_topic_history.reset();
|
||||
|
||||
@@ -753,7 +753,7 @@ run_test("whitespace_glitch", () => {
|
||||
run_test("stream_completion", () => {
|
||||
stream_data.subscribed_streams = () => ["office", "dev help"];
|
||||
|
||||
narrow_state.stream = () => {};
|
||||
narrow_state.__Rewire__("stream", () => {});
|
||||
|
||||
stream_topic_history.reset();
|
||||
|
||||
@@ -775,7 +775,7 @@ run_test("stream_completion", () => {
|
||||
|
||||
function people_suggestion_setup() {
|
||||
stream_data.subscribed_streams = () => [];
|
||||
narrow_state.stream = noop;
|
||||
narrow_state.__Rewire__("stream", noop);
|
||||
|
||||
const ted = {
|
||||
email: "ted@zulip.com",
|
||||
@@ -923,7 +923,7 @@ run_test("operator_suggestions", () => {
|
||||
run_test("queries_with_spaces", () => {
|
||||
stream_data.subscribed_streams = () => ["office", "dev help"];
|
||||
|
||||
narrow_state.stream = () => {};
|
||||
narrow_state.__Rewire__("stream", () => {});
|
||||
|
||||
stream_topic_history.reset();
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ run_test("basic_get_suggestions", () => {
|
||||
|
||||
stream_data.subscribed_streams = () => [];
|
||||
|
||||
narrow_state.stream = () => "office";
|
||||
narrow_state.__Rewire__("stream", () => "office");
|
||||
|
||||
const suggestions = get_suggestions("", query);
|
||||
|
||||
@@ -97,7 +97,7 @@ run_test("subset_suggestions", () => {
|
||||
|
||||
stream_data.subscribed_streams = () => [];
|
||||
|
||||
narrow_state.stream = () => {};
|
||||
narrow_state.__Rewire__("stream", () => {});
|
||||
|
||||
const suggestions = get_suggestions("", query);
|
||||
|
||||
@@ -113,7 +113,7 @@ run_test("subset_suggestions", () => {
|
||||
run_test("private_suggestions", () => {
|
||||
stream_data.subscribed_streams = () => [];
|
||||
|
||||
narrow_state.stream = () => {};
|
||||
narrow_state.__Rewire__("stream", () => {});
|
||||
|
||||
let query = "is:private";
|
||||
let suggestions = get_suggestions("", query);
|
||||
@@ -226,7 +226,7 @@ run_test("private_suggestions", () => {
|
||||
run_test("group_suggestions", () => {
|
||||
stream_data.subscribed_streams = () => [];
|
||||
|
||||
narrow_state.stream = () => {};
|
||||
narrow_state.__Rewire__("stream", () => {});
|
||||
|
||||
// Entering a comma in a pm-with query should immediately generate
|
||||
// suggestions for the next person.
|
||||
@@ -374,7 +374,7 @@ run_test("empty_query_suggestions", () => {
|
||||
|
||||
stream_data.subscribed_streams = () => ["devel", "office"];
|
||||
|
||||
narrow_state.stream = () => {};
|
||||
narrow_state.__Rewire__("stream", () => {});
|
||||
|
||||
const suggestions = get_suggestions("", query);
|
||||
|
||||
@@ -415,7 +415,7 @@ run_test("has_suggestions", () => {
|
||||
// default suggestion when suggesting `has` operator.
|
||||
let query = "h";
|
||||
stream_data.subscribed_streams = () => ["devel", "office"];
|
||||
narrow_state.stream = () => {};
|
||||
narrow_state.__Rewire__("stream", () => {});
|
||||
|
||||
let suggestions = get_suggestions("", query);
|
||||
let expected = ["h", "has:link", "has:image", "has:attachment"];
|
||||
@@ -471,7 +471,7 @@ run_test("has_suggestions", () => {
|
||||
|
||||
run_test("check_is_suggestions", () => {
|
||||
stream_data.subscribed_streams = () => ["devel", "office"];
|
||||
narrow_state.stream = () => {};
|
||||
narrow_state.__Rewire__("stream", () => {});
|
||||
|
||||
let query = "i";
|
||||
let suggestions = get_suggestions("", query);
|
||||
@@ -541,7 +541,7 @@ run_test("check_is_suggestions", () => {
|
||||
run_test("sent_by_me_suggestions", () => {
|
||||
stream_data.subscribed_streams = () => [];
|
||||
|
||||
narrow_state.stream = () => {};
|
||||
narrow_state.__Rewire__("stream", () => {});
|
||||
|
||||
let query = "";
|
||||
let suggestions = get_suggestions("", query);
|
||||
@@ -615,7 +615,7 @@ run_test("topic_suggestions", () => {
|
||||
|
||||
stream_data.subscribed_streams = () => ["office"];
|
||||
|
||||
narrow_state.stream = () => "office";
|
||||
narrow_state.__Rewire__("stream", () => "office");
|
||||
|
||||
const devel_id = 44;
|
||||
const office_id = 77;
|
||||
@@ -710,7 +710,7 @@ run_test("whitespace_glitch", () => {
|
||||
|
||||
stream_data.subscribed_streams = () => ["office"];
|
||||
|
||||
narrow_state.stream = () => {};
|
||||
narrow_state.__Rewire__("stream", () => {});
|
||||
|
||||
stream_topic_history.reset();
|
||||
|
||||
@@ -724,7 +724,7 @@ run_test("whitespace_glitch", () => {
|
||||
run_test("stream_completion", () => {
|
||||
stream_data.subscribed_streams = () => ["office", "dev help"];
|
||||
|
||||
narrow_state.stream = () => {};
|
||||
narrow_state.__Rewire__("stream", () => {});
|
||||
|
||||
stream_topic_history.reset();
|
||||
|
||||
@@ -749,7 +749,7 @@ run_test("people_suggestions", () => {
|
||||
|
||||
stream_data.subscribed_streams = () => [];
|
||||
|
||||
narrow_state.stream = () => {};
|
||||
narrow_state.__Rewire__("stream", () => {});
|
||||
|
||||
const ted = {
|
||||
email: "ted@zulip.com",
|
||||
@@ -863,7 +863,7 @@ run_test("operator_suggestions", () => {
|
||||
run_test("queries_with_spaces", () => {
|
||||
stream_data.subscribed_streams = () => ["office", "dev help"];
|
||||
|
||||
narrow_state.stream = () => {};
|
||||
narrow_state.__Rewire__("stream", () => {});
|
||||
|
||||
stream_topic_history.reset();
|
||||
|
||||
|
||||
@@ -383,12 +383,12 @@ let narrow_state;
|
||||
test_ui("narrowing", () => {
|
||||
initialize_stream_data();
|
||||
|
||||
narrow_state = set_global("narrow_state", {
|
||||
narrow_state = rewiremock("../../static/js/narrow_state").with({
|
||||
stream() {
|
||||
return "devel";
|
||||
},
|
||||
topic: noop,
|
||||
});
|
||||
}).mock.value;
|
||||
|
||||
topic_list.close = noop;
|
||||
topic_list.rebuild = noop;
|
||||
|
||||
@@ -8,9 +8,11 @@ const rewiremock = require("rewiremock/node");
|
||||
const {set_global, zrequire} = require("../zjsunit/namespace");
|
||||
const {run_test} = require("../zjsunit/test");
|
||||
|
||||
const narrow_state = set_global("narrow_state", {
|
||||
const narrow_state = {
|
||||
__esModule: true,
|
||||
topic() {},
|
||||
});
|
||||
};
|
||||
rewiremock("../../static/js/narrow_state").with(narrow_state);
|
||||
set_global("unread", {});
|
||||
const muting = {
|
||||
__esModule: true,
|
||||
|
||||
@@ -116,7 +116,6 @@ zrequire("condense");
|
||||
zrequire("lightbox");
|
||||
zrequire("overlays");
|
||||
zrequire("message_view_header");
|
||||
zrequire("narrow_state");
|
||||
zrequire("presence");
|
||||
zrequire("search_pill_widget");
|
||||
zrequire("unread");
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
const {strict: assert} = require("assert");
|
||||
|
||||
const _ = require("lodash");
|
||||
const rewiremock = require("rewiremock/node");
|
||||
|
||||
const {set_global, zrequire} = require("../zjsunit/namespace");
|
||||
const {run_test} = require("../zjsunit/test");
|
||||
@@ -11,11 +12,13 @@ let page_params = set_global("page_params", {
|
||||
realm_push_notifications_enabled: false,
|
||||
});
|
||||
|
||||
set_global("narrow_state", {});
|
||||
rewiremock("../../static/js/narrow_state").with({});
|
||||
set_global("current_msg_list", {});
|
||||
set_global("home_msg_list", {});
|
||||
const message_store = set_global("message_store", {});
|
||||
|
||||
rewiremock.enable();
|
||||
|
||||
const muting = zrequire("muting");
|
||||
const people = zrequire("people");
|
||||
const stream_data = zrequire("stream_data");
|
||||
@@ -693,3 +696,4 @@ run_test("errors", () => {
|
||||
assert.equal(counts.private_message_count, 0);
|
||||
test_notifiable_count(counts.home_unread_messages, 0);
|
||||
});
|
||||
rewiremock.disable();
|
||||
|
||||
@@ -38,7 +38,7 @@ rewiremock("../../static/js/pm_list").with({
|
||||
update_private_messages() {},
|
||||
});
|
||||
|
||||
set_global("narrow_state", {
|
||||
rewiremock("../../static/js/narrow_state").with({
|
||||
update_email() {},
|
||||
});
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@ const poll_widget = {__esModule: true};
|
||||
rewiremock("../../static/js/poll_widget").with(poll_widget);
|
||||
set_global("document", "document-stub");
|
||||
|
||||
const narrow_state = set_global("narrow_state", {});
|
||||
const narrow_state = {__esModule: true};
|
||||
rewiremock("../../static/js/narrow_state").with(narrow_state);
|
||||
set_global("current_msg_list", {});
|
||||
|
||||
rewiremock.enable();
|
||||
|
||||
@@ -22,7 +22,6 @@ import "../unread";
|
||||
import "../stream_list";
|
||||
import "../widgetize";
|
||||
import "../message_list";
|
||||
import "../narrow_state";
|
||||
import "../narrow";
|
||||
import "../reload_state";
|
||||
import "../reload";
|
||||
|
||||
@@ -9,6 +9,7 @@ const common = require("./common");
|
||||
const compose_pm_pill = require("./compose_pm_pill");
|
||||
const drafts = require("./drafts");
|
||||
const message_viewport = require("./message_viewport");
|
||||
const narrow_state = require("./narrow_state");
|
||||
const people = require("./people");
|
||||
|
||||
exports.blur_compose_inputs = function () {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import * as alert_words from "./alert_words";
|
||||
import * as narrow_state from "./narrow_state";
|
||||
import * as people from "./people";
|
||||
import * as pm_list from "./pm_list";
|
||||
import * as rows from "./rows";
|
||||
|
||||
1
static/js/global.d.ts
vendored
1
static/js/global.d.ts
vendored
@@ -52,7 +52,6 @@ declare let message_scroll: any;
|
||||
declare let message_store: any;
|
||||
declare let message_util: any;
|
||||
declare let narrow: any;
|
||||
declare let narrow_state: any;
|
||||
declare let navigate: any;
|
||||
declare let night_mode: any;
|
||||
declare let notifications: any;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
const narrow_state = require("./narrow_state");
|
||||
const people = require("./people");
|
||||
|
||||
exports.get_hash_category = function (hash) {
|
||||
|
||||
@@ -4,6 +4,7 @@ const alert_words = require("./alert_words");
|
||||
const channel = require("./channel");
|
||||
const huddle_data = require("./huddle_data");
|
||||
const message_edit_history = require("./message_edit_history");
|
||||
const narrow_state = require("./narrow_state");
|
||||
const pm_list = require("./pm_list");
|
||||
const recent_senders = require("./recent_senders");
|
||||
const unread_ui = require("./unread_ui");
|
||||
|
||||
@@ -4,6 +4,7 @@ const autosize = require("autosize");
|
||||
|
||||
const {MessageListData} = require("./message_list_data");
|
||||
const {MessageListView} = require("./message_list_view");
|
||||
const narrow_state = require("./narrow_state");
|
||||
|
||||
exports.narrowed = undefined;
|
||||
exports.set_narrowed = function (value) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import render_recipient_row from "../templates/recipient_row.hbs";
|
||||
import render_single_message from "../templates/single_message.hbs";
|
||||
|
||||
import * as message_viewport from "./message_viewport";
|
||||
import * as narrow_state from "./narrow_state";
|
||||
import * as people from "./people";
|
||||
import * as rendered_markdown from "./rendered_markdown";
|
||||
import * as rows from "./rows";
|
||||
|
||||
@@ -4,6 +4,7 @@ const _ = require("lodash");
|
||||
|
||||
const loading = require("./loading");
|
||||
const message_viewport = require("./message_viewport");
|
||||
const narrow_state = require("./narrow_state");
|
||||
|
||||
let actively_scrolling = false;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
const render_message_view_header = require("../templates/message_view_header.hbs");
|
||||
|
||||
const narrow_state = require("./narrow_state");
|
||||
const peer_data = require("./peer_data");
|
||||
const rendered_markdown = require("./rendered_markdown");
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
const channel = require("./channel");
|
||||
const {Filter} = require("./filter");
|
||||
const {MessageListData} = require("./message_list_data");
|
||||
const narrow_state = require("./narrow_state");
|
||||
const people = require("./people");
|
||||
const search_pill = require("./search_pill");
|
||||
const top_left_corner = require("./top_left_corner");
|
||||
|
||||
@@ -1,52 +1,50 @@
|
||||
"use strict";
|
||||
|
||||
const {Filter} = require("./filter");
|
||||
const people = require("./people");
|
||||
import {Filter} from "./filter";
|
||||
import * as people from "./people";
|
||||
|
||||
let current_filter;
|
||||
|
||||
exports.reset_current_filter = function () {
|
||||
export function reset_current_filter() {
|
||||
current_filter = undefined;
|
||||
};
|
||||
}
|
||||
|
||||
exports.set_current_filter = function (filter) {
|
||||
export function set_current_filter(filter) {
|
||||
current_filter = filter;
|
||||
};
|
||||
}
|
||||
|
||||
exports.active = function () {
|
||||
export function active() {
|
||||
return current_filter !== undefined;
|
||||
};
|
||||
}
|
||||
|
||||
exports.filter = function () {
|
||||
export function filter() {
|
||||
// Both, `All messages` and
|
||||
// `Recent topics` have `current_filter=undefined`
|
||||
return current_filter;
|
||||
};
|
||||
}
|
||||
|
||||
exports.operators = function () {
|
||||
export function operators() {
|
||||
if (current_filter === undefined) {
|
||||
return new Filter(page_params.narrow).operators();
|
||||
}
|
||||
return current_filter.operators();
|
||||
};
|
||||
}
|
||||
|
||||
exports.update_email = function (user_id, new_email) {
|
||||
export function update_email(user_id, new_email) {
|
||||
if (current_filter !== undefined) {
|
||||
current_filter.update_email(user_id, new_email);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/* Operators we should send to the server. */
|
||||
exports.public_operators = function () {
|
||||
export function public_operators() {
|
||||
if (current_filter === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
return current_filter.public_operators();
|
||||
};
|
||||
}
|
||||
|
||||
exports.search_string = function () {
|
||||
return Filter.unparse(exports.operators());
|
||||
};
|
||||
export function search_string() {
|
||||
return Filter.unparse(operators());
|
||||
}
|
||||
|
||||
// Collect operators which appear only once into an object,
|
||||
// and discard those which appear more than once.
|
||||
@@ -73,9 +71,9 @@ function collect_single(operators) {
|
||||
// This logic is here and not in the 'compose' module because
|
||||
// it will get more complicated as we add things to the narrow
|
||||
// operator language.
|
||||
exports.set_compose_defaults = function () {
|
||||
export function set_compose_defaults() {
|
||||
const opts = {};
|
||||
const single = collect_single(exports.operators());
|
||||
const single = collect_single(operators());
|
||||
|
||||
// Set the stream, topic, and/or PM recipient if they are
|
||||
// uniquely specified in the narrow view.
|
||||
@@ -95,9 +93,9 @@ exports.set_compose_defaults = function () {
|
||||
}
|
||||
}
|
||||
return opts;
|
||||
};
|
||||
}
|
||||
|
||||
exports.stream = function () {
|
||||
export function stream() {
|
||||
if (current_filter === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -110,9 +108,9 @@ exports.stream = function () {
|
||||
return stream_data.get_name(name);
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
}
|
||||
|
||||
exports.stream_sub = function () {
|
||||
export function stream_sub() {
|
||||
if (current_filter === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -125,9 +123,9 @@ exports.stream_sub = function () {
|
||||
const sub = stream_data.get_sub_by_name(name);
|
||||
|
||||
return sub;
|
||||
};
|
||||
}
|
||||
|
||||
exports.topic = function () {
|
||||
export function topic() {
|
||||
if (current_filter === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -136,9 +134,9 @@ exports.topic = function () {
|
||||
return operands[0];
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
}
|
||||
|
||||
exports.pm_string = function () {
|
||||
export function pm_string() {
|
||||
// If you are narrowed to a PM conversation
|
||||
// with users 4, 5, and 99, this will return "4,5,99"
|
||||
|
||||
@@ -160,9 +158,9 @@ exports.pm_string = function () {
|
||||
const user_ids_string = people.reply_to_to_user_ids_string(emails_string);
|
||||
|
||||
return user_ids_string;
|
||||
};
|
||||
}
|
||||
|
||||
exports.get_first_unread_info = function () {
|
||||
export function get_first_unread_info() {
|
||||
if (current_filter === undefined) {
|
||||
// we don't yet support the all-messages view
|
||||
blueslip.error("unexpected call to get_first_unread_info");
|
||||
@@ -181,7 +179,7 @@ exports.get_first_unread_info = function () {
|
||||
};
|
||||
}
|
||||
|
||||
const unread_ids = exports._possible_unread_message_ids();
|
||||
const unread_ids = _possible_unread_message_ids();
|
||||
|
||||
if (unread_ids === undefined) {
|
||||
// _possible_unread_message_ids() only works for certain narrows
|
||||
@@ -202,9 +200,9 @@ exports.get_first_unread_info = function () {
|
||||
flavor: "found",
|
||||
msg_id: unread_ids[0],
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
exports._possible_unread_message_ids = function () {
|
||||
export function _possible_unread_message_ids() {
|
||||
// This function currently only returns valid results for
|
||||
// certain types of narrows, mostly left sidebar narrows.
|
||||
// For more complicated narrows we may return undefined.
|
||||
@@ -221,16 +219,16 @@ exports._possible_unread_message_ids = function () {
|
||||
let current_filter_pm_string;
|
||||
|
||||
if (current_filter.can_bucket_by("stream", "topic")) {
|
||||
sub = exports.stream_sub();
|
||||
sub = stream_sub();
|
||||
if (sub === undefined) {
|
||||
return [];
|
||||
}
|
||||
topic_name = exports.topic();
|
||||
topic_name = topic();
|
||||
return unread.get_msg_ids_for_topic(sub.stream_id, topic_name);
|
||||
}
|
||||
|
||||
if (current_filter.can_bucket_by("stream")) {
|
||||
sub = exports.stream_sub();
|
||||
sub = stream_sub();
|
||||
if (sub === undefined) {
|
||||
return [];
|
||||
}
|
||||
@@ -238,7 +236,7 @@ exports._possible_unread_message_ids = function () {
|
||||
}
|
||||
|
||||
if (current_filter.can_bucket_by("pm-with")) {
|
||||
current_filter_pm_string = exports.pm_string();
|
||||
current_filter_pm_string = pm_string();
|
||||
if (current_filter_pm_string === undefined) {
|
||||
return [];
|
||||
}
|
||||
@@ -267,25 +265,25 @@ exports._possible_unread_message_ids = function () {
|
||||
}
|
||||
|
||||
return undefined;
|
||||
};
|
||||
}
|
||||
|
||||
// Are we narrowed to PMs: all PMs or PMs with particular people.
|
||||
exports.narrowed_to_pms = function () {
|
||||
export function narrowed_to_pms() {
|
||||
if (current_filter === undefined) {
|
||||
return false;
|
||||
}
|
||||
return current_filter.has_operator("pm-with") || current_filter.has_operand("is", "private");
|
||||
};
|
||||
}
|
||||
|
||||
exports.narrowed_by_pm_reply = function () {
|
||||
export function narrowed_by_pm_reply() {
|
||||
if (current_filter === undefined) {
|
||||
return false;
|
||||
}
|
||||
const operators = current_filter.operators();
|
||||
return operators.length === 1 && current_filter.has_operator("pm-with");
|
||||
};
|
||||
}
|
||||
|
||||
exports.narrowed_by_topic_reply = function () {
|
||||
export function narrowed_by_topic_reply() {
|
||||
if (current_filter === undefined) {
|
||||
return false;
|
||||
}
|
||||
@@ -295,60 +293,58 @@ exports.narrowed_by_topic_reply = function () {
|
||||
current_filter.operands("stream").length === 1 &&
|
||||
current_filter.operands("topic").length === 1
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
// We auto-reply under certain conditions, namely when you're narrowed
|
||||
// to a PM (or huddle), and when you're narrowed to some stream/topic pair
|
||||
exports.narrowed_by_reply = function () {
|
||||
return exports.narrowed_by_pm_reply() || exports.narrowed_by_topic_reply();
|
||||
};
|
||||
export function narrowed_by_reply() {
|
||||
return narrowed_by_pm_reply() || narrowed_by_topic_reply();
|
||||
}
|
||||
|
||||
exports.narrowed_by_stream_reply = function () {
|
||||
export function narrowed_by_stream_reply() {
|
||||
if (current_filter === undefined) {
|
||||
return false;
|
||||
}
|
||||
const operators = current_filter.operators();
|
||||
return operators.length === 1 && current_filter.operands("stream").length === 1;
|
||||
};
|
||||
}
|
||||
|
||||
exports.narrowed_to_topic = function () {
|
||||
export function narrowed_to_topic() {
|
||||
if (current_filter === undefined) {
|
||||
return false;
|
||||
}
|
||||
return current_filter.has_operator("stream") && current_filter.has_operator("topic");
|
||||
};
|
||||
}
|
||||
|
||||
exports.narrowed_to_search = function () {
|
||||
export function narrowed_to_search() {
|
||||
return current_filter !== undefined && current_filter.is_search();
|
||||
};
|
||||
}
|
||||
|
||||
exports.narrowed_to_starred = function () {
|
||||
export function narrowed_to_starred() {
|
||||
if (current_filter === undefined) {
|
||||
return false;
|
||||
}
|
||||
return current_filter.has_operand("is", "starred");
|
||||
};
|
||||
}
|
||||
|
||||
exports.excludes_muted_topics = function () {
|
||||
export function excludes_muted_topics() {
|
||||
return (
|
||||
!exports.narrowed_to_topic() &&
|
||||
!exports.narrowed_to_search() &&
|
||||
!exports.narrowed_to_pms() &&
|
||||
!exports.narrowed_to_starred()
|
||||
!narrowed_to_topic() &&
|
||||
!narrowed_to_search() &&
|
||||
!narrowed_to_pms() &&
|
||||
!narrowed_to_starred()
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
exports.is_for_stream_id = function (stream_id) {
|
||||
export function is_for_stream_id(stream_id) {
|
||||
// This is not perfect, since we still track narrows by
|
||||
// name, not id, but at least the interface is good going
|
||||
// forward.
|
||||
const narrow_sub = exports.stream_sub();
|
||||
const narrow_sub = stream_sub();
|
||||
|
||||
if (narrow_sub === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return stream_id === narrow_sub.stream_id;
|
||||
};
|
||||
|
||||
window.narrow_state = exports;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ const alert_words = require("./alert_words");
|
||||
const channel = require("./channel");
|
||||
const favicon = require("./favicon");
|
||||
const muting = require("./muting");
|
||||
const narrow_state = require("./narrow_state");
|
||||
const people = require("./people");
|
||||
const settings_config = require("./settings_config");
|
||||
const spoilers = require("./spoilers");
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import * as narrow_state from "./narrow_state";
|
||||
import * as people from "./people";
|
||||
import * as pm_conversations from "./pm_conversations";
|
||||
import * as pm_list_dom from "./pm_list_dom";
|
||||
|
||||
@@ -21,6 +21,7 @@ const message_edit_history = require("./message_edit_history");
|
||||
const message_viewport = require("./message_viewport");
|
||||
const muting = require("./muting");
|
||||
const muting_ui = require("./muting_ui");
|
||||
const narrow_state = require("./narrow_state");
|
||||
const people = require("./people");
|
||||
const rows = require("./rows");
|
||||
const settings_config = require("./settings_config");
|
||||
|
||||
@@ -7,6 +7,7 @@ const render_recent_topics_body = require("../templates/recent_topics_table.hbs"
|
||||
const drafts = require("./drafts");
|
||||
const {localstorage} = require("./localstorage");
|
||||
const muting = require("./muting");
|
||||
const narrow_state = require("./narrow_state");
|
||||
const people = require("./people");
|
||||
const recent_senders = require("./recent_senders");
|
||||
const top_left_corner = require("./top_left_corner");
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const {localstorage} = require("./localstorage");
|
||||
const narrow_state = require("./narrow_state");
|
||||
const util = require("./util");
|
||||
|
||||
// Read https://zulip.readthedocs.io/en/latest/subsystems/hashchange-system.html
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const {Filter} = require("./filter");
|
||||
const narrow_state = require("./narrow_state");
|
||||
const search_pill = require("./search_pill");
|
||||
|
||||
// Exported for unit testing
|
||||
|
||||
@@ -5,6 +5,7 @@ const Handlebars = require("handlebars/runtime");
|
||||
const common = require("./common");
|
||||
const {Filter} = require("./filter");
|
||||
const huddle_data = require("./huddle_data");
|
||||
const narrow_state = require("./narrow_state");
|
||||
const people = require("./people");
|
||||
const settings_data = require("./settings_data");
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import * as emoji from "../shared/js/emoji";
|
||||
|
||||
import * as alert_words from "./alert_words";
|
||||
import * as muting_ui from "./muting_ui";
|
||||
import * as narrow_state from "./narrow_state";
|
||||
import * as peer_data from "./peer_data";
|
||||
import * as people from "./people";
|
||||
import * as settings_config from "./settings_config";
|
||||
|
||||
@@ -7,6 +7,7 @@ const render_subscription_settings = require("../templates/subscription_settings
|
||||
const render_subscription_stream_privacy_modal = require("../templates/subscription_stream_privacy_modal.hbs");
|
||||
|
||||
const channel = require("./channel");
|
||||
const narrow_state = require("./narrow_state");
|
||||
const peer_data = require("./peer_data");
|
||||
const people = require("./people");
|
||||
const pill_typeahead = require("./pill_typeahead");
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
const narrow_state = require("./narrow_state");
|
||||
const peer_data = require("./peer_data");
|
||||
|
||||
// In theory, this function should apply the account-level defaults,
|
||||
|
||||
@@ -7,6 +7,7 @@ const render_stream_sidebar_row = require("../templates/stream_sidebar_row.hbs")
|
||||
|
||||
const keydown_util = require("./keydown_util");
|
||||
const {ListCursor} = require("./list_cursor");
|
||||
const narrow_state = require("./narrow_state");
|
||||
const scroll_util = require("./scroll_util");
|
||||
const stream_sort = require("./stream_sort");
|
||||
const topic_list = require("./topic_list");
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import * as muting from "./muting";
|
||||
import * as narrow_state from "./narrow_state";
|
||||
|
||||
const max_topics = 5;
|
||||
const max_topics_with_unread = 8;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
const render_typing_notifications = require("../templates/typing_notifications.hbs");
|
||||
|
||||
const narrow_state = require("./narrow_state");
|
||||
const people = require("./people");
|
||||
const typing_data = require("./typing_data");
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
// dependencies that existed when this code was in people.js.
|
||||
// (We should do bot updates here too.)
|
||||
const message_live_update = require("./message_live_update");
|
||||
const narrow_state = require("./narrow_state");
|
||||
const people = require("./people");
|
||||
const pm_list = require("./pm_list");
|
||||
const settings_config = require("./settings_config");
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
const narrow_state = require("./narrow_state");
|
||||
const poll_widget = require("./poll_widget");
|
||||
const todo_widget = require("./todo_widget");
|
||||
const zform = require("./zform");
|
||||
|
||||
Reference in New Issue
Block a user