2019-03-24 08:37:53 +01:00
|
|
|
var Dict = require('./dict').Dict;
|
2019-02-08 11:56:33 +01:00
|
|
|
|
2018-08-17 03:46:32 +02:00
|
|
|
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();
|
|
|
|
};
|
|
|
|
|
2019-02-22 12:28:29 +01:00
|
|
|
exports.get_starred_msg_ids = function () {
|
|
|
|
return exports.ids.keys();
|
|
|
|
};
|
|
|
|
|
2018-08-17 03:46:32 +02:00
|
|
|
exports.rerender_ui = function () {
|
2018-08-17 08:48:12 +02:00
|
|
|
var count = exports.count();
|
|
|
|
|
|
|
|
if (!page_params.starred_message_counts) {
|
|
|
|
// This essentially hides the count
|
|
|
|
count = 0;
|
|
|
|
}
|
|
|
|
|
2019-01-30 18:24:56 +01:00
|
|
|
top_left_corner.update_starred_count(count);
|
2018-08-17 03:46:32 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
return exports;
|
|
|
|
|
|
|
|
}());
|
|
|
|
|
|
|
|
if (typeof module !== 'undefined') {
|
|
|
|
module.exports = starred_messages;
|
|
|
|
}
|
|
|
|
|
|
|
|
window.starred_messages = starred_messages;
|