From d1be8f9b50a094c63b5283ae4e84543727c191ba Mon Sep 17 00:00:00 2001 From: Prakhar Pratyush Date: Tue, 15 Oct 2024 18:41:09 +0530 Subject: [PATCH] realm_export: Fix '#allow_private_data_export_stats' not live-updated. Earlier, the count of total users and users who consented in the '#allow_private_data_export_stats' text were not being live updated. This commit fixes that behavior. The counts are now live-updated when: * a new user joins * a user is removed * a user is deactivated * a user is reactivated * a user toggles their 'allow_private_data_export' personal setting. Fixes #31201. --- web/src/settings_exports.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/web/src/settings_exports.ts b/web/src/settings_exports.ts index 7b4b47514d..d61c7b1450 100644 --- a/web/src/settings_exports.ts +++ b/web/src/settings_exports.ts @@ -420,6 +420,22 @@ function maybe_store_export_consent_data_and_return(export_consent: ExportConsen return false; } +function update_start_export_modal_stats(): void { + total_users_count = export_consents.size; + users_consented_for_export_count = get_export_consents_having_consent_value(true).length; + if ($("#allow_private_data_export_stats").length) { + $("#allow_private_data_export_stats").text( + $t( + { + defaultMessage: + "Exporting private data for {users_consented_for_export_count} users ({total_users_count} users total).", + }, + {users_consented_for_export_count, total_users_count}, + ), + ); + } +} + export function remove_export_consent_data_and_redraw(user_id: number): void { if (!meta.loaded) { return; @@ -432,6 +448,7 @@ export function remove_export_consent_data_and_redraw(user_id: number): void { export_consents.delete(user_id); redraw_export_consents_list(); + update_start_export_modal_stats(); } export function update_export_consent_data_and_redraw(export_consent: ExportConsent): void { @@ -445,4 +462,5 @@ export function update_export_consent_data_and_redraw(export_consent: ExportCons export_consents.set(export_consent.user_id, export_consent.consented); redraw_export_consents_list(); + update_start_export_modal_stats(); }