Fixed profile null / default checks

This commit is contained in:
Thorsten Sommer 2025-11-14 11:04:58 +01:00
parent 8bb7549c39
commit 73a2f3f028
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
3 changed files with 4 additions and 8 deletions

View File

@ -85,7 +85,7 @@ public partial class AssistantMyTasks : AssistantBaseCore<SettingsDialogMyTasks>
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;

View File

@ -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))

View File

@ -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)