Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

settings: Fix redraw_bots_list when adding/removing bots.

Tim Abbott09c6ee6468e3
diff --git a/frontend_tests/node_tests/dispatch.js b/frontend_tests/node_tests/dispatch.js
index 53542e4135d..ae2aaf4cadf 100644
--- a/frontend_tests/node_tests/dispatch.js
+++ b/frontend_tests/node_tests/dispatch.js
@@ -509,14 +509,13 @@ run_test("realm_bot add", ({override}) => {
const admin_stub = make_stub();
override(bot_data, "add", bot_stub.f);
override(settings_bots, "render_bots", () => {});
- override(settings_users, "update_bot_data", admin_stub.f);
+ override(settings_users, "redraw_bots_list", admin_stub.f);
dispatch(event);
assert.equal(bot_stub.num_calls, 1);
assert.equal(admin_stub.num_calls, 1);
const args = bot_stub.get_args("bot");
assert_same(args.bot, event.bot);
- admin_stub.get_args("update_user_id", "update_bot_data");
});
run_test("realm_bot remove", ({override}) => {
diff --git a/static/js/server_events_dispatch.js b/static/js/server_events_dispatch.js
index f9289ff3f04..a458ec4af98 100644
--- a/static/js/server_events_dispatch.js
+++ b/static/js/server_events_dispatch.js
@@ -328,7 +328,7 @@ export function dispatch_normal_event(event) {
case "add":
bot_data.add(event.bot);
settings_bots.render_bots();
- settings_users.update_bot_data(event.bot.user_id);
+ settings_users.redraw_bots_list();
break;
case "remove":
bot_data.deactivate(event.bot.user_id);
diff --git a/static/js/settings_users.js b/static/js/settings_users.js
index c21370fbe87..bfeb69a0219 100644
--- a/static/js/settings_users.js
+++ b/static/js/settings_users.js
@@ -374,6 +374,11 @@ export function redraw_bots_list() {
return;
}
+ // In order to properly redraw after a user may have been added,
+ // we need to update the bot_list_widget with the new set of bot
+ // user IDs to display.
+ const bot_user_ids = bot_data.all_user_ids();
+ bot_list_widget.replace_list_data(bot_user_ids);
bot_list_widget.hard_redraw();
}