From 7c6ddc844ca82101f08e5cf5d4b7c73a3fc8bf87 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Sat, 12 Apr 2025 23:57:55 +0200 Subject: [PATCH] Fix: Settings encryption message --- .../ViewModels/SettingsProfilesViewModel.cs | 58 +++++++++---------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/Source/NETworkManager/ViewModels/SettingsProfilesViewModel.cs b/Source/NETworkManager/ViewModels/SettingsProfilesViewModel.cs index 136816fc49..6cb82e7a57 100644 --- a/Source/NETworkManager/ViewModels/SettingsProfilesViewModel.cs +++ b/Source/NETworkManager/ViewModels/SettingsProfilesViewModel.cs @@ -187,41 +187,39 @@ private async void EnableEncryptionAction() settings.NegativeButtonText = Strings.Cancel; settings.DefaultButtonFocus = MessageDialogResult.Affirmative; - if (await _dialogCoordinator.ShowMessageAsync(this, Strings.Disclaimer, - Strings.ProfileEncryptionDisclaimer, - MessageDialogStyle.AffirmativeAndNegative) == MessageDialogResult.Affirmative) + if (await _dialogCoordinator.ShowMessageAsync(this, Strings.Disclaimer, Strings.ProfileEncryptionDisclaimer, MessageDialogStyle.AffirmativeAndNegative, settings) != MessageDialogResult.Affirmative) + return; + + var customDialog = new CustomDialog { - var customDialog = new CustomDialog - { - Title = Strings.SetMasterPassword - }; + Title = Strings.SetMasterPassword + }; - var credentialsSetPasswordViewModel = new CredentialsSetPasswordViewModel(async instance => - { - await _dialogCoordinator.HideMetroDialogAsync(this, customDialog); + var credentialsSetPasswordViewModel = new CredentialsSetPasswordViewModel(async instance => + { + await _dialogCoordinator.HideMetroDialogAsync(this, customDialog); - try - { - ProfileManager.EnableEncryption(SelectedProfileFile, instance.Password); - } - catch (Exception ex) - { - var metroDialogSettings = AppearanceManager.MetroDialog; - metroDialogSettings.AffirmativeButtonText = Strings.OK; - - await _dialogCoordinator.ShowMessageAsync(this, Strings.EncryptionError, - $"{Strings.EncryptionErrorMessage}\n\n{ex.Message}", - MessageDialogStyle.Affirmative, metroDialogSettings); - } - }, async _ => { await _dialogCoordinator.HideMetroDialogAsync(this, customDialog); }); - - customDialog.Content = new CredentialsSetPasswordDialog + try { - DataContext = credentialsSetPasswordViewModel - }; + ProfileManager.EnableEncryption(SelectedProfileFile, instance.Password); + } + catch (Exception ex) + { + var metroDialogSettings = AppearanceManager.MetroDialog; + metroDialogSettings.AffirmativeButtonText = Strings.OK; - await _dialogCoordinator.ShowMetroDialogAsync(this, customDialog); - } + await _dialogCoordinator.ShowMessageAsync(this, Strings.EncryptionError, + $"{Strings.EncryptionErrorMessage}\n\n{ex.Message}", + MessageDialogStyle.Affirmative, metroDialogSettings); + } + }, async _ => { await _dialogCoordinator.HideMetroDialogAsync(this, customDialog); }); + + customDialog.Content = new CredentialsSetPasswordDialog + { + DataContext = credentialsSetPasswordViewModel + }; + + await _dialogCoordinator.ShowMetroDialogAsync(this, customDialog); } public ICommand ChangeMasterPasswordCommand => new RelayCommand(_ => ChangeMasterPasswordAction());