mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 04:53:36 +00:00
This commit introduces the change of rendering private messages section as collapsible, whose data-fetching logic came with zulip#21357. We now have separated out `Private messages` from `top_left_corner` section and shifted it below the `global_filters` in a different separate section along with stream list with common scroll bar in left-sidebar. The new PM section will be opened by-default on loading the page and will have a toggle-icon in its header, clicking on which makes the section collapse/expand accordingly. In default view, only recent 5 PM threads would be shown and would append the active conversation as the 6th one at last if not present in those 5, similar to how topics list work. In PM section with unreads, a maximum of 8 conversations would be shown and rest of them would be hidden behind the 'more conversations' li-item, clicking on which takes to the zoomedIn view of PM section where all the present PM threads would be visible and rest of the sections of left-sidebar will get collapsed. Fixes #20870. Co-authored-by: Aman Agrawal <amanagr@zulip.com>
81 lines
2.4 KiB
JavaScript
81 lines
2.4 KiB
JavaScript
import $ from "jquery";
|
|
|
|
import * as resize from "./resize";
|
|
import * as ui_util from "./ui_util";
|
|
import * as unread_ui from "./unread_ui";
|
|
|
|
export function update_starred_count(count) {
|
|
const $starred_li = $(".top_left_starred_messages");
|
|
ui_util.update_unread_count_in_dom($starred_li, count);
|
|
}
|
|
|
|
export function update_dom_with_unread_counts(counts) {
|
|
// Note that "Private messages" counts are handled in pm_list.js.
|
|
|
|
// mentioned/home have simple integer counts
|
|
const $mentioned_li = $(".top_left_mentions");
|
|
const $home_li = $(".top_left_all_messages");
|
|
|
|
ui_util.update_unread_count_in_dom($mentioned_li, counts.mentioned_message_count);
|
|
ui_util.update_unread_count_in_dom($home_li, counts.home_unread_messages);
|
|
|
|
unread_ui.animate_mention_changes($mentioned_li, counts.mentioned_message_count);
|
|
}
|
|
|
|
function remove($elem) {
|
|
$elem.removeClass("active-filter active-sub-filter");
|
|
}
|
|
|
|
export function deselect_top_left_corner_items() {
|
|
remove($(".top_left_all_messages"));
|
|
remove($(".top_left_starred_messages"));
|
|
remove($(".top_left_mentions"));
|
|
remove($(".top_left_recent_topics"));
|
|
}
|
|
|
|
export function handle_narrow_activated(filter) {
|
|
deselect_top_left_corner_items();
|
|
|
|
let ops;
|
|
let filter_name;
|
|
let $filter_li;
|
|
|
|
// TODO: handle confused filters like "in:all stream:foo"
|
|
ops = filter.operands("in");
|
|
if (ops.length >= 1) {
|
|
filter_name = ops[0];
|
|
if (filter_name === "home") {
|
|
$filter_li = $(".top_left_all_messages");
|
|
$filter_li.addClass("active-filter");
|
|
}
|
|
}
|
|
ops = filter.operands("is");
|
|
if (ops.length >= 1) {
|
|
filter_name = ops[0];
|
|
if (filter_name === "starred") {
|
|
$filter_li = $(".top_left_starred_messages");
|
|
$filter_li.addClass("active-filter");
|
|
} else if (filter_name === "mentioned") {
|
|
$filter_li = $(".top_left_mentions");
|
|
$filter_li.addClass("active-filter");
|
|
}
|
|
}
|
|
}
|
|
|
|
export function handle_narrow_deactivated() {
|
|
deselect_top_left_corner_items();
|
|
|
|
const $filter_li = $(".top_left_all_messages");
|
|
$filter_li.addClass("active-filter");
|
|
}
|
|
|
|
export function narrow_to_recent_topics() {
|
|
remove($(".top_left_all_messages"));
|
|
remove($(".top_left_starred_messages"));
|
|
remove($(".top_left_mentions"));
|
|
$(".top_left_recent_topics").addClass("active-filter");
|
|
setTimeout(() => {
|
|
resize.resize_stream_filters_container();
|
|
}, 0);
|
|
}
|