Files
zulip/static/js/starred_messages.js
Anders Kaseorg 636587665b js: Convert static/js/starred_messages.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00

49 lines
865 B
JavaScript

import * as top_left_corner from "./top_left_corner";
export const starred_ids = new Set();
export function initialize() {
starred_ids.clear();
for (const id of page_params.starred_messages) {
starred_ids.add(id);
}
rerender_ui();
}
export function add(ids) {
for (const id of ids) {
starred_ids.add(id);
}
rerender_ui();
}
export function remove(ids) {
for (const id of ids) {
starred_ids.delete(id);
}
rerender_ui();
}
export function get_count() {
return starred_ids.size;
}
export function get_starred_msg_ids() {
return Array.from(starred_ids);
}
export function rerender_ui() {
let count = get_count();
if (!page_params.starred_message_counts) {
// This essentially hides the count
count = 0;
}
top_left_corner.update_starred_count(count);
}