mirror of https://github.com/zulip/zulip.git
narrow: Rename to `message_view`.
This brings it in sync with other libraries like `message_list` and `message_list_data`.
This commit is contained in:
parent
48cdfd25f7
commit
f58c586bee
|
@ -149,12 +149,12 @@ EXEMPT_FILES = make_set(
|
||||||
"web/src/message_scroll.js",
|
"web/src/message_scroll.js",
|
||||||
"web/src/message_scroll_state.ts",
|
"web/src/message_scroll_state.ts",
|
||||||
"web/src/message_util.ts",
|
"web/src/message_util.ts",
|
||||||
|
"web/src/message_view.js",
|
||||||
"web/src/message_view_header.ts",
|
"web/src/message_view_header.ts",
|
||||||
"web/src/message_viewport.ts",
|
"web/src/message_viewport.ts",
|
||||||
"web/src/messages_overlay_ui.ts",
|
"web/src/messages_overlay_ui.ts",
|
||||||
"web/src/modals.ts",
|
"web/src/modals.ts",
|
||||||
"web/src/muted_users_ui.ts",
|
"web/src/muted_users_ui.ts",
|
||||||
"web/src/narrow.js",
|
|
||||||
"web/src/narrow_history.ts",
|
"web/src/narrow_history.ts",
|
||||||
"web/src/narrow_title.ts",
|
"web/src/narrow_title.ts",
|
||||||
"web/src/navbar_alerts.ts",
|
"web/src/navbar_alerts.ts",
|
||||||
|
|
|
@ -20,7 +20,7 @@ import * as hashchange from "./hashchange";
|
||||||
import * as message_edit from "./message_edit";
|
import * as message_edit from "./message_edit";
|
||||||
import * as message_lists from "./message_lists";
|
import * as message_lists from "./message_lists";
|
||||||
import * as message_store from "./message_store";
|
import * as message_store from "./message_store";
|
||||||
import * as narrow from "./narrow";
|
import * as message_view from "./message_view";
|
||||||
import * as narrow_state from "./narrow_state";
|
import * as narrow_state from "./narrow_state";
|
||||||
import * as navigate from "./navigate";
|
import * as navigate from "./navigate";
|
||||||
import {page_params} from "./page_params";
|
import {page_params} from "./page_params";
|
||||||
|
@ -474,7 +474,7 @@ export function initialize() {
|
||||||
}
|
}
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const row_id = get_row_id_for_narrowing(this);
|
const row_id = get_row_id_for_narrowing(this);
|
||||||
narrow.narrow_by_recipient(row_id, {trigger: "message header"});
|
message_view.narrow_by_recipient(row_id, {trigger: "message header"});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#message_feed_container").on("click", ".narrows_by_topic", function (e) {
|
$("#message_feed_container").on("click", ".narrows_by_topic", function (e) {
|
||||||
|
@ -483,7 +483,7 @@ export function initialize() {
|
||||||
}
|
}
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const row_id = get_row_id_for_narrowing(this);
|
const row_id = get_row_id_for_narrowing(this);
|
||||||
narrow.narrow_by_topic(row_id, {trigger: "message header"});
|
message_view.narrow_by_topic(row_id, {trigger: "message header"});
|
||||||
});
|
});
|
||||||
|
|
||||||
// SIDEBARS
|
// SIDEBARS
|
||||||
|
|
|
@ -17,7 +17,7 @@ import * as dialog_widget from "./dialog_widget";
|
||||||
import * as flatpickr from "./flatpickr";
|
import * as flatpickr from "./flatpickr";
|
||||||
import {$t_html} from "./i18n";
|
import {$t_html} from "./i18n";
|
||||||
import * as message_edit from "./message_edit";
|
import * as message_edit from "./message_edit";
|
||||||
import * as narrow from "./narrow";
|
import * as message_view from "./message_view";
|
||||||
import * as onboarding_steps from "./onboarding_steps";
|
import * as onboarding_steps from "./onboarding_steps";
|
||||||
import {page_params} from "./page_params";
|
import {page_params} from "./page_params";
|
||||||
import * as poll_modal from "./poll_modal";
|
import * as poll_modal from "./poll_modal";
|
||||||
|
@ -283,7 +283,7 @@ export function initialize() {
|
||||||
`.${CSS.escape(compose_banner.CLASSNAMES.search_view)} .main-view-banner-action-button`,
|
`.${CSS.escape(compose_banner.CLASSNAMES.search_view)} .main-view-banner-action-button`,
|
||||||
(event) => {
|
(event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
narrow.to_compose_target();
|
message_view.to_compose_target();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -440,7 +440,7 @@ export function initialize() {
|
||||||
|
|
||||||
$("#compose").on("click", ".narrow_to_compose_recipients", (e) => {
|
$("#compose").on("click", ".narrow_to_compose_recipients", (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
narrow.to_compose_target();
|
message_view.to_compose_target();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#compose").on("click", ".collapse_composebox_button", (e) => {
|
$("#compose").on("click", ".collapse_composebox_button", (e) => {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import * as channel from "./channel";
|
||||||
import * as feedback_widget from "./feedback_widget";
|
import * as feedback_widget from "./feedback_widget";
|
||||||
import {$t} from "./i18n";
|
import {$t} from "./i18n";
|
||||||
import * as message_store from "./message_store";
|
import * as message_store from "./message_store";
|
||||||
import * as narrow from "./narrow";
|
import * as message_view from "./message_view";
|
||||||
import * as stream_data from "./stream_data";
|
import * as stream_data from "./stream_data";
|
||||||
|
|
||||||
export function initialize() {
|
export function initialize() {
|
||||||
|
@ -27,7 +27,7 @@ export function initialize() {
|
||||||
|
|
||||||
// The code below is for sending a message received from notification reply which
|
// The code below is for sending a message received from notification reply which
|
||||||
// is often referred to as inline reply feature. This is done so desktop app doesn't
|
// is often referred to as inline reply feature. This is done so desktop app doesn't
|
||||||
// have to depend on channel.post for setting crsf_token and narrow.narrow_by_topic
|
// have to depend on channel.post for setting crsf_token and message_view.narrow_by_topic
|
||||||
// to narrow to the message being sent.
|
// to narrow to the message being sent.
|
||||||
if (window.electron_bridge.set_send_notification_reply_message_supported !== undefined) {
|
if (window.electron_bridge.set_send_notification_reply_message_supported !== undefined) {
|
||||||
window.electron_bridge.set_send_notification_reply_message_supported(true);
|
window.electron_bridge.set_send_notification_reply_message_supported(true);
|
||||||
|
@ -47,9 +47,11 @@ export function initialize() {
|
||||||
|
|
||||||
function success() {
|
function success() {
|
||||||
if (message.type === "stream") {
|
if (message.type === "stream") {
|
||||||
narrow.narrow_by_topic(message_id, {trigger: "desktop_notification_reply"});
|
message_view.narrow_by_topic(message_id, {trigger: "desktop_notification_reply"});
|
||||||
} else {
|
} else {
|
||||||
narrow.narrow_by_recipient(message_id, {trigger: "desktop_notification_reply"});
|
message_view.narrow_by_recipient(message_id, {
|
||||||
|
trigger: "desktop_notification_reply",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,8 @@ import * as browser_history from "./browser_history";
|
||||||
import * as compose_actions from "./compose_actions";
|
import * as compose_actions from "./compose_actions";
|
||||||
import * as drafts from "./drafts";
|
import * as drafts from "./drafts";
|
||||||
import {$t} from "./i18n";
|
import {$t} from "./i18n";
|
||||||
|
import * as message_view from "./message_view";
|
||||||
import * as messages_overlay_ui from "./messages_overlay_ui";
|
import * as messages_overlay_ui from "./messages_overlay_ui";
|
||||||
import * as narrow from "./narrow";
|
|
||||||
import * as overlays from "./overlays";
|
import * as overlays from "./overlays";
|
||||||
import * as people from "./people";
|
import * as people from "./people";
|
||||||
import * as rendered_markdown from "./rendered_markdown";
|
import * as rendered_markdown from "./rendered_markdown";
|
||||||
|
@ -24,7 +24,7 @@ function restore_draft(draft_id) {
|
||||||
|
|
||||||
if (compose_args.type === "stream") {
|
if (compose_args.type === "stream") {
|
||||||
if (draft.stream_id !== undefined && draft.topic !== "") {
|
if (draft.stream_id !== undefined && draft.topic !== "") {
|
||||||
narrow.show(
|
message_view.show(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
operator: "channel",
|
operator: "channel",
|
||||||
|
@ -37,7 +37,7 @@ function restore_draft(draft_id) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (compose_args.private_message_recipient !== "") {
|
if (compose_args.private_message_recipient !== "") {
|
||||||
narrow.show([{operator: "dm", operand: compose_args.private_message_recipient}], {
|
message_view.show([{operator: "dm", operand: compose_args.private_message_recipient}], {
|
||||||
trigger: "restore draft",
|
trigger: "restore draft",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,9 +12,9 @@ import * as inbox_ui from "./inbox_ui";
|
||||||
import * as inbox_util from "./inbox_util";
|
import * as inbox_util from "./inbox_util";
|
||||||
import * as info_overlay from "./info_overlay";
|
import * as info_overlay from "./info_overlay";
|
||||||
import * as message_fetch from "./message_fetch";
|
import * as message_fetch from "./message_fetch";
|
||||||
|
import * as message_view from "./message_view";
|
||||||
import * as message_viewport from "./message_viewport";
|
import * as message_viewport from "./message_viewport";
|
||||||
import * as modals from "./modals";
|
import * as modals from "./modals";
|
||||||
import * as narrow from "./narrow";
|
|
||||||
import * as overlays from "./overlays";
|
import * as overlays from "./overlays";
|
||||||
import {page_params} from "./page_params";
|
import {page_params} from "./page_params";
|
||||||
import * as people from "./people";
|
import * as people from "./people";
|
||||||
|
@ -57,7 +57,7 @@ function show_all_message_view() {
|
||||||
// Don't export this function outside of this module since
|
// Don't export this function outside of this module since
|
||||||
// `change_hash` is false here which means it is should only
|
// `change_hash` is false here which means it is should only
|
||||||
// be called after hash is updated in the URL.
|
// be called after hash is updated in the URL.
|
||||||
narrow.show([{operator: "in", operand: "home"}], {
|
message_view.show([{operator: "in", operand: "home"}], {
|
||||||
trigger: "hashchange",
|
trigger: "hashchange",
|
||||||
change_hash: false,
|
change_hash: false,
|
||||||
then_select_id: history.state?.narrow_pointer,
|
then_select_id: history.state?.narrow_pointer,
|
||||||
|
@ -198,7 +198,7 @@ function do_hashchange_normal(from_reload) {
|
||||||
narrow_opts.then_select_offset = data_for_hash.narrow_offset;
|
narrow_opts.then_select_offset = data_for_hash.narrow_offset;
|
||||||
narrow_opts.show_more_topics = data_for_hash.show_more_topics ?? false;
|
narrow_opts.show_more_topics = data_for_hash.show_more_topics ?? false;
|
||||||
}
|
}
|
||||||
narrow.show(terms, narrow_opts);
|
message_view.show(terms, narrow_opts);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "":
|
case "":
|
||||||
|
|
|
@ -32,8 +32,8 @@ import * as message_edit from "./message_edit";
|
||||||
import * as message_edit_history from "./message_edit_history";
|
import * as message_edit_history from "./message_edit_history";
|
||||||
import * as message_lists from "./message_lists";
|
import * as message_lists from "./message_lists";
|
||||||
import * as message_scroll_state from "./message_scroll_state";
|
import * as message_scroll_state from "./message_scroll_state";
|
||||||
|
import * as message_view from "./message_view";
|
||||||
import * as modals from "./modals";
|
import * as modals from "./modals";
|
||||||
import * as narrow from "./narrow";
|
|
||||||
import * as narrow_state from "./narrow_state";
|
import * as narrow_state from "./narrow_state";
|
||||||
import * as navbar_menus from "./navbar_menus";
|
import * as navbar_menus from "./navbar_menus";
|
||||||
import * as navigate from "./navigate";
|
import * as navigate from "./navigate";
|
||||||
|
@ -832,7 +832,7 @@ export function process_hotkey(e, hotkey) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event_name === "narrow_to_compose_target") {
|
if (event_name === "narrow_to_compose_target") {
|
||||||
narrow.to_compose_target();
|
message_view.to_compose_target();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -925,7 +925,7 @@ export function process_hotkey(e, hotkey) {
|
||||||
// Shortcuts that don't require a message
|
// Shortcuts that don't require a message
|
||||||
switch (event_name) {
|
switch (event_name) {
|
||||||
case "narrow_private":
|
case "narrow_private":
|
||||||
narrow.show(
|
message_view.show(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
operator: "is",
|
operator: "is",
|
||||||
|
@ -952,19 +952,19 @@ export function process_hotkey(e, hotkey) {
|
||||||
browser_history.go_to_location("keyboard-shortcuts");
|
browser_history.go_to_location("keyboard-shortcuts");
|
||||||
return true;
|
return true;
|
||||||
case "stream_cycle_backward":
|
case "stream_cycle_backward":
|
||||||
narrow.stream_cycle_backward();
|
message_view.stream_cycle_backward();
|
||||||
return true;
|
return true;
|
||||||
case "stream_cycle_forward":
|
case "stream_cycle_forward":
|
||||||
narrow.stream_cycle_forward();
|
message_view.stream_cycle_forward();
|
||||||
return true;
|
return true;
|
||||||
case "n_key":
|
case "n_key":
|
||||||
narrow.narrow_to_next_topic({trigger: "hotkey", only_followed_topics: false});
|
message_view.narrow_to_next_topic({trigger: "hotkey", only_followed_topics: false});
|
||||||
return true;
|
return true;
|
||||||
case "narrow_to_next_unread_followed_topic":
|
case "narrow_to_next_unread_followed_topic":
|
||||||
narrow.narrow_to_next_topic({trigger: "hotkey", only_followed_topics: true});
|
message_view.narrow_to_next_topic({trigger: "hotkey", only_followed_topics: true});
|
||||||
return true;
|
return true;
|
||||||
case "p_key":
|
case "p_key":
|
||||||
narrow.narrow_to_next_pm_string({trigger: "hotkey"});
|
message_view.narrow_to_next_pm_string({trigger: "hotkey"});
|
||||||
return true;
|
return true;
|
||||||
case "open_recent_view":
|
case "open_recent_view":
|
||||||
browser_history.go_to_location("#recent");
|
browser_history.go_to_location("#recent");
|
||||||
|
@ -1091,13 +1091,13 @@ export function process_hotkey(e, hotkey) {
|
||||||
case "toggle_conversation_view":
|
case "toggle_conversation_view":
|
||||||
if (narrow_state.narrowed_by_topic_reply()) {
|
if (narrow_state.narrowed_by_topic_reply()) {
|
||||||
// narrow to stream if user is in topic view
|
// narrow to stream if user is in topic view
|
||||||
return do_narrow_action(narrow.narrow_by_recipient);
|
return do_narrow_action(message_view.narrow_by_recipient);
|
||||||
} else if (narrow_state.narrowed_by_pm_reply()) {
|
} else if (narrow_state.narrowed_by_pm_reply()) {
|
||||||
// do nothing if user is in DM view
|
// do nothing if user is in DM view
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// else narrow to conversation view (topic / DM)
|
// else narrow to conversation view (topic / DM)
|
||||||
return do_narrow_action(narrow.narrow_by_topic);
|
return do_narrow_action(message_view.narrow_by_topic);
|
||||||
case "toggle_stream_subscription":
|
case "toggle_stream_subscription":
|
||||||
deprecated_feature_notice.maybe_show_deprecation_notice("Shift + S");
|
deprecated_feature_notice.maybe_show_deprecation_notice("Shift + S");
|
||||||
return true;
|
return true;
|
||||||
|
@ -1194,10 +1194,10 @@ export function process_hotkey(e, hotkey) {
|
||||||
case "zoom_to_message_near": {
|
case "zoom_to_message_near": {
|
||||||
// The following code is essentially equivalent to
|
// The following code is essentially equivalent to
|
||||||
// `window.location = hashutil.by_conversation_and_time_url(msg)`
|
// `window.location = hashutil.by_conversation_and_time_url(msg)`
|
||||||
// but we use `narrow.show` to pass in the `trigger` parameter
|
// but we use `message_view.show` to pass in the `trigger` parameter
|
||||||
switch (msg.type) {
|
switch (msg.type) {
|
||||||
case "private":
|
case "private":
|
||||||
narrow.show(
|
message_view.show(
|
||||||
[
|
[
|
||||||
{operator: "dm", operand: msg.reply_to},
|
{operator: "dm", operand: msg.reply_to},
|
||||||
{operator: "near", operand: msg.id},
|
{operator: "near", operand: msg.id},
|
||||||
|
@ -1206,7 +1206,7 @@ export function process_hotkey(e, hotkey) {
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
case "stream":
|
case "stream":
|
||||||
narrow.show(
|
message_view.show(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
operator: "channel",
|
operator: "channel",
|
||||||
|
|
|
@ -18,7 +18,7 @@ import * as message_lists from "./message_lists";
|
||||||
import * as message_notifications from "./message_notifications";
|
import * as message_notifications from "./message_notifications";
|
||||||
import * as message_store from "./message_store";
|
import * as message_store from "./message_store";
|
||||||
import * as message_util from "./message_util";
|
import * as message_util from "./message_util";
|
||||||
import * as narrow from "./narrow";
|
import * as message_view from "./message_view";
|
||||||
import * as narrow_state from "./narrow_state";
|
import * as narrow_state from "./narrow_state";
|
||||||
import * as pm_list from "./pm_list";
|
import * as pm_list from "./pm_list";
|
||||||
import * as recent_senders from "./recent_senders";
|
import * as recent_senders from "./recent_senders";
|
||||||
|
@ -152,7 +152,7 @@ export function insert_new_messages(messages, sent_by_this_client) {
|
||||||
if (sent_by_this_client) {
|
if (sent_by_this_client) {
|
||||||
compose_notifications.notify_local_mixes(messages, need_user_to_scroll, {
|
compose_notifications.notify_local_mixes(messages, need_user_to_scroll, {
|
||||||
narrow_to_recipient(message_id) {
|
narrow_to_recipient(message_id) {
|
||||||
narrow.narrow_by_topic(message_id, {trigger: "outside_current_view"});
|
message_view.narrow_by_topic(message_id, {trigger: "outside_current_view"});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -429,7 +429,7 @@ export function update_messages(events) {
|
||||||
trigger: "stream/topic change",
|
trigger: "stream/topic change",
|
||||||
then_select_id: current_selected_id,
|
then_select_id: current_selected_id,
|
||||||
};
|
};
|
||||||
narrow.show(terms, opts);
|
message_view.show(terms, opts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import * as blueslip from "./blueslip";
|
||||||
import * as desktop_notifications from "./desktop_notifications";
|
import * as desktop_notifications from "./desktop_notifications";
|
||||||
import {$t} from "./i18n";
|
import {$t} from "./i18n";
|
||||||
import * as message_parser from "./message_parser";
|
import * as message_parser from "./message_parser";
|
||||||
import * as narrow from "./narrow";
|
import * as message_view from "./message_view";
|
||||||
import * as people from "./people";
|
import * as people from "./people";
|
||||||
import * as spoilers from "./spoilers";
|
import * as spoilers from "./spoilers";
|
||||||
import * as stream_data from "./stream_data";
|
import * as stream_data from "./stream_data";
|
||||||
|
@ -162,7 +162,7 @@ export function process_notification(notification) {
|
||||||
notification_object.addEventListener("click", () => {
|
notification_object.addEventListener("click", () => {
|
||||||
notification_object.close();
|
notification_object.close();
|
||||||
if (message.type !== "test-notification") {
|
if (message.type !== "test-notification") {
|
||||||
narrow.narrow_by_topic(message.id, {trigger: "notification"});
|
message_view.narrow_by_topic(message.id, {trigger: "notification"});
|
||||||
}
|
}
|
||||||
window.focus();
|
window.focus();
|
||||||
});
|
});
|
||||||
|
|
|
@ -171,7 +171,7 @@ function create_and_update_message_list(filter, id_info, opts) {
|
||||||
//
|
//
|
||||||
// It's fine for the hash change to happen anytime before updating
|
// It's fine for the hash change to happen anytime before updating
|
||||||
// the current message list as we are trying to emulate the `hashchange`
|
// the current message list as we are trying to emulate the `hashchange`
|
||||||
// workflow we have which calls `narrow.show` after hash is updated.
|
// workflow we have which calls `message_view.show` after hash is updated.
|
||||||
if (opts.change_hash) {
|
if (opts.change_hash) {
|
||||||
update_hash_to_match_filter(filter, opts.trigger);
|
update_hash_to_match_filter(filter, opts.trigger);
|
||||||
opts.show_more_topics = history.state?.show_more_topics ?? false;
|
opts.show_more_topics = history.state?.show_more_topics ?? false;
|
||||||
|
@ -276,7 +276,7 @@ export function show(raw_terms, opts) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Since narrow.show is called directly from various
|
// Since message_view.show is called directly from various
|
||||||
// places in our code without passing through hashchange,
|
// places in our code without passing through hashchange,
|
||||||
// we need to check if the narrow is allowed for spectator here too.
|
// we need to check if the narrow is allowed for spectator here too.
|
||||||
if (
|
if (
|
||||||
|
@ -456,7 +456,7 @@ export function show(raw_terms, opts) {
|
||||||
success(data) {
|
success(data) {
|
||||||
// After the message is fetched, we make the
|
// After the message is fetched, we make the
|
||||||
// message locally available and then call
|
// message locally available and then call
|
||||||
// narrow.show recursively, setting a flag to
|
// message_view.show recursively, setting a flag to
|
||||||
// indicate we've already done this.
|
// indicate we've already done this.
|
||||||
message_helper.process_new_message(data.message);
|
message_helper.process_new_message(data.message);
|
||||||
show(raw_terms, {
|
show(raw_terms, {
|
||||||
|
@ -470,7 +470,7 @@ export function show(raw_terms, opts) {
|
||||||
// happen, for example, if a user types
|
// happen, for example, if a user types
|
||||||
// `stream:foo topic:bar near:1` into the search
|
// `stream:foo topic:bar near:1` into the search
|
||||||
// box. No special rewriting is required, so call
|
// box. No special rewriting is required, so call
|
||||||
// narrow.show recursively.
|
// message_view.show recursively.
|
||||||
show(raw_terms, {
|
show(raw_terms, {
|
||||||
fetched_target_message: true,
|
fetched_target_message: true,
|
||||||
...opts,
|
...opts,
|
||||||
|
@ -478,7 +478,7 @@ export function show(raw_terms, opts) {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// The channel.get will call narrow.show recursively
|
// The channel.get will call message_view.show recursively
|
||||||
// from a continuation unconditionally; the correct thing
|
// from a continuation unconditionally; the correct thing
|
||||||
// to do here is return.
|
// to do here is return.
|
||||||
return;
|
return;
|
||||||
|
@ -487,7 +487,7 @@ export function show(raw_terms, opts) {
|
||||||
|
|
||||||
// IMPORTANT: No code that modifies UI state should appear above
|
// IMPORTANT: No code that modifies UI state should appear above
|
||||||
// this point. This is important to prevent calling such functions
|
// this point. This is important to prevent calling such functions
|
||||||
// more than once in the event that we call narrow.show
|
// more than once in the event that we call message_view.show.
|
||||||
// recursively.
|
// recursively.
|
||||||
reset_ui_state(opts);
|
reset_ui_state(opts);
|
||||||
|
|
|
@ -4,7 +4,7 @@ import * as tippy from "tippy.js";
|
||||||
import render_navbar_personal_menu_popover from "../templates/popovers/navbar/navbar_personal_menu_popover.hbs";
|
import render_navbar_personal_menu_popover from "../templates/popovers/navbar/navbar_personal_menu_popover.hbs";
|
||||||
|
|
||||||
import * as channel from "./channel";
|
import * as channel from "./channel";
|
||||||
import * as narrow from "./narrow";
|
import * as message_view from "./message_view";
|
||||||
import * as people from "./people";
|
import * as people from "./people";
|
||||||
import * as popover_menus from "./popover_menus";
|
import * as popover_menus from "./popover_menus";
|
||||||
import * as popover_menus_data from "./popover_menus_data";
|
import * as popover_menus_data from "./popover_menus_data";
|
||||||
|
@ -79,7 +79,7 @@ export function initialize() {
|
||||||
$popper.one("click", ".narrow-self-direct-message", (e) => {
|
$popper.one("click", ".narrow-self-direct-message", (e) => {
|
||||||
const user_id = current_user.user_id;
|
const user_id = current_user.user_id;
|
||||||
const email = people.get_by_user_id(user_id).email;
|
const email = people.get_by_user_id(user_id).email;
|
||||||
narrow.show(
|
message_view.show(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
operator: "dm",
|
operator: "dm",
|
||||||
|
@ -95,7 +95,7 @@ export function initialize() {
|
||||||
$popper.one("click", ".narrow-messages-sent", (e) => {
|
$popper.one("click", ".narrow-messages-sent", (e) => {
|
||||||
const user_id = current_user.user_id;
|
const user_id = current_user.user_id;
|
||||||
const email = people.get_by_user_id(user_id).email;
|
const email = people.get_by_user_id(user_id).email;
|
||||||
narrow.show(
|
message_view.show(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
operator: "sender",
|
operator: "sender",
|
||||||
|
|
|
@ -4,7 +4,7 @@ import * as compose from "./compose";
|
||||||
import * as compose_actions from "./compose_actions";
|
import * as compose_actions from "./compose_actions";
|
||||||
import {localstorage} from "./localstorage";
|
import {localstorage} from "./localstorage";
|
||||||
import * as message_fetch from "./message_fetch";
|
import * as message_fetch from "./message_fetch";
|
||||||
import * as narrow from "./narrow";
|
import * as message_view from "./message_view";
|
||||||
|
|
||||||
// Check if we're doing a compose-preserving reload. This must be
|
// Check if we're doing a compose-preserving reload. This must be
|
||||||
// done before the first call to get_events
|
// done before the first call to get_events
|
||||||
|
@ -28,7 +28,7 @@ export function initialize() {
|
||||||
// exist, but be log it so that it's available for future
|
// exist, but be log it so that it's available for future
|
||||||
// debugging if an exception happens later.
|
// debugging if an exception happens later.
|
||||||
blueslip.info("Invalid hash change reload token");
|
blueslip.info("Invalid hash change reload token");
|
||||||
narrow.changehash("", trigger);
|
message_view.changehash("", trigger);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ls.remove(hash_fragment);
|
ls.remove(hash_fragment);
|
||||||
|
@ -83,5 +83,5 @@ export function initialize() {
|
||||||
});
|
});
|
||||||
|
|
||||||
activity.set_new_user_input(false);
|
activity.set_new_user_input(false);
|
||||||
narrow.changehash(vars.oldhash, trigger);
|
message_view.changehash(vars.oldhash, trigger);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import render_compose_banner from "../templates/compose_banner/compose_banner.hb
|
||||||
import * as compose_actions from "./compose_actions";
|
import * as compose_actions from "./compose_actions";
|
||||||
import * as compose_banner from "./compose_banner";
|
import * as compose_banner from "./compose_banner";
|
||||||
import {$t} from "./i18n";
|
import {$t} from "./i18n";
|
||||||
import * as narrow from "./narrow";
|
import * as message_view from "./message_view";
|
||||||
import * as people from "./people";
|
import * as people from "./people";
|
||||||
import * as scheduled_messages from "./scheduled_messages";
|
import * as scheduled_messages from "./scheduled_messages";
|
||||||
import * as stream_data from "./stream_data";
|
import * as stream_data from "./stream_data";
|
||||||
|
@ -19,7 +19,7 @@ export function hide_scheduled_message_success_compose_banner(scheduled_message_
|
||||||
|
|
||||||
function narrow_via_edit_scheduled_message(compose_args) {
|
function narrow_via_edit_scheduled_message(compose_args) {
|
||||||
if (compose_args.message_type === "stream") {
|
if (compose_args.message_type === "stream") {
|
||||||
narrow.show(
|
message_view.show(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
operator: "channel",
|
operator: "channel",
|
||||||
|
@ -30,7 +30,7 @@ function narrow_via_edit_scheduled_message(compose_args) {
|
||||||
{trigger: "edit scheduled message"},
|
{trigger: "edit scheduled message"},
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
narrow.show([{operator: "dm", operand: compose_args.private_message_recipient}], {
|
message_view.show([{operator: "dm", operand: compose_args.private_message_recipient}], {
|
||||||
trigger: "edit scheduled message",
|
trigger: "edit scheduled message",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import * as channel from "./channel";
|
import * as channel from "./channel";
|
||||||
import * as narrow from "./narrow";
|
import * as message_view from "./message_view";
|
||||||
import {page_params} from "./page_params";
|
import {page_params} from "./page_params";
|
||||||
|
|
||||||
function set_tutorial_status(status, callback) {
|
function set_tutorial_status(status, callback) {
|
||||||
|
@ -13,7 +13,7 @@ function set_tutorial_status(status, callback) {
|
||||||
export function initialize() {
|
export function initialize() {
|
||||||
if (page_params.needs_tutorial) {
|
if (page_params.needs_tutorial) {
|
||||||
set_tutorial_status("started");
|
set_tutorial_status("started");
|
||||||
narrow.show(
|
message_view.show(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
operator: "is",
|
operator: "is",
|
||||||
|
|
|
@ -67,11 +67,11 @@ import * as message_list_hover from "./message_list_hover";
|
||||||
import * as message_list_tooltips from "./message_list_tooltips";
|
import * as message_list_tooltips from "./message_list_tooltips";
|
||||||
import * as message_lists from "./message_lists";
|
import * as message_lists from "./message_lists";
|
||||||
import * as message_scroll from "./message_scroll";
|
import * as message_scroll from "./message_scroll";
|
||||||
|
import * as message_view from "./message_view";
|
||||||
import * as message_view_header from "./message_view_header";
|
import * as message_view_header from "./message_view_header";
|
||||||
import * as message_viewport from "./message_viewport";
|
import * as message_viewport from "./message_viewport";
|
||||||
import * as modals from "./modals";
|
import * as modals from "./modals";
|
||||||
import * as muted_users from "./muted_users";
|
import * as muted_users from "./muted_users";
|
||||||
import * as narrow from "./narrow";
|
|
||||||
import * as narrow_history from "./narrow_history";
|
import * as narrow_history from "./narrow_history";
|
||||||
import * as narrow_state from "./narrow_state";
|
import * as narrow_state from "./narrow_state";
|
||||||
import * as narrow_title from "./narrow_title";
|
import * as narrow_title from "./narrow_title";
|
||||||
|
@ -774,7 +774,7 @@ export function initialize_everything(state_data) {
|
||||||
const sub = sub_store.get(stream_id);
|
const sub = sub_store.get(stream_id);
|
||||||
sidebar_ui.hide_all();
|
sidebar_ui.hide_all();
|
||||||
popovers.hide_all();
|
popovers.hide_all();
|
||||||
narrow.show(
|
message_view.show(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
operator: "stream",
|
operator: "stream",
|
||||||
|
@ -832,14 +832,14 @@ export function initialize_everything(state_data) {
|
||||||
compose_textarea.initialize();
|
compose_textarea.initialize();
|
||||||
upload.initialize();
|
upload.initialize();
|
||||||
search.initialize({
|
search.initialize({
|
||||||
on_narrow_search: narrow.show,
|
on_narrow_search: message_view.show,
|
||||||
});
|
});
|
||||||
desktop_notifications.initialize();
|
desktop_notifications.initialize();
|
||||||
audible_notifications.initialize();
|
audible_notifications.initialize();
|
||||||
compose_notifications.initialize({
|
compose_notifications.initialize({
|
||||||
on_click_scroll_to_selected: message_viewport.scroll_to_selected,
|
on_click_scroll_to_selected: message_viewport.scroll_to_selected,
|
||||||
on_narrow_to_recipient(message_id) {
|
on_narrow_to_recipient(message_id) {
|
||||||
narrow.narrow_by_topic(message_id, {trigger: "compose_notification"});
|
message_view.narrow_by_topic(message_id, {trigger: "compose_notification"});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
unread_ops.initialize();
|
unread_ops.initialize();
|
||||||
|
@ -859,7 +859,7 @@ export function initialize_everything(state_data) {
|
||||||
activity.initialize();
|
activity.initialize();
|
||||||
activity_ui.initialize({
|
activity_ui.initialize({
|
||||||
narrow_by_email(email) {
|
narrow_by_email(email) {
|
||||||
narrow.show(
|
message_view.show(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
operator: "dm",
|
operator: "dm",
|
||||||
|
@ -886,7 +886,7 @@ export function initialize_everything(state_data) {
|
||||||
topic_list.initialize({
|
topic_list.initialize({
|
||||||
on_topic_click(stream_id, topic) {
|
on_topic_click(stream_id, topic) {
|
||||||
const sub = sub_store.get(stream_id);
|
const sub = sub_store.get(stream_id);
|
||||||
narrow.show(
|
message_view.show(
|
||||||
[
|
[
|
||||||
{operator: "channel", operand: sub.name},
|
{operator: "channel", operand: sub.name},
|
||||||
{operator: "topic", operand: topic},
|
{operator: "topic", operand: topic},
|
||||||
|
|
|
@ -24,8 +24,8 @@ import * as dialog_widget from "./dialog_widget";
|
||||||
import * as hash_util from "./hash_util";
|
import * as hash_util from "./hash_util";
|
||||||
import {$t, $t_html} from "./i18n";
|
import {$t, $t_html} from "./i18n";
|
||||||
import * as message_lists from "./message_lists";
|
import * as message_lists from "./message_lists";
|
||||||
|
import * as message_view from "./message_view";
|
||||||
import * as muted_users from "./muted_users";
|
import * as muted_users from "./muted_users";
|
||||||
import * as narrow from "./narrow";
|
|
||||||
import * as overlays from "./overlays";
|
import * as overlays from "./overlays";
|
||||||
import {page_params} from "./page_params";
|
import {page_params} from "./page_params";
|
||||||
import * as people from "./people";
|
import * as people from "./people";
|
||||||
|
@ -688,7 +688,7 @@ function register_click_handlers() {
|
||||||
$("body").on("click", ".user-card-popover-actions .narrow_to_private_messages", (e) => {
|
$("body").on("click", ".user-card-popover-actions .narrow_to_private_messages", (e) => {
|
||||||
const user_id = elem_to_user_id($(e.target).parents("ul"));
|
const user_id = elem_to_user_id($(e.target).parents("ul"));
|
||||||
const email = people.get_by_user_id(user_id).email;
|
const email = people.get_by_user_id(user_id).email;
|
||||||
narrow.show(
|
message_view.show(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
operator: "dm",
|
operator: "dm",
|
||||||
|
@ -708,7 +708,7 @@ function register_click_handlers() {
|
||||||
$("body").on("click", ".user-card-popover-actions .narrow_to_messages_sent", (e) => {
|
$("body").on("click", ".user-card-popover-actions .narrow_to_messages_sent", (e) => {
|
||||||
const user_id = elem_to_user_id($(e.target).parents("ul"));
|
const user_id = elem_to_user_id($(e.target).parents("ul"));
|
||||||
const email = people.get_by_user_id(user_id).email;
|
const email = people.get_by_user_id(user_id).email;
|
||||||
narrow.show(
|
message_view.show(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
operator: "sender",
|
operator: "sender",
|
||||||
|
|
|
@ -31,7 +31,7 @@ const browser_history = zrequire("browser_history");
|
||||||
const people = zrequire("people");
|
const people = zrequire("people");
|
||||||
const hash_util = zrequire("hash_util");
|
const hash_util = zrequire("hash_util");
|
||||||
const hashchange = zrequire("hashchange");
|
const hashchange = zrequire("hashchange");
|
||||||
const narrow = zrequire("../src/narrow");
|
const message_view = zrequire("../src/message_view");
|
||||||
const stream_data = zrequire("stream_data");
|
const stream_data = zrequire("stream_data");
|
||||||
const {Filter} = zrequire("../src/filter");
|
const {Filter} = zrequire("../src/filter");
|
||||||
|
|
||||||
|
@ -181,9 +181,9 @@ function test_helper({override, override_rewire, change_tab}) {
|
||||||
stub(ui_report, "error");
|
stub(ui_report, "error");
|
||||||
|
|
||||||
if (change_tab) {
|
if (change_tab) {
|
||||||
override_rewire(narrow, "show", (terms) => {
|
override_rewire(message_view, "show", (terms) => {
|
||||||
narrow_terms = terms;
|
narrow_terms = terms;
|
||||||
events.push("narrow.show");
|
events.push("message_view.show");
|
||||||
});
|
});
|
||||||
|
|
||||||
override(info_overlay, "show", (name) => {
|
override(info_overlay, "show", (name) => {
|
||||||
|
@ -237,7 +237,7 @@ run_test("hash_interactions", ({override, override_rewire}) => {
|
||||||
helper.assert_events([
|
helper.assert_events([
|
||||||
[overlays, "close_for_hash_change"],
|
[overlays, "close_for_hash_change"],
|
||||||
[message_viewport, "stop_auto_scrolling"],
|
[message_viewport, "stop_auto_scrolling"],
|
||||||
"narrow.show",
|
"message_view.show",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
helper.clear_events();
|
helper.clear_events();
|
||||||
|
@ -245,7 +245,7 @@ run_test("hash_interactions", ({override, override_rewire}) => {
|
||||||
helper.assert_events([
|
helper.assert_events([
|
||||||
[overlays, "close_for_hash_change"],
|
[overlays, "close_for_hash_change"],
|
||||||
[message_viewport, "stop_auto_scrolling"],
|
[message_viewport, "stop_auto_scrolling"],
|
||||||
"narrow.show",
|
"message_view.show",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Test old "#recent_topics" hash redirects to "#recent".
|
// Test old "#recent_topics" hash redirects to "#recent".
|
||||||
|
@ -268,7 +268,7 @@ run_test("hash_interactions", ({override, override_rewire}) => {
|
||||||
helper.assert_events([
|
helper.assert_events([
|
||||||
[overlays, "close_for_hash_change"],
|
[overlays, "close_for_hash_change"],
|
||||||
[message_viewport, "stop_auto_scrolling"],
|
[message_viewport, "stop_auto_scrolling"],
|
||||||
"narrow.show",
|
"message_view.show",
|
||||||
]);
|
]);
|
||||||
let terms = helper.get_narrow_terms();
|
let terms = helper.get_narrow_terms();
|
||||||
assert.equal(terms[0].operand, "Denmark");
|
assert.equal(terms[0].operand, "Denmark");
|
||||||
|
@ -280,7 +280,7 @@ run_test("hash_interactions", ({override, override_rewire}) => {
|
||||||
helper.assert_events([
|
helper.assert_events([
|
||||||
[overlays, "close_for_hash_change"],
|
[overlays, "close_for_hash_change"],
|
||||||
[message_viewport, "stop_auto_scrolling"],
|
[message_viewport, "stop_auto_scrolling"],
|
||||||
"narrow.show",
|
"message_view.show",
|
||||||
]);
|
]);
|
||||||
terms = helper.get_narrow_terms();
|
terms = helper.get_narrow_terms();
|
||||||
assert.equal(terms.length, 0);
|
assert.equal(terms.length, 0);
|
||||||
|
@ -375,7 +375,7 @@ run_test("update_hash_to_match_filter", ({override, override_rewire}) => {
|
||||||
let terms = [{operator: "is", operand: "dm"}];
|
let terms = [{operator: "is", operand: "dm"}];
|
||||||
|
|
||||||
blueslip.expect("error", "browser does not support pushState");
|
blueslip.expect("error", "browser does not support pushState");
|
||||||
narrow.update_hash_to_match_filter(new Filter(terms));
|
message_view.update_hash_to_match_filter(new Filter(terms));
|
||||||
|
|
||||||
helper.assert_events([[message_viewport, "stop_auto_scrolling"]]);
|
helper.assert_events([[message_viewport, "stop_auto_scrolling"]]);
|
||||||
assert.equal(window.location.hash, "#narrow/is/dm");
|
assert.equal(window.location.hash, "#narrow/is/dm");
|
||||||
|
@ -388,7 +388,7 @@ run_test("update_hash_to_match_filter", ({override, override_rewire}) => {
|
||||||
terms = [{operator: "is", operand: "starred"}];
|
terms = [{operator: "is", operand: "starred"}];
|
||||||
|
|
||||||
helper.clear_events();
|
helper.clear_events();
|
||||||
narrow.update_hash_to_match_filter(new Filter(terms));
|
message_view.update_hash_to_match_filter(new Filter(terms));
|
||||||
helper.assert_events([[message_viewport, "stop_auto_scrolling"]]);
|
helper.assert_events([[message_viewport, "stop_auto_scrolling"]]);
|
||||||
assert.equal(url_pushed, "http://zulip.zulipdev.com/#narrow/is/starred");
|
assert.equal(url_pushed, "http://zulip.zulipdev.com/#narrow/is/starred");
|
||||||
});
|
});
|
||||||
|
|
|
@ -50,7 +50,7 @@ const message_actions_popover = mock_esm("../src/message_actions_popover");
|
||||||
const message_edit = mock_esm("../src/message_edit");
|
const message_edit = mock_esm("../src/message_edit");
|
||||||
const message_lists = mock_esm("../src/message_lists");
|
const message_lists = mock_esm("../src/message_lists");
|
||||||
const user_topics_ui = mock_esm("../src/user_topics_ui");
|
const user_topics_ui = mock_esm("../src/user_topics_ui");
|
||||||
const narrow = mock_esm("../src/narrow");
|
const message_view = mock_esm("../src/message_view");
|
||||||
const narrow_state = mock_esm("../src/narrow_state");
|
const narrow_state = mock_esm("../src/narrow_state");
|
||||||
const navigate = mock_esm("../src/navigate");
|
const navigate = mock_esm("../src/navigate");
|
||||||
const modals = mock_esm("../src/modals", {
|
const modals = mock_esm("../src/modals", {
|
||||||
|
@ -313,12 +313,12 @@ run_test("basic mappings", () => {
|
||||||
assert_mapping("w", activity_ui, "initiate_search");
|
assert_mapping("w", activity_ui, "initiate_search");
|
||||||
assert_mapping("q", stream_list, "initiate_search");
|
assert_mapping("q", stream_list, "initiate_search");
|
||||||
|
|
||||||
assert_mapping("A", narrow, "stream_cycle_backward");
|
assert_mapping("A", message_view, "stream_cycle_backward");
|
||||||
assert_mapping("D", narrow, "stream_cycle_forward");
|
assert_mapping("D", message_view, "stream_cycle_forward");
|
||||||
|
|
||||||
assert_mapping("c", compose_actions, "start");
|
assert_mapping("c", compose_actions, "start");
|
||||||
assert_mapping("x", compose_actions, "start");
|
assert_mapping("x", compose_actions, "start");
|
||||||
assert_mapping("P", narrow, "show");
|
assert_mapping("P", message_view, "show");
|
||||||
assert_mapping("g", gear_menu, "toggle");
|
assert_mapping("g", gear_menu, "toggle");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -381,7 +381,7 @@ run_test("misc", ({override}) => {
|
||||||
assert_mapping("e", message_edit, "start");
|
assert_mapping("e", message_edit, "start");
|
||||||
|
|
||||||
override(narrow_state, "narrowed_by_topic_reply", () => true);
|
override(narrow_state, "narrowed_by_topic_reply", () => true);
|
||||||
assert_mapping("s", narrow, "narrow_by_recipient");
|
assert_mapping("s", message_view, "narrow_by_recipient");
|
||||||
|
|
||||||
override(narrow_state, "narrowed_by_topic_reply", () => false);
|
override(narrow_state, "narrowed_by_topic_reply", () => false);
|
||||||
override(narrow_state, "narrowed_by_pm_reply", () => true);
|
override(narrow_state, "narrowed_by_pm_reply", () => true);
|
||||||
|
@ -435,13 +435,13 @@ run_test("G/M keys", () => {
|
||||||
run_test("n/p keys", () => {
|
run_test("n/p keys", () => {
|
||||||
// Test keys that work when a message is selected and
|
// Test keys that work when a message is selected and
|
||||||
// also when the message list is empty.
|
// also when the message list is empty.
|
||||||
assert_mapping("n", narrow, "narrow_to_next_topic");
|
assert_mapping("n", message_view, "narrow_to_next_topic");
|
||||||
assert_mapping("p", narrow, "narrow_to_next_pm_string");
|
assert_mapping("p", message_view, "narrow_to_next_pm_string");
|
||||||
assert_mapping("n", narrow, "narrow_to_next_topic");
|
assert_mapping("n", message_view, "narrow_to_next_topic");
|
||||||
});
|
});
|
||||||
|
|
||||||
run_test("narrow next unread followed topic", () => {
|
run_test("narrow next unread followed topic", () => {
|
||||||
assert_mapping("N", narrow, "narrow_to_next_topic", true, true);
|
assert_mapping("N", message_view, "narrow_to_next_topic", true, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
run_test("motion_keys", () => {
|
run_test("motion_keys", () => {
|
||||||
|
|
|
@ -14,7 +14,7 @@ const narrow_banner = zrequire("narrow_banner");
|
||||||
const people = zrequire("people");
|
const people = zrequire("people");
|
||||||
const stream_data = zrequire("stream_data");
|
const stream_data = zrequire("stream_data");
|
||||||
const {Filter} = zrequire("../src/filter");
|
const {Filter} = zrequire("../src/filter");
|
||||||
const narrow = zrequire("narrow");
|
const message_view = zrequire("message_view");
|
||||||
const narrow_title = zrequire("narrow_title");
|
const narrow_title = zrequire("narrow_title");
|
||||||
const settings_config = zrequire("settings_config");
|
const settings_config = zrequire("settings_config");
|
||||||
const recent_view_util = zrequire("recent_view_util");
|
const recent_view_util = zrequire("recent_view_util");
|
||||||
|
@ -661,21 +661,21 @@ run_test("show_invalid_narrow_message", ({mock_template}) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
run_test("narrow_to_compose_target errors", ({disallow_rewire}) => {
|
run_test("narrow_to_compose_target errors", ({disallow_rewire}) => {
|
||||||
disallow_rewire(narrow, "show");
|
disallow_rewire(message_view, "show");
|
||||||
|
|
||||||
// No-op when not composing.
|
// No-op when not composing.
|
||||||
compose_state.set_message_type(undefined);
|
compose_state.set_message_type(undefined);
|
||||||
narrow.to_compose_target();
|
message_view.to_compose_target();
|
||||||
|
|
||||||
// No-op when empty stream.
|
// No-op when empty stream.
|
||||||
compose_state.set_message_type("stream");
|
compose_state.set_message_type("stream");
|
||||||
compose_state.set_stream_id("");
|
compose_state.set_stream_id("");
|
||||||
narrow.to_compose_target();
|
message_view.to_compose_target();
|
||||||
});
|
});
|
||||||
|
|
||||||
run_test("narrow_to_compose_target streams", ({override_rewire}) => {
|
run_test("narrow_to_compose_target streams", ({override_rewire}) => {
|
||||||
const args = {called: false};
|
const args = {called: false};
|
||||||
override_rewire(narrow, "show", (terms, opts) => {
|
override_rewire(message_view, "show", (terms, opts) => {
|
||||||
args.terms = terms;
|
args.terms = terms;
|
||||||
args.opts = opts;
|
args.opts = opts;
|
||||||
args.called = true;
|
args.called = true;
|
||||||
|
@ -688,7 +688,7 @@ run_test("narrow_to_compose_target streams", ({override_rewire}) => {
|
||||||
// Test with existing topic
|
// Test with existing topic
|
||||||
compose_state.topic("one");
|
compose_state.topic("one");
|
||||||
args.called = false;
|
args.called = false;
|
||||||
narrow.to_compose_target();
|
message_view.to_compose_target();
|
||||||
assert.equal(args.called, true);
|
assert.equal(args.called, true);
|
||||||
assert.equal(args.opts.trigger, "narrow_to_compose_target");
|
assert.equal(args.opts.trigger, "narrow_to_compose_target");
|
||||||
assert.deepEqual(args.terms, [
|
assert.deepEqual(args.terms, [
|
||||||
|
@ -699,7 +699,7 @@ run_test("narrow_to_compose_target streams", ({override_rewire}) => {
|
||||||
// Test with new topic
|
// Test with new topic
|
||||||
compose_state.topic("four");
|
compose_state.topic("four");
|
||||||
args.called = false;
|
args.called = false;
|
||||||
narrow.to_compose_target();
|
message_view.to_compose_target();
|
||||||
assert.equal(args.called, true);
|
assert.equal(args.called, true);
|
||||||
assert.deepEqual(args.terms, [
|
assert.deepEqual(args.terms, [
|
||||||
{operator: "channel", operand: "ROME"},
|
{operator: "channel", operand: "ROME"},
|
||||||
|
@ -709,21 +709,21 @@ run_test("narrow_to_compose_target streams", ({override_rewire}) => {
|
||||||
// Test with blank topic
|
// Test with blank topic
|
||||||
compose_state.topic("");
|
compose_state.topic("");
|
||||||
args.called = false;
|
args.called = false;
|
||||||
narrow.to_compose_target();
|
message_view.to_compose_target();
|
||||||
assert.equal(args.called, true);
|
assert.equal(args.called, true);
|
||||||
assert.deepEqual(args.terms, [{operator: "channel", operand: "ROME"}]);
|
assert.deepEqual(args.terms, [{operator: "channel", operand: "ROME"}]);
|
||||||
|
|
||||||
// Test with no topic
|
// Test with no topic
|
||||||
compose_state.topic(undefined);
|
compose_state.topic(undefined);
|
||||||
args.called = false;
|
args.called = false;
|
||||||
narrow.to_compose_target();
|
message_view.to_compose_target();
|
||||||
assert.equal(args.called, true);
|
assert.equal(args.called, true);
|
||||||
assert.deepEqual(args.terms, [{operator: "channel", operand: "ROME"}]);
|
assert.deepEqual(args.terms, [{operator: "channel", operand: "ROME"}]);
|
||||||
});
|
});
|
||||||
|
|
||||||
run_test("narrow_to_compose_target direct messages", ({override, override_rewire}) => {
|
run_test("narrow_to_compose_target direct messages", ({override, override_rewire}) => {
|
||||||
const args = {called: false};
|
const args = {called: false};
|
||||||
override_rewire(narrow, "show", (terms, opts) => {
|
override_rewire(message_view, "show", (terms, opts) => {
|
||||||
args.terms = terms;
|
args.terms = terms;
|
||||||
args.opts = opts;
|
args.opts = opts;
|
||||||
args.called = true;
|
args.called = true;
|
||||||
|
@ -740,35 +740,35 @@ run_test("narrow_to_compose_target direct messages", ({override, override_rewire
|
||||||
// Test with valid person
|
// Test with valid person
|
||||||
emails = "alice@example.com";
|
emails = "alice@example.com";
|
||||||
args.called = false;
|
args.called = false;
|
||||||
narrow.to_compose_target();
|
message_view.to_compose_target();
|
||||||
assert.equal(args.called, true);
|
assert.equal(args.called, true);
|
||||||
assert.deepEqual(args.terms, [{operator: "dm", operand: "alice@example.com"}]);
|
assert.deepEqual(args.terms, [{operator: "dm", operand: "alice@example.com"}]);
|
||||||
|
|
||||||
// Test with valid persons
|
// Test with valid persons
|
||||||
emails = "alice@example.com,ray@example.com";
|
emails = "alice@example.com,ray@example.com";
|
||||||
args.called = false;
|
args.called = false;
|
||||||
narrow.to_compose_target();
|
message_view.to_compose_target();
|
||||||
assert.equal(args.called, true);
|
assert.equal(args.called, true);
|
||||||
assert.deepEqual(args.terms, [{operator: "dm", operand: "alice@example.com,ray@example.com"}]);
|
assert.deepEqual(args.terms, [{operator: "dm", operand: "alice@example.com,ray@example.com"}]);
|
||||||
|
|
||||||
// Test with some invalid persons
|
// Test with some invalid persons
|
||||||
emails = "alice@example.com,random,ray@example.com";
|
emails = "alice@example.com,random,ray@example.com";
|
||||||
args.called = false;
|
args.called = false;
|
||||||
narrow.to_compose_target();
|
message_view.to_compose_target();
|
||||||
assert.equal(args.called, true);
|
assert.equal(args.called, true);
|
||||||
assert.deepEqual(args.terms, [{operator: "is", operand: "dm"}]);
|
assert.deepEqual(args.terms, [{operator: "is", operand: "dm"}]);
|
||||||
|
|
||||||
// Test with all invalid persons
|
// Test with all invalid persons
|
||||||
emails = "alice,random,ray";
|
emails = "alice,random,ray";
|
||||||
args.called = false;
|
args.called = false;
|
||||||
narrow.to_compose_target();
|
message_view.to_compose_target();
|
||||||
assert.equal(args.called, true);
|
assert.equal(args.called, true);
|
||||||
assert.deepEqual(args.terms, [{operator: "is", operand: "dm"}]);
|
assert.deepEqual(args.terms, [{operator: "is", operand: "dm"}]);
|
||||||
|
|
||||||
// Test with no persons
|
// Test with no persons
|
||||||
emails = "";
|
emails = "";
|
||||||
args.called = false;
|
args.called = false;
|
||||||
narrow.to_compose_target();
|
message_view.to_compose_target();
|
||||||
assert.equal(args.called, true);
|
assert.equal(args.called, true);
|
||||||
assert.deepEqual(args.terms, [{operator: "is", operand: "dm"}]);
|
assert.deepEqual(args.terms, [{operator: "is", operand: "dm"}]);
|
||||||
});
|
});
|
|
@ -60,7 +60,7 @@ mock_esm("../src/unread_ui", {
|
||||||
});
|
});
|
||||||
|
|
||||||
//
|
//
|
||||||
// We have strange hacks in narrow.show to sleep 0
|
// We have strange hacks in message_view.show to sleep 0
|
||||||
// seconds.
|
// seconds.
|
||||||
set_global("setTimeout", (f, t) => {
|
set_global("setTimeout", (f, t) => {
|
||||||
assert.equal(t, 0);
|
assert.equal(t, 0);
|
||||||
|
@ -75,7 +75,7 @@ const {buddy_list} = zrequire("buddy_list");
|
||||||
const activity_ui = zrequire("activity_ui");
|
const activity_ui = zrequire("activity_ui");
|
||||||
const narrow_state = zrequire("narrow_state");
|
const narrow_state = zrequire("narrow_state");
|
||||||
const stream_data = zrequire("stream_data");
|
const stream_data = zrequire("stream_data");
|
||||||
const narrow = zrequire("narrow");
|
const message_view = zrequire("message_view");
|
||||||
const people = zrequire("people");
|
const people = zrequire("people");
|
||||||
|
|
||||||
const denmark = {
|
const denmark = {
|
||||||
|
@ -211,7 +211,7 @@ run_test("basics", ({override}) => {
|
||||||
opts.cont();
|
opts.cont();
|
||||||
};
|
};
|
||||||
|
|
||||||
narrow.show(terms, {
|
message_view.show(terms, {
|
||||||
then_select_id: selected_id,
|
then_select_id: selected_id,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ run_test("basics", ({override}) => {
|
||||||
message_lists.current.selected_id = () => -1;
|
message_lists.current.selected_id = () => -1;
|
||||||
message_lists.current.get_row = () => row;
|
message_lists.current.get_row = () => row;
|
||||||
|
|
||||||
narrow.show([{operator: "is", operand: "private"}], {
|
message_view.show([{operator: "is", operand: "private"}], {
|
||||||
then_select_id: selected_id,
|
then_select_id: selected_id,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ run_test("basics", ({override}) => {
|
||||||
row.get_offset_to_window = () => ({top: 100, bottom: 150});
|
row.get_offset_to_window = () => ({top: 100, bottom: 150});
|
||||||
message_lists.current.get_row = () => row;
|
message_lists.current.get_row = () => row;
|
||||||
|
|
||||||
narrow.show(terms, {
|
message_view.show(terms, {
|
||||||
then_select_id: selected_id,
|
then_select_id: selected_id,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ run_test("basics", ({override}) => {
|
||||||
row.get_offset_to_window = () => ({top: 150, bottom: 250});
|
row.get_offset_to_window = () => ({top: 150, bottom: 250});
|
||||||
message_lists.current.get_row = () => row;
|
message_lists.current.get_row = () => row;
|
||||||
|
|
||||||
narrow.show(terms, {
|
message_view.show(terms, {
|
||||||
then_select_id: selected_id,
|
then_select_id: selected_id,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ const all_messages_data = mock_esm("../src/all_messages_data");
|
||||||
const {Filter} = zrequire("../src/filter");
|
const {Filter} = zrequire("../src/filter");
|
||||||
const {MessageListData} = zrequire("../src/message_list_data");
|
const {MessageListData} = zrequire("../src/message_list_data");
|
||||||
const narrow_state = zrequire("narrow_state");
|
const narrow_state = zrequire("narrow_state");
|
||||||
const narrow = zrequire("narrow");
|
const message_view = zrequire("message_view");
|
||||||
const message_lists = zrequire("message_lists");
|
const message_lists = zrequire("message_lists");
|
||||||
const resolved_topic = zrequire("../shared/src/resolved_topic");
|
const resolved_topic = zrequire("../shared/src/resolved_topic");
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ function test_with(fixture) {
|
||||||
|
|
||||||
narrow_state.__Rewire__("get_first_unread_info", () => fixture.unread_info);
|
narrow_state.__Rewire__("get_first_unread_info", () => fixture.unread_info);
|
||||||
|
|
||||||
narrow.maybe_add_local_messages({
|
message_view.maybe_add_local_messages({
|
||||||
id_info,
|
id_info,
|
||||||
msg_data,
|
msg_data,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue