mirror of
https://github.com/zulip/zulip.git
synced 2025-11-09 08:26:11 +00:00
This reverts commit 6fba17599f (#16898).
@chrisbobbe reported this crash:
Uncaught TypeError: Cannot read property 'stream_id' of undefined
at starred_messages.js:43
at Array.filter (<anonymous>)
at Object.e.get_topic_starred_msg_ids (starred_messages.js:40)
at stream_popover.js:221
at HTMLSpanElement.<anonymous> (stream_popover.js:358)
at HTMLUListElement.dispatch (jquery.js:5429)
at HTMLUListElement.v.handle (jquery.js:5233)
Signed-off-by: Anders Kaseorg <anders@zulip.com>
51 lines
966 B
JavaScript
51 lines
966 B
JavaScript
"use strict";
|
|
|
|
exports.starred_ids = new Set();
|
|
|
|
exports.initialize = function () {
|
|
exports.starred_ids.clear();
|
|
|
|
for (const id of page_params.starred_messages) {
|
|
exports.starred_ids.add(id);
|
|
}
|
|
|
|
exports.rerender_ui();
|
|
};
|
|
|
|
exports.add = function (ids) {
|
|
for (const id of ids) {
|
|
exports.starred_ids.add(id);
|
|
}
|
|
|
|
exports.rerender_ui();
|
|
};
|
|
|
|
exports.remove = function (ids) {
|
|
for (const id of ids) {
|
|
exports.starred_ids.delete(id);
|
|
}
|
|
|
|
exports.rerender_ui();
|
|
};
|
|
|
|
exports.get_count = function () {
|
|
return exports.starred_ids.size;
|
|
};
|
|
|
|
exports.get_starred_msg_ids = function () {
|
|
return Array.from(exports.starred_ids);
|
|
};
|
|
|
|
exports.rerender_ui = function () {
|
|
let count = exports.get_count();
|
|
|
|
if (!page_params.starred_message_counts) {
|
|
// This essentially hides the count
|
|
count = 0;
|
|
}
|
|
|
|
top_left_corner.update_starred_count(count);
|
|
};
|
|
|
|
window.starred_messages = exports;
|