mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
ModListGallery loading error display
This commit is contained in:
parent
dbce33fb45
commit
b5edd9ce26
Wabbajack
@ -10,6 +10,8 @@ using System.Threading.Tasks;
|
||||
using DynamicData;
|
||||
using DynamicData.Binding;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib;
|
||||
using Wabbajack.Lib.ModListRegistry;
|
||||
|
||||
@ -23,6 +25,9 @@ namespace Wabbajack
|
||||
|
||||
private int missingHashFallbackCounter;
|
||||
|
||||
[Reactive]
|
||||
public IErrorResponse Error { get; set; }
|
||||
|
||||
public ModListGalleryVM(MainWindowVM mainWindowVM)
|
||||
: base(mainWindowVM)
|
||||
{
|
||||
@ -32,8 +37,18 @@ namespace Wabbajack
|
||||
.ObserveOn(RxApp.TaskpoolScheduler)
|
||||
.SelectTask(async _ =>
|
||||
{
|
||||
return (await ModlistMetadata.LoadFromGithub())
|
||||
.AsObservableChangeSet(x => x.DownloadMetadata?.Hash ?? $"Fallback{missingHashFallbackCounter++}");
|
||||
try
|
||||
{
|
||||
Error = null;
|
||||
var list = await ModlistMetadata.LoadFromGithub();
|
||||
return list.AsObservableChangeSet(x => x.DownloadMetadata?.Hash ?? $"Fallback{missingHashFallbackCounter++}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utils.Error(ex);
|
||||
Error = ErrorResponse.Fail(ex);
|
||||
return Observable.Empty<IChangeSet<ModlistMetadata, string>>();
|
||||
}
|
||||
})
|
||||
// Unsubscribe and release when not active
|
||||
.FlowSwitch(
|
||||
|
@ -52,6 +52,16 @@
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
<mahapps:ProgressRing x:Name="LoadingRing" Grid.Row="1" />
|
||||
<iconPacks:PackIconControl
|
||||
x:Name="ErrorIcon"
|
||||
Grid.Row="1"
|
||||
Width="55"
|
||||
Height="55"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{StaticResource ErrorBrush}"
|
||||
Kind="{x:Static iconPacks:PackIconMaterialKind.AlertCircle}"
|
||||
ToolTip="Error loading modlist gallery" />
|
||||
<local:TopProgressView
|
||||
Title="Browsing Modlists"
|
||||
Grid.Row="0"
|
||||
|
@ -23,10 +23,22 @@ namespace Wabbajack
|
||||
this.WhenAny(x => x.ViewModel.ModLists)
|
||||
.BindToStrict(this, x => x.ModListGalleryControl.ItemsSource)
|
||||
.DisposeWith(dispose);
|
||||
this.WhenAny(x => x.ViewModel.ModLists.Count)
|
||||
.Select(x => x > 0 ? Visibility.Collapsed : Visibility.Visible)
|
||||
Observable.CombineLatest(
|
||||
this.WhenAny(x => x.ViewModel.ModLists.Count)
|
||||
.Select(x => x > 0),
|
||||
this.WhenAny(x => x.ViewModel.Error)
|
||||
.Select(e => e?.Succeeded ?? true),
|
||||
resultSelector: (hasContent, succeeded) =>
|
||||
{
|
||||
return !hasContent && succeeded;
|
||||
})
|
||||
.Select(x => x ? Visibility.Visible : Visibility.Collapsed)
|
||||
.BindToStrict(this, x => x.LoadingRing.Visibility)
|
||||
.DisposeWith(dispose);
|
||||
this.WhenAny(x => x.ViewModel.Error)
|
||||
.Select(e => (e?.Succeeded ?? true) ? Visibility.Collapsed : Visibility.Visible)
|
||||
.BindToStrict(this, x => x.ErrorIcon.Visibility)
|
||||
.DisposeWith(dispose);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user