From 02ab5ad7643917c6ebf481cdd25e27d8dbd45a66 Mon Sep 17 00:00:00 2001 From: Robert Date: Sat, 25 Mar 2023 22:44:34 +0100 Subject: [PATCH] Profiles - Retain suspension state toggled by keybinds --- src/Artemis.Core/Services/Storage/ProfileService.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Artemis.Core/Services/Storage/ProfileService.cs b/src/Artemis.Core/Services/Storage/ProfileService.cs index 4b86f3d55..ba1f496e7 100644 --- a/src/Artemis.Core/Services/Storage/ProfileService.cs +++ b/src/Artemis.Core/Services/Storage/ProfileService.cs @@ -109,22 +109,26 @@ internal class ProfileService : IProfileService if (profileConfiguration.HotkeyMode == ProfileConfigurationHotkeyMode.None) return; + bool before = profileConfiguration.IsSuspended; foreach (ArtemisKeyboardKeyEventArgs e in _pendingKeyboardEvents) { if (profileConfiguration.HotkeyMode == ProfileConfigurationHotkeyMode.Toggle) { - if (profileConfiguration.EnableHotkey != null && - profileConfiguration.EnableHotkey.MatchesEventArgs(e)) + if (profileConfiguration.EnableHotkey != null && profileConfiguration.EnableHotkey.MatchesEventArgs(e)) profileConfiguration.IsSuspended = !profileConfiguration.IsSuspended; } else { if (profileConfiguration.IsSuspended && profileConfiguration.EnableHotkey != null && profileConfiguration.EnableHotkey.MatchesEventArgs(e)) profileConfiguration.IsSuspended = false; - if (!profileConfiguration.IsSuspended && profileConfiguration.DisableHotkey != null && profileConfiguration.DisableHotkey.MatchesEventArgs(e)) + else if (!profileConfiguration.IsSuspended && profileConfiguration.DisableHotkey != null && profileConfiguration.DisableHotkey.MatchesEventArgs(e)) profileConfiguration.IsSuspended = true; } } + + // If suspension was changed, save the category + if (before != profileConfiguration.IsSuspended) + SaveProfileCategory(profileConfiguration.Category); } private void CreateDefaultProfileCategories() @@ -422,7 +426,7 @@ internal class ProfileService : IProfileService _profileCategories.Remove(profileCategory); _profileCategoryRepository.Remove(profileCategory.Entity); } - + OnProfileCategoryRemoved(new ProfileCategoryEventArgs(profileCategory)); }