settings: Refactor code to update realm group based settings.

This commit refactors code such that we do not add separate
if condition block for each realm group based settings using
the new API format to send the request accordingly. We now
use a single if-block to update the request data for realm
group permission settings using new API format.
This commit is contained in:
Sahil Batra
2024-06-25 17:15:47 +05:30
committed by Tim Abbott
parent 84cd835a8c
commit d7d83618a4

View File

@@ -971,18 +971,18 @@ export function populate_data_for_realm_settings_request(
continue;
}
if (property_name === "can_create_public_channel_group") {
const realm_group_settings_using_new_api_format = new Set([
"can_create_private_channel_group",
"can_create_public_channel_group",
]);
if (realm_group_settings_using_new_api_format.has(property_name)) {
const old_value = get_realm_settings_property_value(
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
("realm_" + property_name) as RealmSettingProperties,
);
data[property_name] = JSON.stringify({
new: input_value,
old: realm.realm_can_create_public_channel_group,
});
continue;
}
if (property_name === "can_create_private_channel_group") {
data[property_name] = JSON.stringify({
new: input_value,
old: realm.realm_can_create_private_channel_group,
old: old_value,
});
continue;
}