Files
zulip/static/js/pm_list_dom.js
jai2201 6f9e97921d pm_section: Create collapsible private messages section.
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>
2022-10-26 13:47:08 -07:00

54 lines
1.3 KiB
JavaScript

import _ from "lodash";
import render_more_private_conversations from "../templates/more_pms.hbs";
import render_pm_list_item from "../templates/pm_list_item.hbs";
import * as vdom from "./vdom";
export function keyed_pm_li(conversation) {
const render = () => render_pm_list_item(conversation);
const eq = (other) => _.isEqual(conversation, other.conversation);
const key = conversation.user_ids_string;
return {
key,
render,
conversation,
eq,
};
}
export function more_private_conversations_li(more_conversations_unread_count) {
const render = () => render_more_private_conversations({more_conversations_unread_count});
// Used in vdom.js to check if an element has changed and needs to
// be updated in the DOM.
const eq = (other) =>
other.more_items &&
more_conversations_unread_count === other.more_conversations_unread_count;
// This special key must be impossible as a user_ids_string.
const key = "more_private_conversations";
return {
key,
more_items: true,
more_conversations_unread_count,
render,
eq,
};
}
export function pm_ul(nodes) {
const attrs = [
["class", "pm-list"],
["data-name", "private"],
];
return vdom.ul({
attrs,
keyed_nodes: nodes,
});
}