mirror of
https://github.com/zulip/zulip.git
synced 2025-11-18 21:48:30 +00:00
minor: Inline add_sub into create_sub_from_server_data.
We now use add_sub only in tests. The line to defensively initialize subscribers does not get copied from add_sub, since we know that create_sub_from_server_data always initializes subscribers via set_subscribers.
This commit is contained in:
@@ -212,6 +212,10 @@ exports.unsubscribe_myself = function (sub) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.add_sub = function (sub) {
|
exports.add_sub = function (sub) {
|
||||||
|
// This function is currently used only by tests.
|
||||||
|
// We use create_sub_from_server_data at page load.
|
||||||
|
// We use create_streams for new streams in live-update events.
|
||||||
|
|
||||||
if (!Object.prototype.hasOwnProperty.call(sub, "subscribers")) {
|
if (!Object.prototype.hasOwnProperty.call(sub, "subscribers")) {
|
||||||
sub.subscribers = new LazySet([]);
|
sub.subscribers = new LazySet([]);
|
||||||
}
|
}
|
||||||
@@ -805,7 +809,8 @@ exports.create_sub_from_server_data = function (attrs) {
|
|||||||
|
|
||||||
exports.update_calculated_fields(sub);
|
exports.update_calculated_fields(sub);
|
||||||
|
|
||||||
exports.add_sub(sub);
|
stream_info.set(sub.name, sub);
|
||||||
|
subs_by_stream_id.set(sub.stream_id, sub);
|
||||||
|
|
||||||
return sub;
|
return sub;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user