user_groups: Do not remove the user group row if user can join again.

We now do not remove the user group row immediately from "Your groups"
panel when user is removed from the group, if the user can join that
group again by themselves. This makes the behavior similar to what
we have for streams.

(cherry picked from commit 377df9e4db)
This commit is contained in:
Sahil Batra 2023-12-20 13:10:27 +05:30 committed by Alex Vandiver
parent e311b372cb
commit 660edba4dd
1 changed files with 14 additions and 1 deletions

View File

@ -201,7 +201,20 @@ export function handle_member_edit_event(group_id, user_ids) {
// or remove the group-row on the left panel accordingly.
const tab_key = get_active_data().$tabs.first().attr("data-tab-key");
if (tab_key === "your-groups" && user_ids.includes(people.my_current_user_id())) {
redraw_user_group_list();
if (user_groups.is_user_in_group(group_id, people.my_current_user_id())) {
// We add the group row to list if the current user
// is added to it. The whole list is redrawed to
// maintain the sorted order of groups.
redraw_user_group_list();
} else if (!settings_data.can_edit_user_group(group_id)) {
// We remove the group row immediately only if the
// user cannot join the group again themselves.
const group_row = row_for_group_id(group_id);
if (group_row.length) {
group_row.remove();
update_empty_left_panel_message();
}
}
}
// update display of check-mark.