Fix error thrown on first time setup when no storage locations exist
This commit is contained in:
parent
e9854cc722
commit
ad8f4ddfbf
2 changed files with 17 additions and 22 deletions
|
|
@ -1,12 +1,15 @@
|
|||
@using LANCommander.SDK.Enums
|
||||
@inject StorageLocationService StorageLocationService
|
||||
|
||||
<Select
|
||||
DataSource="StorageLocations"
|
||||
ItemValue="l => l"
|
||||
ItemLabel="l => l.Path"
|
||||
@bind-Value="Value"
|
||||
OnSelectedItemChanged="ValueChanged" />
|
||||
@if (StorageLocations.Any())
|
||||
{
|
||||
<Select
|
||||
DataSource="StorageLocations"
|
||||
ItemValue="l => l"
|
||||
ItemLabel="l => l.Path"
|
||||
@bind-Value="Value"
|
||||
OnSelectedItemChanged="ValueChanged" />
|
||||
}
|
||||
|
||||
@code {
|
||||
[Parameter] public StorageLocation Value { get; set; } = new();
|
||||
|
|
|
|||
|
|
@ -146,38 +146,30 @@
|
|||
|
||||
try
|
||||
{
|
||||
SavesStorageLocation = await StorageLocationService
|
||||
var existingSaves = await StorageLocationService
|
||||
.AsNoTracking()
|
||||
.FirstOrDefaultAsync(l => l.Type == StorageLocationType.Save && l.Default);
|
||||
|
||||
if (existingSaves != null)
|
||||
SavesStorageLocation = existingSaves;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger?.LogError(ex, "Couldn't retrieve existing store locations");
|
||||
|
||||
SavesStorageLocation = new StorageLocation
|
||||
{
|
||||
Path = Path.Join(AppPaths.GetConfigDirectory(), "Saves"),
|
||||
Type = StorageLocationType.Save,
|
||||
Default = true,
|
||||
};
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
MediaStorageLocation = await StorageLocationService
|
||||
var existingMedia = await StorageLocationService
|
||||
.AsNoTracking()
|
||||
.FirstOrDefaultAsync(l => l.Type == SDK.Enums.StorageLocationType.Media && l.Default);
|
||||
|
||||
if (existingMedia != null)
|
||||
MediaStorageLocation = existingMedia;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger?.LogError(ex, "Couldn't retrieve existing store locations");
|
||||
|
||||
MediaStorageLocation = new StorageLocation
|
||||
{
|
||||
Path = Path.Join(AppPaths.GetConfigDirectory(), "Media"),
|
||||
Type = StorageLocationType.Media,
|
||||
Default = true,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue