mirror of
https://github.com/zulip/zulip.git
synced 2026-06-30 21:11:04 +08:00
pm_list: Show all DMs if header matches search term.
This commit is contained in:
parent
024081a171
commit
00a7a31404
@ -1,5 +1,6 @@
|
||||
import $ from "jquery";
|
||||
import _ from "lodash";
|
||||
import assert from "minimalistic-assert";
|
||||
import * as z from "zod/mini";
|
||||
|
||||
import type {Filter} from "./filter.ts";
|
||||
@ -12,6 +13,7 @@ import * as resize from "./resize.ts";
|
||||
import * as scroll_util from "./scroll_util.ts";
|
||||
import * as ui_util from "./ui_util.ts";
|
||||
import type {FullUnreadCountsData} from "./unread.ts";
|
||||
import * as util from "./util.ts";
|
||||
import * as vdom from "./vdom.ts";
|
||||
|
||||
let prior_dom: vdom.Tag<PMNode> | undefined;
|
||||
@ -86,7 +88,10 @@ 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): void {
|
||||
export function update_private_messages(
|
||||
is_left_sidebar_search_active = false,
|
||||
header_text?: string,
|
||||
): void {
|
||||
const is_dm_section_expanded = is_left_sidebar_search_active || !private_messages_collapsed;
|
||||
$("#toggle-direct-messages-section-icon").toggleClass(
|
||||
"rotate-icon-down",
|
||||
@ -102,8 +107,14 @@ export function update_private_messages(is_left_sidebar_search_active = false):
|
||||
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})) {
|
||||
// Show all DMs if the search term matches the header text.
|
||||
search_term = "";
|
||||
}
|
||||
}
|
||||
|
||||
const conversations = pm_list_data.get_conversations(search_term);
|
||||
const pm_list_info = pm_list_data.get_list_info(zoomed, search_term);
|
||||
const conversations_to_be_shown = pm_list_info.conversations_to_be_shown;
|
||||
|
||||
@ -313,10 +313,12 @@ export function update_expanded_views_for_search(search_term: string): void {
|
||||
search_term,
|
||||
});
|
||||
for (const view of expanded_views) {
|
||||
let show_view = show_all_views || util.prefix_match({
|
||||
value: view.name,
|
||||
search_term,
|
||||
});
|
||||
let show_view =
|
||||
show_all_views ||
|
||||
util.prefix_match({
|
||||
value: view.name,
|
||||
search_term,
|
||||
});
|
||||
const $view = $(`.top_left_${view.css_class_suffix}`);
|
||||
|
||||
if (show_view && $view.hasClass("top_left_scheduled_messages")) {
|
||||
@ -603,7 +605,10 @@ function actually_update_left_sidebar_for_search(): void {
|
||||
}
|
||||
|
||||
// Update left sidebar DM list.
|
||||
pm_list.update_private_messages(is_left_sidebar_search_active);
|
||||
pm_list.update_private_messages(
|
||||
is_left_sidebar_search_active,
|
||||
LEFT_SIDEBAR_DIRECT_MESSAGES_TITLE,
|
||||
);
|
||||
|
||||
// Update left sidebar channel list.
|
||||
stream_list.update_streams_sidebar();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user