From 73a2f3f0280d0931210ca89ecfcb555b530e3980 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Fri, 14 Nov 2025 11:04:58 +0100 Subject: [PATCH] Fixed profile null / default checks --- .../Assistants/MyTasks/AssistantMyTasks.razor.cs | 2 +- app/MindWork AI Studio/Components/ChatComponent.razor.cs | 6 +----- app/MindWork AI Studio/Settings/SettingsManager.cs | 4 ++-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/app/MindWork AI Studio/Assistants/MyTasks/AssistantMyTasks.razor.cs b/app/MindWork AI Studio/Assistants/MyTasks/AssistantMyTasks.razor.cs index fe1ec919..fa5d1e27 100644 --- a/app/MindWork AI Studio/Assistants/MyTasks/AssistantMyTasks.razor.cs +++ b/app/MindWork AI Studio/Assistants/MyTasks/AssistantMyTasks.razor.cs @@ -85,7 +85,7 @@ public partial class AssistantMyTasks : AssistantBaseCore private string? ValidateProfile(Profile profile) { - if(profile == default || profile == Profile.NO_PROFILE) + if(profile == Profile.NO_PROFILE) return T("Please select one of your profiles."); return null; diff --git a/app/MindWork AI Studio/Components/ChatComponent.razor.cs b/app/MindWork AI Studio/Components/ChatComponent.razor.cs index 8359e0ee..94ee2385 100644 --- a/app/MindWork AI Studio/Components/ChatComponent.razor.cs +++ b/app/MindWork AI Studio/Components/ChatComponent.razor.cs @@ -801,11 +801,7 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable // Try to select the profile: if (!string.IsNullOrWhiteSpace(chatProfile)) - { - this.currentProfile = this.SettingsManager.ConfigurationData.Profiles.FirstOrDefault(x => x.Id == chatProfile); - if(this.currentProfile == default) - this.currentProfile = Profile.NO_PROFILE; - } + this.currentProfile = this.SettingsManager.ConfigurationData.Profiles.FirstOrDefault(x => x.Id == chatProfile) ?? Profile.NO_PROFILE; // Try to select the chat template: if (!string.IsNullOrWhiteSpace(chatChatTemplate)) diff --git a/app/MindWork AI Studio/Settings/SettingsManager.cs b/app/MindWork AI Studio/Settings/SettingsManager.cs index 54e6f1b3..7bab00cb 100644 --- a/app/MindWork AI Studio/Settings/SettingsManager.cs +++ b/app/MindWork AI Studio/Settings/SettingsManager.cs @@ -260,11 +260,11 @@ public sealed class SettingsManager public Profile GetPreselectedProfile(Tools.Components component) { var preselection = component.PreselectedProfile(this); - if (preselection != default) + if (preselection != Profile.NO_PROFILE) return preselection; preselection = this.ConfigurationData.Profiles.FirstOrDefault(x => x.Id == this.ConfigurationData.App.PreselectedProfile); - return preselection != default ? preselection : Profile.NO_PROFILE; + return preselection ?? Profile.NO_PROFILE; } public ChatTemplate GetPreselectedChatTemplate(Tools.Components component)