mirror of https://github.com/zulip/zulip.git
pm_list_dom: Convert module to TypeScript.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
961c7185ab
commit
e459b83c06
|
@ -142,7 +142,7 @@ EXEMPT_FILES = make_set(
|
|||
"web/src/playground_links_popover.js",
|
||||
"web/src/plotly.js.d.ts",
|
||||
"web/src/pm_list.js",
|
||||
"web/src/pm_list_dom.js",
|
||||
"web/src/pm_list_dom.ts",
|
||||
"web/src/poll_widget.js",
|
||||
"web/src/popover_menus.js",
|
||||
"web/src/popover_menus_data.js",
|
||||
|
|
|
@ -5,10 +5,19 @@ 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);
|
||||
// TODO/typescript: Move this to pm_list_data
|
||||
type PMListConversation = {
|
||||
user_ids_string: string;
|
||||
};
|
||||
|
||||
const eq = (other) => _.isEqual(conversation, other.conversation);
|
||||
type PMNode = vdom.Node & {
|
||||
conversation: PMListConversation;
|
||||
};
|
||||
|
||||
export function keyed_pm_li(conversation: PMListConversation): PMNode {
|
||||
const render = (): string => render_pm_list_item(conversation);
|
||||
|
||||
const eq = (other: PMNode): boolean => _.isEqual(conversation, other.conversation);
|
||||
|
||||
const key = conversation.user_ids_string;
|
||||
|
||||
|
@ -20,12 +29,20 @@ export function keyed_pm_li(conversation) {
|
|||
};
|
||||
}
|
||||
|
||||
export function more_private_conversations_li(more_conversations_unread_count) {
|
||||
const render = () => render_more_private_conversations({more_conversations_unread_count});
|
||||
type MorePrivateConversationsNode = vdom.Node & {
|
||||
more_items: boolean;
|
||||
more_conversations_unread_count: number;
|
||||
};
|
||||
|
||||
export function more_private_conversations_li(
|
||||
more_conversations_unread_count: number,
|
||||
): MorePrivateConversationsNode {
|
||||
const render = (): string =>
|
||||
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) =>
|
||||
const eq = (other: MorePrivateConversationsNode): boolean =>
|
||||
other.more_items &&
|
||||
more_conversations_unread_count === other.more_conversations_unread_count;
|
||||
|
||||
|
@ -41,8 +58,8 @@ export function more_private_conversations_li(more_conversations_unread_count) {
|
|||
};
|
||||
}
|
||||
|
||||
export function pm_ul(nodes) {
|
||||
const attrs = [
|
||||
export function pm_ul(nodes: vdom.Node[]): vdom.Tag {
|
||||
const attrs: [string, string][] = [
|
||||
["class", "pm-list"],
|
||||
["data-name", "private"],
|
||||
];
|
|
@ -151,7 +151,7 @@ export function update(
|
|||
like `attrs` for attributes.
|
||||
|
||||
For examples of creating vdom objects, look at
|
||||
`pm_list_dom.js`.
|
||||
`pm_list_dom.ts`.
|
||||
*/
|
||||
function do_full_update(): void {
|
||||
const rendered_dom = render_tag(new_dom);
|
||||
|
|
Loading…
Reference in New Issue