settings_user_topics: Fix implicit use of any.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2024-05-03 14:19:27 -07:00 committed by Tim Abbott
parent 939b88b9a7
commit 2be5cb0223
2 changed files with 28 additions and 21 deletions

View File

@ -61,26 +61,30 @@ export function populate_list(): void {
export function set_up(): void {
loaded = true;
$("body").on("change", ".settings_user_topic_visibility_policy", function (e) {
const $row = $(this).closest("tr");
const stream_id_string = $row.attr("data-stream-id");
assert(stream_id_string !== undefined);
const stream_id = Number.parseInt(stream_id_string, 10);
const topic = $row.attr("data-topic");
assert(topic !== undefined);
const visibility_policy = this.value;
$("body").on(
"change",
"select.settings_user_topic_visibility_policy",
function (this: HTMLSelectElement, e) {
const $row = $(this).closest("tr");
const stream_id_string = $row.attr("data-stream-id");
assert(stream_id_string !== undefined);
const stream_id = Number.parseInt(stream_id_string, 10);
const topic = $row.attr("data-topic");
assert(topic !== undefined);
const visibility_policy = Number(this.value);
e.stopPropagation();
e.stopPropagation();
user_topics.set_user_topic_visibility_policy(
stream_id,
topic,
visibility_policy,
false,
false,
$row.closest("#user-topic-settings").find(".alert-notification"),
);
});
user_topics.set_user_topic_visibility_policy(
stream_id,
topic,
visibility_policy,
false,
false,
$row.closest("#user-topic-settings").find(".alert-notification"),
);
},
);
populate_list();
}

View File

@ -52,7 +52,7 @@ run_test("settings", ({override, override_rewire}) => {
const topic_change_handler = $("body").get_on_handler(
"change",
".settings_user_topic_visibility_policy",
"select.settings_user_topic_visibility_policy",
);
assert.equal(typeof topic_change_handler, "function");
@ -104,8 +104,11 @@ run_test("settings", ({override, override_rewire}) => {
user_topic_visibility_policy_changed = true;
},
);
$topic_fake_this.value = user_topics.all_visibility_policies.UNMUTED;
topic_change_handler.call($topic_fake_this, event);
const topic_fake_this = {
to_$: () => $topic_fake_this,
value: user_topics.all_visibility_policies.UNMUTED,
};
topic_change_handler.call(topic_fake_this, event);
assert.ok(user_topic_visibility_policy_changed);
assert.equal(topic_data_called, 2);
});