2020-02-01 04:53:37 +01:00
|
|
|
exports.ids = new Set();
|
2018-08-17 03:46:32 +02:00
|
|
|
|
|
|
|
exports.initialize = function () {
|
2020-02-01 04:53:37 +01:00
|
|
|
exports.ids.clear();
|
2018-08-17 03:46:32 +02:00
|
|
|
_.each(page_params.starred_messages, function (id) {
|
2020-02-01 04:53:37 +01:00
|
|
|
exports.ids.add(id);
|
2018-08-17 03:46:32 +02:00
|
|
|
});
|
|
|
|
exports.rerender_ui();
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.add = function (ids) {
|
|
|
|
_.each(ids, function (id) {
|
2020-02-01 04:53:37 +01:00
|
|
|
exports.ids.add(id);
|
2018-08-17 03:46:32 +02:00
|
|
|
});
|
|
|
|
exports.rerender_ui();
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.remove = function (ids) {
|
|
|
|
_.each(ids, function (id) {
|
2020-02-01 04:53:37 +01:00
|
|
|
exports.ids.delete(id);
|
2018-08-17 03:46:32 +02:00
|
|
|
});
|
|
|
|
exports.rerender_ui();
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.count = function () {
|
2020-02-01 04:53:37 +01:00
|
|
|
return exports.ids.size;
|
2018-08-17 03:46:32 +02:00
|
|
|
};
|
|
|
|
|
2019-02-22 12:28:29 +01:00
|
|
|
exports.get_starred_msg_ids = function () {
|
2020-02-04 23:46:56 +01:00
|
|
|
return Array.from(exports.ids);
|
2019-02-22 12:28:29 +01:00
|
|
|
};
|
|
|
|
|
2018-08-17 03:46:32 +02:00
|
|
|
exports.rerender_ui = function () {
|
2019-11-02 00:06:25 +01:00
|
|
|
let count = exports.count();
|
2018-08-17 08:48:12 +02:00
|
|
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2019-10-25 09:45:13 +02:00
|
|
|
window.starred_messages = exports;
|