mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 09:27:43 +00:00
buddy_list: Refactor maybe_remove_user_id for ease of adding user lists.
This commit is contained in:
@@ -600,17 +600,19 @@ export class BuddyList extends BuddyListConf {
|
|||||||
}
|
}
|
||||||
|
|
||||||
maybe_remove_user_id(opts: {user_id: number}): void {
|
maybe_remove_user_id(opts: {user_id: number}): void {
|
||||||
let pos = this.users_matching_view_ids.indexOf(opts.user_id);
|
let was_removed = false;
|
||||||
if (pos >= 0) {
|
for (const user_id_list of [this.users_matching_view_ids, this.other_user_ids]) {
|
||||||
this.users_matching_view_ids.splice(pos, 1);
|
const pos = user_id_list.indexOf(opts.user_id);
|
||||||
} else {
|
if (pos >= 0) {
|
||||||
pos = this.other_user_ids.indexOf(opts.user_id);
|
user_id_list.splice(pos, 1);
|
||||||
if (pos < 0) {
|
was_removed = true;
|
||||||
return;
|
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);
|
this.all_user_ids.splice(pos, 1);
|
||||||
|
|
||||||
if (pos < this.render_count) {
|
if (pos < this.render_count) {
|
||||||
|
|||||||
Reference in New Issue
Block a user