fix(ar-modal): updateNotificationSettings not updating state (#28409)

This commit is contained in:
Jack 2024-05-13 11:38:12 -05:00 committed by GitHub
parent 89dbb9888c
commit d871b4d267
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 1 deletions

View File

@ -553,13 +553,17 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
index: number,
setting: NotificationSetting,
) => {
// if you've changed notification method
const settings: NotificationSetting[] = [...notificationSettings];
settings[index] = setting;
// if you've changed notification method -> remove trailing methods
if (notificationSettings[index].method !== setting.method) {
notificationSettings[index] = setting;
setNotificationSettings(
notificationSettings.filter((_, idx) => idx <= index),
);
if (notificationSettings.length - 1 > index) {
setNotificationAddState('active');
}
@ -567,6 +571,8 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
if (setting.method !== undefined && notificationAddState !== 'hidden') {
setNotificationAddState('active');
}
} else {
setNotificationSettings(settings);
}
};