muted_topics: Rerender list only if modal is opened and section is loaded.

We should rernder the muted topics list in settings only if the settings
modal is opened and the muted topics section is loaded.
This commit is contained in:
sahil839 2020-07-12 03:43:47 +05:30 committed by Tim Abbott
parent c1b047b0d1
commit d41f66a917
4 changed files with 19 additions and 1 deletions

View File

@ -32,7 +32,10 @@ run_test('settings', () => {
set_up_ui_called = true;
};
assert.equal(settings_muting.loaded, false);
settings_muting.set_up();
assert.equal(settings_muting.loaded, true);
const click_handler = $('body').get_on_handler('click', '.settings-unmute-topic');
assert.equal(typeof click_handler, 'function');
@ -71,3 +74,8 @@ run_test('settings', () => {
assert(set_up_ui_called);
assert.equal(data_called, 2);
});
run_test('reset', () => {
settings_muting.reset();
assert.equal(settings_muting.loaded, false);
});

View File

@ -20,7 +20,9 @@ exports.rerender = function () {
if (current_msg_list !== home_msg_list) {
home_msg_list.update_muting_and_rerender();
}
exports.set_up_muted_topics_ui();
if (overlays.settings_open() && settings_muting.loaded) {
exports.set_up_muted_topics_ui();
}
};
exports.persist_mute = function (stream_id, topic_name) {

View File

@ -1,4 +1,7 @@
exports.loaded = false;
exports.set_up = function () {
exports.loaded = true;
$('body').on('click', '.settings-unmute-topic', function (e) {
const $row = $(this).closest("tr");
const stream_id = parseInt($row.attr("data-stream-id"), 10);
@ -13,4 +16,8 @@ exports.set_up = function () {
muting_ui.set_up_muted_topics_ui();
};
exports.reset = function () {
exports.loaded = false;
};
window.settings_muting = exports;

View File

@ -77,6 +77,7 @@ exports.reset_sections = function () {
settings_profile_fields.reset();
settings_streams.reset();
settings_user_groups.reset();
settings_muting.reset();
// settings_users doesn't need a reset()
};