mirror of https://github.com/zulip/zulip.git
49 lines
998 B
JavaScript
49 lines
998 B
JavaScript
|
var starred_messages = (function () {
|
||
|
|
||
|
var exports = {};
|
||
|
|
||
|
exports.ids = new Dict();
|
||
|
|
||
|
exports.initialize = function () {
|
||
|
exports.ids = new Dict();
|
||
|
_.each(page_params.starred_messages, function (id) {
|
||
|
exports.ids.set(id, true);
|
||
|
});
|
||
|
exports.rerender_ui();
|
||
|
};
|
||
|
|
||
|
exports.add = function (ids) {
|
||
|
_.each(ids, function (id) {
|
||
|
exports.ids.set(id, true);
|
||
|
});
|
||
|
exports.rerender_ui();
|
||
|
};
|
||
|
|
||
|
exports.remove = function (ids) {
|
||
|
_.each(ids, function (id) {
|
||
|
if (exports.ids.has(id)) {
|
||
|
exports.ids.del(id);
|
||
|
}
|
||
|
});
|
||
|
exports.rerender_ui();
|
||
|
};
|
||
|
|
||
|
exports.count = function () {
|
||
|
return exports.ids.num_items();
|
||
|
};
|
||
|
|
||
|
exports.rerender_ui = function () {
|
||
|
var starred_li = top_left_corner.get_global_filter_li('starred');
|
||
|
top_left_corner.update_count_in_dom(starred_li, exports.count());
|
||
|
};
|
||
|
|
||
|
return exports;
|
||
|
|
||
|
}());
|
||
|
|
||
|
if (typeof module !== 'undefined') {
|
||
|
module.exports = starred_messages;
|
||
|
}
|
||
|
|
||
|
window.starred_messages = starred_messages;
|