Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

pm_list: Move constant to pm_list to avoid passing a parameter.

Aman Agrawalab9ac525ca11
diff --git a/web/src/pm_list.ts b/web/src/pm_list.ts
index d393631d4c4..2ac701345e4 100644
--- a/web/src/pm_list.ts
+++ b/web/src/pm_list.ts
@@ -1,9 +1,9 @@
import $ from "jquery";
import _ from "lodash";
-import assert from "minimalistic-assert";
import * as z from "zod/mini";
import type {Filter} from "./filter.ts";
+import {$t} from "./i18n.ts";
import {localstorage} from "./localstorage.ts";
import * as mouse_drag from "./mouse_drag.ts";
import * as pm_list_data from "./pm_list_data.ts";
@@ -17,6 +17,8 @@ import type {FullUnreadCountsData} from "./unread.ts";
import * as util from "./util.ts";
import * as vdom from "./vdom.ts";
+export const LEFT_SIDEBAR_DIRECT_MESSAGES_TITLE = $t({defaultMessage: "DIRECT MESSAGES"});
+
let prior_dom: vdom.Tag<PMNode> | undefined;
// This module manages the direct messages section in the upper
@@ -89,10 +91,7 @@ function set_dom_to(new_dom: vdom.Tag<PMNode>): void {
prior_dom = new_dom;
}
-export function update_private_messages(
- is_left_sidebar_search_active = false,
- header_text?: string,
-): void {
+export function update_private_messages(is_left_sidebar_search_active = false): void {
const is_dm_section_expanded = is_left_sidebar_search_active || !private_messages_collapsed;
$("#toggle-direct-messages-section-icon").toggleClass(
"rotate-icon-down",
@@ -108,9 +107,8 @@ export function update_private_messages(
const $filter = $<HTMLInputElement>(".direct-messages-list-filter").expectOne();
search_term = $filter.val()!;
} else if (is_left_sidebar_search_active) {
- assert(header_text !== undefined);
search_term = ui_util.get_left_sidebar_search_term();
- if (util.prefix_match({value: header_text, search_term})) {
+ if (util.prefix_match({value: LEFT_SIDEBAR_DIRECT_MESSAGES_TITLE, search_term})) {
// Show all DMs if the search term matches the header text.
search_term = "";
}
diff --git a/web/src/sidebar_ui.ts b/web/src/sidebar_ui.ts
index 426bda05229..132e98c9b26 100644
--- a/web/src/sidebar_ui.ts
+++ b/web/src/sidebar_ui.ts
@@ -34,7 +34,6 @@ import {user_settings} from "./user_settings.ts";
import * as util from "./util.ts";
const LEFT_SIDEBAR_NAVIGATION_AREA_TITLE = $t({defaultMessage: "VIEWS"});
-const LEFT_SIDEBAR_DIRECT_MESSAGES_TITLE = $t({defaultMessage: "DIRECT MESSAGES"});
export let left_sidebar_cursor: ListCursor<JQuery>;
@@ -353,7 +352,7 @@ export function initialize_left_sidebar(): void {
primary_condensed_views,
expanded_views,
LEFT_SIDEBAR_NAVIGATION_AREA_TITLE,
- LEFT_SIDEBAR_DIRECT_MESSAGES_TITLE,
+ LEFT_SIDEBAR_DIRECT_MESSAGES_TITLE: pm_list.LEFT_SIDEBAR_DIRECT_MESSAGES_TITLE,
});
$("#left-sidebar-container").html(rendered_sidebar);
@@ -605,10 +604,7 @@ function actually_update_left_sidebar_for_search(): void {
}
// Update left sidebar DM list.
- pm_list.update_private_messages(
- is_left_sidebar_search_active,
- LEFT_SIDEBAR_DIRECT_MESSAGES_TITLE,
- );
+ pm_list.update_private_messages(is_left_sidebar_search_active);
// Update left sidebar channel list.
stream_list.update_streams_sidebar();