diff --git a/web/src/settings_components.ts b/web/src/settings_components.ts index 35381ac075..d4988172b4 100644 --- a/web/src/settings_components.ts +++ b/web/src/settings_components.ts @@ -1414,11 +1414,9 @@ export function get_group_setting_widget(setting_name: string): GroupSettingPill } export function set_group_setting_widget_value( - property_name: string, + pill_widget: GroupSettingPillContainer, property_value: GroupSettingType, ): void { - const pill_widget = get_group_setting_widget(property_name); - assert(pill_widget !== null); pill_widget.clear(); if (typeof property_value === "number") { @@ -1476,7 +1474,7 @@ export function create_group_setting_widget({ } if (group !== undefined) { - set_group_setting_widget_value(setting_name, group[setting_name]); + set_group_setting_widget_value(pill_widget, group[setting_name]); pill_widget.onPillCreate(() => { save_discard_group_widget_status_handler($("#group_permission_settings"), group); @@ -1490,13 +1488,13 @@ export function create_group_setting_widget({ "group", )!.default_group_name; if (default_group_name === "group_creator") { - set_group_setting_widget_value("new_group_" + setting_name, { + set_group_setting_widget_value(pill_widget, { direct_members: [current_user.user_id], direct_subgroups: [], }); } else { const default_group_id = user_groups.get_user_group_from_name(default_group_name)!.id; - set_group_setting_widget_value("new_group_" + setting_name, default_group_id); + set_group_setting_widget_value(pill_widget, default_group_id); } } } diff --git a/web/src/settings_org.js b/web/src/settings_org.js index 15971772a9..a5d9f8e34b 100644 --- a/web/src/settings_org.js +++ b/web/src/settings_org.js @@ -617,7 +617,8 @@ export function discard_group_property_element_changes(elem, group) { if (property_name === "can_mention_group") { settings_components.set_dropdown_list_widget_setting_value(property_name, property_value); } else if (property_name === "can_manage_group") { - settings_components.set_group_setting_widget_value(property_name, property_value); + const pill_widget = settings_components.get_group_setting_widget(property_name); + settings_components.set_group_setting_widget_value(pill_widget, property_value); } else if (property_value !== undefined) { settings_components.set_input_element_value($elem, property_value); } else {