settings: render_alert_words_ui -> rerender_alert_words_ui.

Correctly specifying that this is a rerender function makes starting
with a `loaded` conditional make much more sense.
This commit is contained in:
Tim Abbott 2022-02-25 16:58:57 -08:00 committed by Tim Abbott
parent d6c00521b3
commit 7ddefc68cc
4 changed files with 11 additions and 10 deletions

View File

@ -17,7 +17,7 @@ alert_words.initialize({
});
const noop = () => {};
run_test("render_alert_words_ui", ({mock_template}) => {
run_test("rerender_alert_words_ui", ({mock_template}) => {
let list_widget_create_called = false;
alert_words_ui.reset();
assert.ok(!$("#create_alert_word_name").is_focused());
@ -37,7 +37,7 @@ run_test("render_alert_words_ui", ({mock_template}) => {
assert.ok(["foo", "bar"].includes(args.alert_word.word));
});
assert.equal(alert_words_ui.loaded, false);
alert_words_ui.render_alert_words_ui();
alert_words_ui.rerender_alert_words_ui();
assert.equal(list_widget_create_called, false);
alert_words_ui.set_up_alert_words();
assert.equal(alert_words_ui.loaded, true);
@ -46,7 +46,7 @@ run_test("render_alert_words_ui", ({mock_template}) => {
});
run_test("add_alert_word", ({override_rewire}) => {
override_rewire(alert_words_ui, "render_alert_words_ui", () => {}); // we've already tested this above
override_rewire(alert_words_ui, "rerender_alert_words_ui", () => {}); // we've already tested this above
alert_words_ui.set_up_alert_words();
@ -101,7 +101,7 @@ run_test("add_alert_word", ({override_rewire}) => {
});
run_test("add_alert_word_keypress", ({override_rewire}) => {
override_rewire(alert_words_ui, "render_alert_words_ui", () => {});
override_rewire(alert_words_ui, "rerender_alert_words_ui", () => {});
alert_words_ui.set_up_alert_words();
const create_form = $("#create_alert_word_form");
@ -127,7 +127,7 @@ run_test("add_alert_word_keypress", ({override_rewire}) => {
});
run_test("remove_alert_word", ({override_rewire}) => {
override_rewire(alert_words_ui, "render_alert_words_ui", () => {});
override_rewire(alert_words_ui, "rerender_alert_words_ui", () => {});
alert_words_ui.set_up_alert_words();
const word_list = $("#alert-words-table");
@ -174,7 +174,7 @@ run_test("remove_alert_word", ({override_rewire}) => {
});
run_test("close_status_message", ({override_rewire}) => {
override_rewire(alert_words_ui, "render_alert_words_ui", () => {});
override_rewire(alert_words_ui, "rerender_alert_words_ui", () => {});
alert_words_ui.set_up_alert_words();
const alert_word_settings = $("#alert-word-settings");

View File

@ -126,7 +126,7 @@ run_test("alert_words", ({override}) => {
assert.ok(!alert_words.has_alert_word("fire"));
assert.ok(!alert_words.has_alert_word("lunch"));
override(alert_words_ui, "render_alert_words_ui", noop);
override(alert_words_ui, "rerender_alert_words_ui", noop);
const event = event_fixtures.alert_words;
dispatch(event);

View File

@ -9,10 +9,11 @@ import * as ListWidget from "./list_widget";
export let loaded = false;
export function render_alert_words_ui() {
export function rerender_alert_words_ui() {
if (!loaded) {
return;
}
const words = alert_words.get_word_list();
words.sort();
const word_list = $("#alert-words-table");
@ -90,7 +91,7 @@ function remove_alert_word(alert_word) {
export function set_up_alert_words() {
// The settings page must be rendered before this function gets called.
loaded = true;
render_alert_words_ui();
rerender_alert_words_ui();
$("#create_alert_word_form").on("click", "#create_alert_word_button", () => {
const word = $("#create_alert_word_name").val();

View File

@ -78,7 +78,7 @@ export function dispatch_normal_event(event) {
switch (event.type) {
case "alert_words":
alert_words.set_words(event.alert_words);
alert_words_ui.render_alert_words_ui();
alert_words_ui.rerender_alert_words_ui();
break;
case "attachment":