mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 23:13:25 +00:00
buddy_list: Make insert_or_move a bulk operation.
This commit is contained in:
@@ -92,12 +92,7 @@ export function redraw_user(user_id: number): void {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const info = buddy_data.get_item(user_id);
|
buddy_list.insert_or_move([user_id]);
|
||||||
|
|
||||||
buddy_list.insert_or_move({
|
|
||||||
user_id,
|
|
||||||
item: info,
|
|
||||||
});
|
|
||||||
update_presence_indicators();
|
update_presence_indicators();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -319,11 +319,6 @@ export function get_title_data(user_ids_string: string, is_group: boolean): Titl
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function get_item(user_id: number): BuddyUserInfo {
|
|
||||||
const info = info_for(user_id);
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function get_items_for_users(user_ids: number[]): BuddyUserInfo[] {
|
export function get_items_for_users(user_ids: number[]): BuddyUserInfo[] {
|
||||||
const user_info = user_ids.map((user_id) => info_for(user_id));
|
const user_info = user_ids.map((user_id) => info_for(user_id));
|
||||||
return user_info;
|
return user_info;
|
||||||
|
|||||||
@@ -928,9 +928,14 @@ export class BuddyList extends BuddyListConf {
|
|||||||
this.update_padding();
|
this.update_padding();
|
||||||
}
|
}
|
||||||
|
|
||||||
insert_or_move(opts: {user_id: number; item: BuddyUserInfo}): void {
|
insert_or_move(user_ids: number[]): void {
|
||||||
const user_id = opts.user_id;
|
// TODO: Further optimize this function by clubbing DOM updates from
|
||||||
const item = opts.item;
|
// multiple insertions/movements into a single update.
|
||||||
|
|
||||||
|
const all_participant_ids = this.render_data.all_participant_ids;
|
||||||
|
const users = buddy_data.get_items_for_users(user_ids);
|
||||||
|
for (const user of users) {
|
||||||
|
const user_id = user.user_id;
|
||||||
|
|
||||||
this.maybe_remove_user_id({user_id});
|
this.maybe_remove_user_id({user_id});
|
||||||
|
|
||||||
@@ -947,7 +952,7 @@ export class BuddyList extends BuddyListConf {
|
|||||||
current_sub?.stream_id,
|
current_sub?.stream_id,
|
||||||
);
|
);
|
||||||
let user_id_list;
|
let user_id_list;
|
||||||
if (this.render_data.all_participant_ids.has(user_id)) {
|
if (all_participant_ids.has(user_id)) {
|
||||||
user_id_list = this.participant_user_ids;
|
user_id_list = this.participant_user_ids;
|
||||||
} else if (is_subscribed_user) {
|
} else if (is_subscribed_user) {
|
||||||
user_id_list = this.users_matching_view_ids;
|
user_id_list = this.users_matching_view_ids;
|
||||||
@@ -967,14 +972,15 @@ export class BuddyList extends BuddyListConf {
|
|||||||
user_id_list.splice(new_pos_in_user_list, 0, user_id);
|
user_id_list.splice(new_pos_in_user_list, 0, user_id);
|
||||||
this.all_user_ids.splice(new_pos_in_all_users, 0, user_id);
|
this.all_user_ids.splice(new_pos_in_all_users, 0, user_id);
|
||||||
|
|
||||||
const html = this.item_to_html({item});
|
const html = this.item_to_html({item: user});
|
||||||
this.insert_new_html({
|
this.insert_new_html({
|
||||||
html,
|
html,
|
||||||
new_user_id,
|
new_user_id,
|
||||||
is_subscribed_user,
|
is_subscribed_user,
|
||||||
is_participant_user: this.render_data.all_participant_ids.has(user_id),
|
is_participant_user: all_participant_ids.has(user_id),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fill_screen_with_content(): void {
|
fill_screen_with_content(): void {
|
||||||
let height = this.height_to_fill();
|
let height = this.height_to_fill();
|
||||||
|
|||||||
Reference in New Issue
Block a user