streams: Correct spinner bug when subscribing.

When clicking on the tick to subscribe to a stream,
an error occurred while trying to find the spinner
location because there are two DOM elements with the
same class, sub_unsub_button, and this made the
selector get the subscribe/unsubscribe button instead
the correct stream_row, where the tick is.

We now check whether the tick or the subscribe/unsubscribe
button was clicked, and if it was the last one we make
sure the stream_row and not the button is being passed
to the sub_or_unsub function.
This commit is contained in:
clarammdantas
2020-04-23 18:49:50 -03:00
committed by Tim Abbott
parent a3a850b440
commit de28c8d238

View File

@@ -636,8 +636,14 @@ exports.initialize = function () {
// checkmark in the subscriber list.
$("#subscriptions_table").on("click", ".sub_unsub_button", function (e) {
const sub = get_sub_for_target(e.target);
const stream_row = $(e.currentTarget).parent();
subs.sub_or_unsub(sub, e.currentTarget);
let stream_row;
if ($(e.currentTarget).is(":button")) {
stream_row = $("#subscriptions_table div.stream-row[data-stream-id='" + sub.stream_id + "']");
} else {
stream_row = $(e.currentTarget).parent();
}
subs.sub_or_unsub(sub, stream_row);
if (!sub.subscribed) {
exports.open_edit_panel_for_row(stream_row);
}