mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 12:33:40 +00:00
widgetize: Convert widget_contents from object to Map.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
committed by
Tim Abbott
parent
56436188a4
commit
52a8449a0e
@@ -5,7 +5,7 @@ const widgets = new Map([
|
||||
["zform", zform],
|
||||
]);
|
||||
|
||||
const widget_contents = {};
|
||||
const widget_contents = new Map();
|
||||
exports.widget_contents = widget_contents;
|
||||
|
||||
function set_widget_in_message(row, widget_elem) {
|
||||
@@ -41,7 +41,7 @@ exports.activate = function (in_opts) {
|
||||
return;
|
||||
}
|
||||
|
||||
let widget_elem = widget_contents[message.id];
|
||||
let widget_elem = widget_contents.get(message.id);
|
||||
if (widget_elem) {
|
||||
set_widget_in_message(row, widget_elem);
|
||||
return;
|
||||
@@ -58,7 +58,7 @@ exports.activate = function (in_opts) {
|
||||
extra_data: extra_data,
|
||||
});
|
||||
|
||||
widget_contents[message.id] = widget_elem;
|
||||
widget_contents.set(message.id, widget_elem);
|
||||
set_widget_in_message(row, widget_elem);
|
||||
|
||||
// Replay any events that already happened. (This is common
|
||||
@@ -70,16 +70,16 @@ exports.activate = function (in_opts) {
|
||||
};
|
||||
|
||||
exports.set_widgets_for_list = function () {
|
||||
_.each(widget_contents, function (widget_elem, idx) {
|
||||
for (const [idx, widget_elem] of widget_contents) {
|
||||
if (current_msg_list.get(idx) !== undefined) {
|
||||
const row = current_msg_list.get_row(idx);
|
||||
set_widget_in_message(row, widget_elem);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
exports.handle_event = function (widget_event) {
|
||||
const widget_elem = widget_contents[widget_event.message_id];
|
||||
const widget_elem = widget_contents.get(widget_event.message_id);
|
||||
|
||||
if (!widget_elem) {
|
||||
// It is common for submessage events to arrive on
|
||||
|
||||
Reference in New Issue
Block a user