subs cleanup: Simplify is_sub_already_present().

Checking for the button was a brittle way to do this.

Note that the code on master is flawed insofar as
we don't respect the search filters.  I don't fix that
bug here.  This is a tactical change to eliminate
another function.

Upcoming changes will make it so that all the bugs
related to "notdisplayed" will simply go away.
This commit is contained in:
Steve Howell
2021-02-17 17:48:10 +00:00
committed by Tim Abbott
parent 6206d0486a
commit a87596a3f9

View File

@@ -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.