diff --git a/apps/red-ui/src/app/modules/account/screens/notifications/notifications-screen/notifications-screen.component.ts b/apps/red-ui/src/app/modules/account/screens/notifications/notifications-screen/notifications-screen.component.ts index 637c3e69e..1f80c321c 100644 --- a/apps/red-ui/src/app/modules/account/screens/notifications/notifications-screen/notifications-screen.component.ts +++ b/apps/red-ui/src/app/modules/account/screens/notifications/notifications-screen/notifications-screen.component.ts @@ -4,6 +4,7 @@ import { NotificationPreferencesService } from '../../../services/notification-p import { BaseFormComponent, getConfig, LoadingService, Toaster } from '@iqser/common-ui'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { + DocumentNotificationsTypes, NotificationCategoriesValues, NotificationGroupsKeys, NotificationGroupsValues, @@ -77,15 +78,7 @@ export class NotificationsScreenComponent extends BaseFormComponent implements O async save() { this.#loadingService.start(); try { - const preferences = - !this.isPreferenceChecked('inAppNotifications', 'ASSIGN_APPROVER') && this.#config.IS_DOCUMINE - ? { - ...this.form.value, - inAppNotifications: this.form - .get('inAppNotifications') - .value.filter((preference: string) => !RSS_EXCLUDED_SETTINGS.includes(preference)), - } - : this.form.value; + const preferences = this.#filterNotificationPreferences(); await firstValueFrom(this.#notificationPreferencesService.update(preferences)); } catch (e) { this.#toaster.error(_('notifications-screen.error.generic')); @@ -115,4 +108,27 @@ export class NotificationsScreenComponent extends BaseFormComponent implements O this.#loadingService.stop(); } + + #filterNotificationPreferences() { + if (!this.#config.IS_DOCUMINE) { + return this.form.value; + } + + if (!this.isPreferenceChecked('inAppNotifications', DocumentNotificationsTypes.assignApprover)) { + return { + ...this.form.value, + inAppNotifications: this.form + .get('inAppNotifications') + .value.filter((preference: string) => !RSS_EXCLUDED_SETTINGS.includes(preference)), + }; + } + if (!this.form.get('inAppNotifications').value.includes(DocumentNotificationsTypes.assignReviewer)) { + return { + ...this.form.value, + inAppNotifications: [...this.form.get('inAppNotifications').value, DocumentNotificationsTypes.assignReviewer], + }; + } + + return this.form.value; + } }