Fixed missed row numbers of providers

This commit is contained in:
tsommer committed 2024-05-19 20:28:25 +02:00
1 parent b485da7aa9
commit 276a33a52e
5 files changed
+25 -3

No files matched your search

@@ -20,7 +20,7 @@
<MudTh Style="text-align: left;">Actions</MudTh>
</HeaderContent>
<RowTemplate>
<MudTd></MudTd>
<MudTd>@context.Num</MudTd>
<MudTd>@context.InstanceName</MudTd>
<MudTd>@context.UsedProvider</MudTd>
<MudTd>@context.Model</MudTd>
@@ -52,6 +52,8 @@ public partial class Settings : ComponentBase
return;
var addedProvider = (AIStudio.Settings.Provider)dialogResult.Data;
addedProvider = addedProvider with { Num = this.SettingsManager.ConfigurationData.NextProviderNum++ };
this.SettingsManager.ConfigurationData.Providers.Add(addedProvider);
await this.SettingsManager.StoreSettings();
}
@@ -60,6 +62,7 @@ public partial class Settings : ComponentBase
{
var dialogParameters = new DialogParameters<ProviderDialog>
{
{ x => x.DataNum, provider.Num },
{ x => x.DataId, provider.Id },
{ x => x.DataInstanceName, provider.InstanceName },
{ x => x.DataProvider, provider.UsedProvider },
@@ -73,6 +76,12 @@ public partial class Settings : ComponentBase
return;
var editedProvider = (AIStudio.Settings.Provider)dialogResult.Data;
// Set the provider number if it's not set. This is important for providers
// added before we started saving the provider number.
if(editedProvider.Num == 0)
editedProvider = editedProvider with { Num = this.SettingsManager.ConfigurationData.NextProviderNum++ };
this.SettingsManager.ConfigurationData.Providers[this.SettingsManager.ConfigurationData.Providers.IndexOf(provider)] = editedProvider;
await this.SettingsManager.StoreSettings();
}