mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
subs: Fix URL not updating as per UI on stream unsubscription.
When user unsubscribe from stream by clicking on subscription-checkmark, the URL changes to unsubscribed stream but stream settings UI is not updated. We should change URL and stream settings modal simultaneously. This PR moves update-hash function inside open-stream-modal function, which make sure that URL is getting updated everytime open-stream-modal function is called and not otherwise.
This commit is contained in:
committed by
Tim Abbott
parent
2d1b80e2b4
commit
ec5ef08a19
@@ -82,11 +82,36 @@ function clear_edit_panel() {
|
|||||||
$(".stream-row.active").removeClass("active");
|
$(".stream-row.active").removeClass("active");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_stream_id(target) {
|
||||||
|
if (target.constructor !== jQuery) {
|
||||||
|
target = $(target);
|
||||||
|
}
|
||||||
|
return target.closest(".stream-row, .subscription_settings").attr("data-stream-id");
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_sub_for_target(target) {
|
||||||
|
var stream_id = get_stream_id(target);
|
||||||
|
if (!stream_id) {
|
||||||
|
blueslip.error('Cannot find stream id for target');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var sub = stream_data.get_sub_by_id(stream_id);
|
||||||
|
if (!sub) {
|
||||||
|
blueslip.error('get_sub_for_target() failed id lookup: ' + stream_id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return sub;
|
||||||
|
}
|
||||||
|
|
||||||
exports.open_edit_panel_for_row = function (stream_row) {
|
exports.open_edit_panel_for_row = function (stream_row) {
|
||||||
|
var sub = get_sub_for_target(stream_row);
|
||||||
|
|
||||||
clear_edit_panel();
|
clear_edit_panel();
|
||||||
subs.show_subs_pane.settings();
|
subs.show_subs_pane.settings();
|
||||||
$(stream_row).addClass("active");
|
$(stream_row).addClass("active");
|
||||||
stream_edit.show_settings_for(stream_row);
|
stream_edit.show_settings_for(stream_row);
|
||||||
|
setup_subscriptions_stream_hash(sub);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.open_edit_panel_empty = function () {
|
exports.open_edit_panel_empty = function () {
|
||||||
@@ -142,29 +167,6 @@ exports.remove_user_from_stream = function (user_email, sub, success, failure) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function get_stream_id(target) {
|
|
||||||
if (target.constructor !== jQuery) {
|
|
||||||
target = $(target);
|
|
||||||
}
|
|
||||||
return target.closest(".stream-row, .subscription_settings").attr("data-stream-id");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function get_sub_for_target(target) {
|
|
||||||
var stream_id = get_stream_id(target);
|
|
||||||
if (!stream_id) {
|
|
||||||
blueslip.error('Cannot find stream id for target');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var sub = stream_data.get_sub_by_id(stream_id);
|
|
||||||
if (!sub) {
|
|
||||||
blueslip.error('get_sub_for_target() failed id lookup: ' + stream_id);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return sub;
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.sort_but_pin_current_user_on_top = function (emails) {
|
exports.sort_but_pin_current_user_on_top = function (emails) {
|
||||||
if (emails === undefined) {
|
if (emails === undefined) {
|
||||||
blueslip.error("Undefined emails are passed to function sort_but_pin_current_user_on_top");
|
blueslip.error("Undefined emails are passed to function sort_but_pin_current_user_on_top");
|
||||||
@@ -656,7 +658,6 @@ exports.initialize = function () {
|
|||||||
regular_sub_settings.removeClass("in");
|
regular_sub_settings.removeClass("in");
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_subscriptions_stream_hash(sub);
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
});
|
});
|
||||||
@@ -695,9 +696,6 @@ exports.initialize = function () {
|
|||||||
$("#subscriptions_table").on("click", ".stream-row", function (e) {
|
$("#subscriptions_table").on("click", ".stream-row", function (e) {
|
||||||
if ($(e.target).closest(".check, .subscription_settings").length === 0) {
|
if ($(e.target).closest(".check, .subscription_settings").length === 0) {
|
||||||
exports.open_edit_panel_for_row(this);
|
exports.open_edit_panel_for_row(this);
|
||||||
var stream_id = $(this).attr("data-stream-id");
|
|
||||||
var sub = stream_data.get_sub_by_id(stream_id);
|
|
||||||
setup_subscriptions_stream_hash(sub);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user