From 8d2b4611036cfad7b5c31a75b6bd5e3f1c497b4a Mon Sep 17 00:00:00 2001 From: Konstantin Markov Date: Thu, 1 Aug 2024 13:33:38 +0300 Subject: [PATCH] Fix notifications on cancel (#4576) --- .../directives/UserPreferencesDirective.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/scripts/apps/users/directives/UserPreferencesDirective.ts b/scripts/apps/users/directives/UserPreferencesDirective.ts index ece1d5a62a..bf3c213f3d 100644 --- a/scripts/apps/users/directives/UserPreferencesDirective.ts +++ b/scripts/apps/users/directives/UserPreferencesDirective.ts @@ -58,14 +58,18 @@ export function UserPreferencesDirective( scope.emailNotificationsFromExtensions = {}; - for (const extension of Object.values(extensions)) { - for (const [key, value] of Object.entries(extension.activationResult.contributions?.notifications ?? [])) { - if (value.type === 'email') { - preferencesService.registerUserPreference(key, 1); - scope.emailNotificationsFromExtensions[key] = preferencesService.getSync(key); + scope.buildNotificationsFromExtensions = function() { + for (const extension of Object.values(extensions)) { + for (const [key, value] of Object.entries(extension.activationResult.contributions?.notifications ?? [])) { + if (value.type === 'email') { + preferencesService.registerUserPreference(key, 1); + scope.emailNotificationsFromExtensions[key] = preferencesService.getSync(key); + } } } - } + }; + + scope.buildNotificationsFromExtensions(); scope.toggleEmailGroupNotifications = function() { const isGroupEnabled = scope.preferences['email:notification'].enabled; @@ -290,6 +294,8 @@ export function UserPreferencesDirective( } }); + scope.buildNotificationsFromExtensions(); + // metadata service initialization is needed if its // values object is undefined or any of the needed // data buckets are missing in it