Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
buddy_list: Refactor maybe_remove_user_id for ease of adding user lists.
evykassirere7f5e526bc66
diff --git a/web/src/buddy_list.ts b/web/src/buddy_list.tsindex 911b5ed853c..5c86db7d7c5 100644--- a/web/src/buddy_list.ts+++ b/web/src/buddy_list.ts@@ -600,17 +600,19 @@ export class BuddyList extends BuddyListConf {}maybe_remove_user_id(opts: {user_id: number}): void {- let pos = this.users_matching_view_ids.indexOf(opts.user_id);- if (pos >= 0) {- this.users_matching_view_ids.splice(pos, 1);- } else {- pos = this.other_user_ids.indexOf(opts.user_id);- if (pos < 0) {- return;+ let was_removed = false;+ for (const user_id_list of [this.users_matching_view_ids, this.other_user_ids]) {+ const pos = user_id_list.indexOf(opts.user_id);+ if (pos >= 0) {+ user_id_list.splice(pos, 1);+ was_removed = true;+ break;}- this.other_user_ids.splice(pos, 1);}- pos = this.all_user_ids.indexOf(opts.user_id);+ if (!was_removed) {+ return;+ }+ const pos = this.all_user_ids.indexOf(opts.user_id);this.all_user_ids.splice(pos, 1);if (pos < this.render_count) {