Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

subs cleanup: Simplify is_sub_already_present().

Steve Howella87596a3f9c3
diff --git a/static/js/subs.js b/static/js/subs.js
index 1f11e80f600..85eaf31725b 100644
--- a/static/js/subs.js
+++ b/static/js/subs.js
@@ -37,6 +37,10 @@ exports.row_for_stream_id = function (stream_id) {
return $(`.stream-row[data-stream-id='${CSS.escape(stream_id)}']`);
};
+exports.is_sub_already_present = function (sub) {
+ return exports.row_for_stream_id(sub.stream_id).length > 0;
+};
+
exports.settings_button_for_sub = function (sub) {
// We don't do expectOne() here, because this button is only
// visible if the user has that stream selected in the streams UI.
@@ -266,16 +270,6 @@ exports.add_sub_to_table = function (sub) {
}
};
-exports.is_sub_already_present = function (sub) {
- // This checks if a stream is already listed the "Manage streams"
- // UI, by checking for its subscribe/unsubscribe checkmark button.
- const button = exports.check_button_for_sub(sub);
- if (button.length !== 0) {
- return true;
- }
- return false;
-};
-
exports.remove_stream = function (stream_id) {
// It is possible that row is empty when we deactivate a
// stream, but we let jQuery silently handle that.