mirror of https://github.com/zulip/zulip.git
narrow_state: Add function to check if message feed is visible.
We directly check if message feed is visible in the code instead of indirectly checking so via recent topics. This helps read the code clearly and would be helpful with the upcoming inbox view.
This commit is contained in:
parent
cc96be2bf9
commit
845e873c44
|
@ -6,7 +6,6 @@ import * as message_lists from "./message_lists";
|
|||
import * as message_store from "./message_store";
|
||||
import * as narrow_state from "./narrow_state";
|
||||
import * as people from "./people";
|
||||
import * as recent_topics_util from "./recent_topics_util";
|
||||
|
||||
export function get_recipient_label(message) {
|
||||
// TODO: This code path is bit of a type-checking disaster; we mix
|
||||
|
@ -109,14 +108,12 @@ export function update_reply_recipient_label(message) {
|
|||
export function initialize() {
|
||||
// When the message selection changes, change the label on the Reply button.
|
||||
$(document).on("message_selected.zulip", () => {
|
||||
if (recent_topics_util.is_visible()) {
|
||||
if (narrow_state.is_message_feed_visible()) {
|
||||
// message_selected events can occur with recent topics
|
||||
// open due to "All messages" loading in the background,
|
||||
// so we return without calling changing button state.
|
||||
return;
|
||||
}
|
||||
|
||||
// so we only update if message feed is visible.
|
||||
update_reply_recipient_label();
|
||||
}
|
||||
});
|
||||
|
||||
// Click handlers for buttons in the compose box.
|
||||
|
|
|
@ -27,6 +27,7 @@ import * as message_scroll from "./message_scroll";
|
|||
import * as message_view_header from "./message_view_header";
|
||||
import * as muted_topics_ui from "./muted_topics_ui";
|
||||
import * as narrow from "./narrow";
|
||||
import * as narrow_state from "./narrow_state";
|
||||
import * as navigate from "./navigate";
|
||||
import * as overlays from "./overlays";
|
||||
import {page_params} from "./page_params";
|
||||
|
@ -874,13 +875,9 @@ export function process_hotkey(e, hotkey) {
|
|||
return true;
|
||||
}
|
||||
|
||||
// We don't want hotkeys below this to work when recent topics is
|
||||
// open. These involve hotkeys that can only be performed on a message.
|
||||
if (recent_topics_util.is_visible()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (message_lists.current.empty()) {
|
||||
// Hotkeys below this point are for the message feed, and so
|
||||
// should only function if the message feed is visible and nonempty.
|
||||
if (!narrow_state.is_message_feed_visible() || message_lists.current.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ import {page_params} from "./page_params";
|
|||
import * as people from "./people";
|
||||
import * as popovers from "./popovers";
|
||||
import * as reactions from "./reactions";
|
||||
import * as recent_topics_util from "./recent_topics_util";
|
||||
import * as rendered_markdown from "./rendered_markdown";
|
||||
import * as rows from "./rows";
|
||||
import * as stream_data from "./stream_data";
|
||||
|
@ -791,7 +790,7 @@ export class MessageListView {
|
|||
|
||||
const restore_scroll_position = () => {
|
||||
if (
|
||||
!recent_topics_util.is_visible() &&
|
||||
narrow_state.is_message_feed_visible() &&
|
||||
list === message_lists.current &&
|
||||
orig_scrolltop_offset !== undefined
|
||||
) {
|
||||
|
|
|
@ -107,7 +107,7 @@ export function update_top_of_narrow_notices(msg_list) {
|
|||
message_lists.current !== message_lists.home
|
||||
) {
|
||||
const filter = narrow_state.filter();
|
||||
if (filter === undefined && recent_topics_util.is_visible()) {
|
||||
if (filter === undefined && !narrow_state.is_message_feed_visible()) {
|
||||
// user moved away from the narrow / filter to recent topics.
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import * as blueslip from "./blueslip";
|
|||
import {Filter} from "./filter";
|
||||
import {page_params} from "./page_params";
|
||||
import * as people from "./people";
|
||||
import * as recent_topics_util from "./recent_topics_util";
|
||||
import * as stream_data from "./stream_data";
|
||||
import * as unread from "./unread";
|
||||
|
||||
|
@ -32,6 +33,10 @@ export function operators() {
|
|||
return current_filter.operators();
|
||||
}
|
||||
|
||||
export function is_message_feed_visible() {
|
||||
return !recent_topics_util.is_visible();
|
||||
}
|
||||
|
||||
export function update_email(user_id, new_email) {
|
||||
if (current_filter !== undefined) {
|
||||
current_filter.update_email(user_id, new_email);
|
||||
|
|
|
@ -11,7 +11,6 @@ import * as message_lists from "./message_lists";
|
|||
import * as narrow_state from "./narrow_state";
|
||||
import * as popover_menus from "./popover_menus";
|
||||
import * as reactions from "./reactions";
|
||||
import * as recent_topics_util from "./recent_topics_util";
|
||||
import * as rows from "./rows";
|
||||
import * as timerender from "./timerender";
|
||||
import {parse_html} from "./ui_util";
|
||||
|
@ -251,7 +250,7 @@ export function initialize() {
|
|||
content() {
|
||||
const narrow_filter = narrow_state.filter();
|
||||
let display_current_view;
|
||||
if (!recent_topics_util.is_visible()) {
|
||||
if (narrow_state.is_message_feed_visible()) {
|
||||
if (narrow_filter === undefined) {
|
||||
display_current_view = $t({defaultMessage: "Currently viewing all messages."});
|
||||
} else if (
|
||||
|
|
|
@ -52,6 +52,7 @@ import * as message_scroll from "./message_scroll";
|
|||
import * as message_view_header from "./message_view_header";
|
||||
import * as message_viewport from "./message_viewport";
|
||||
import * as muted_users from "./muted_users";
|
||||
import * as narrow_state from "./narrow_state";
|
||||
import * as navbar_alerts from "./navbar_alerts";
|
||||
import * as navigate from "./navigate";
|
||||
import * as notifications from "./notifications";
|
||||
|
@ -66,7 +67,6 @@ import * as realm_logo from "./realm_logo";
|
|||
import * as realm_playground from "./realm_playground";
|
||||
import * as realm_user_settings_defaults from "./realm_user_settings_defaults";
|
||||
import * as recent_topics_ui from "./recent_topics_ui";
|
||||
import * as recent_topics_util from "./recent_topics_util";
|
||||
import * as reload from "./reload";
|
||||
import * as rendered_markdown from "./rendered_markdown";
|
||||
import * as resize from "./resize";
|
||||
|
@ -259,7 +259,7 @@ export function initialize_kitchen_sink_stuff() {
|
|||
|
||||
message_viewport.$message_pane.on("wheel", (e) => {
|
||||
const delta = e.originalEvent.deltaY;
|
||||
if (!overlays.is_overlay_or_modal_open() && !recent_topics_util.is_visible()) {
|
||||
if (!overlays.is_overlay_or_modal_open() && narrow_state.is_message_feed_visible()) {
|
||||
// In the message view, we use a throttled mousewheel handler.
|
||||
throttled_mousewheelhandler(e, delta);
|
||||
}
|
||||
|
|
|
@ -9,10 +9,10 @@ import * as message_lists from "./message_lists";
|
|||
import * as message_live_update from "./message_live_update";
|
||||
import * as message_store from "./message_store";
|
||||
import * as message_viewport from "./message_viewport";
|
||||
import * as narrow_state from "./narrow_state";
|
||||
import * as notifications from "./notifications";
|
||||
import * as people from "./people";
|
||||
import * as recent_topics_ui from "./recent_topics_ui";
|
||||
import * as recent_topics_util from "./recent_topics_util";
|
||||
import * as ui_report from "./ui_report";
|
||||
import * as unread from "./unread";
|
||||
import * as unread_ui from "./unread_ui";
|
||||
|
@ -369,7 +369,7 @@ export function notify_server_message_read(message, options) {
|
|||
}
|
||||
|
||||
export function process_scrolled_to_bottom() {
|
||||
if (recent_topics_util.is_visible()) {
|
||||
if (!narrow_state.is_message_feed_visible()) {
|
||||
// First, verify the current message list is visible.
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue