mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Fix potential modlists loading crash on slow connections
This commit is contained in:
parent
601ee7eabe
commit
a908c49f26
@ -16,6 +16,7 @@ using Wabbajack.DTOs;
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using DynamicData;
|
||||||
|
|
||||||
namespace Wabbajack
|
namespace Wabbajack
|
||||||
{
|
{
|
||||||
@ -23,6 +24,7 @@ namespace Wabbajack
|
|||||||
{
|
{
|
||||||
private readonly ILogger<HomeVM> _logger;
|
private readonly ILogger<HomeVM> _logger;
|
||||||
private readonly Client _wjClient;
|
private readonly Client _wjClient;
|
||||||
|
private readonly SourceCache<ModListMetadataVM, string> _modLists = new(x => x.Metadata.NamespacedName);
|
||||||
|
|
||||||
public HomeVM(ILogger<HomeVM> logger, Client wjClient)
|
public HomeVM(ILogger<HomeVM> logger, Client wjClient)
|
||||||
{
|
{
|
||||||
@ -37,23 +39,28 @@ namespace Wabbajack
|
|||||||
};
|
};
|
||||||
Process.Start(processStartInfo);
|
Process.Start(processStartInfo);
|
||||||
});
|
});
|
||||||
this.WhenActivated(async disposables =>
|
LoadModLists().FireAndForget();
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Modlists = await _wjClient.LoadLists().DisposeWith(disposables);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "While loading lists");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
private async Task LoadModLists()
|
||||||
|
{
|
||||||
|
using var ll = LoadingLock.WithLoading();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Modlists = await _wjClient.LoadLists();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "While loading lists");
|
||||||
|
ll.Fail();
|
||||||
|
}
|
||||||
|
ll.Succeed();
|
||||||
|
}
|
||||||
|
|
||||||
public ICommand VisitModlistWizardCommand { get; }
|
public ICommand VisitModlistWizardCommand { get; }
|
||||||
public ICommand BrowseCommand { get; }
|
public ICommand BrowseCommand { get; }
|
||||||
public ReactiveCommand<Unit, Unit> UpdateCommand { get; }
|
public ReactiveCommand<Unit, Unit> UpdateCommand { get; }
|
||||||
|
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public ModlistMetadata[] Modlists { get; set; }
|
public ModlistMetadata[] Modlists { get; private set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user