mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Workshop - Improve child navigation performance
This commit is contained in:
1 parent
cac44d748d
commit
62057d657a
27 files changed
+309
-212
No files matched your search
@@ -3,7 +3,6 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:profile="clr-namespace:Artemis.UI.Screens.Workshop.Profile"
|
||||
xmlns:mdxaml="https://github.com/whistyun/Markdown.Avalonia.Tight"
|
||||
xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||
xmlns:ui="clr-namespace:Artemis.UI"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="800"
|
||||
@@ -14,7 +13,7 @@
|
||||
<Border Classes="card" VerticalAlignment="Top">
|
||||
<ContentControl Content="{CompiledBinding EntryInfoViewModel}" />
|
||||
</Border>
|
||||
<Border Classes="card" VerticalAlignment="Top" IsVisible="{CompiledBinding Entry.Releases.Count}">
|
||||
<Border Classes="card" VerticalAlignment="Top" IsVisible="{CompiledBinding Entry.Releases.Count, FallbackValue=False}">
|
||||
<ContentControl Content="{CompiledBinding EntryReleasesViewModel}" />
|
||||
</Border>
|
||||
</StackPanel>
|
||||
@@ -27,6 +26,6 @@
|
||||
</controls:Frame>
|
||||
</ScrollViewer>
|
||||
|
||||
<ContentControl Grid.Row="1" Grid.Column="2" IsVisible="{CompiledBinding Entry.Images.Count}" Content="{CompiledBinding EntryImagesViewModel}" />
|
||||
<ContentControl Grid.Row="1" Grid.Column="2" IsVisible="{CompiledBinding Entry.Images.Count, FallbackValue=False}" Content="{CompiledBinding EntryImagesViewModel}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -11,7 +11,8 @@ public partial class ProfileDetailsView : ReactiveUserControl<ProfileDetailsView
|
||||
{
|
||||
InitializeComponent();
|
||||
this.WhenActivated(d => ViewModel.WhenAnyValue(vm => vm.Screen)
|
||||
.Subscribe(screen => RouterFrame.NavigateFromObject(screen ?? ViewModel?.ProfileDescriptionViewModel))
|
||||
.WhereNotNull()
|
||||
.Subscribe(screen => RouterFrame.NavigateFromObject(screen))
|
||||
.DisposeWith(d));
|
||||
}
|
||||
}
|
||||
@@ -17,32 +17,32 @@ namespace Artemis.UI.Screens.Workshop.Profile;
|
||||
public partial class ProfileDetailsViewModel : RoutableHostScreen<RoutableScreen, WorkshopDetailParameters>
|
||||
{
|
||||
private readonly IWorkshopClient _client;
|
||||
private readonly Func<IEntryDetails, EntryInfoViewModel> _getEntryInfoViewModel;
|
||||
private readonly ProfileDescriptionViewModel _profileDescriptionViewModel;
|
||||
private readonly Func<IEntryDetails, EntryReleasesViewModel> _getEntryReleasesViewModel;
|
||||
private readonly Func<IEntryDetails, EntryImagesViewModel> _getEntryImagesViewModel;
|
||||
|
||||
[Notify] private IEntryDetails? _entry;
|
||||
[Notify] private EntryInfoViewModel? _entryInfoViewModel;
|
||||
[Notify] private EntryReleasesViewModel? _entryReleasesViewModel;
|
||||
[Notify] private EntryImagesViewModel? _entryImagesViewModel;
|
||||
|
||||
public ProfileDetailsViewModel(IWorkshopClient client,
|
||||
ProfileDescriptionViewModel profileDescriptionViewModel,
|
||||
Func<IEntryDetails, EntryInfoViewModel> getEntryInfoViewModel,
|
||||
EntryInfoViewModel entryInfoViewModel,
|
||||
Func<IEntryDetails, EntryReleasesViewModel> getEntryReleasesViewModel,
|
||||
Func<IEntryDetails, EntryImagesViewModel> getEntryImagesViewModel)
|
||||
{
|
||||
_client = client;
|
||||
_getEntryInfoViewModel = getEntryInfoViewModel;
|
||||
_profileDescriptionViewModel = profileDescriptionViewModel;
|
||||
_getEntryReleasesViewModel = getEntryReleasesViewModel;
|
||||
_getEntryImagesViewModel = getEntryImagesViewModel;
|
||||
|
||||
ProfileDescriptionViewModel = profileDescriptionViewModel;
|
||||
EntryInfoViewModel = entryInfoViewModel;
|
||||
RecycleScreen = false;
|
||||
}
|
||||
|
||||
public ProfileDescriptionViewModel ProfileDescriptionViewModel { get; }
|
||||
|
||||
public override RoutableScreen DefaultScreen => _profileDescriptionViewModel;
|
||||
public EntryInfoViewModel EntryInfoViewModel { get; }
|
||||
|
||||
public override async Task OnNavigating(WorkshopDetailParameters parameters, NavigationArguments args, CancellationToken cancellationToken)
|
||||
{
|
||||
if (Entry?.Id != parameters.EntryId)
|
||||
@@ -51,15 +51,19 @@ public partial class ProfileDetailsViewModel : RoutableHostScreen<RoutableScreen
|
||||
|
||||
private async Task GetEntry(long entryId, CancellationToken cancellationToken)
|
||||
{
|
||||
Task grace = Task.Delay(300, cancellationToken);
|
||||
IOperationResult<IGetEntryByIdResult> result = await _client.GetEntryById.ExecuteAsync(entryId, cancellationToken);
|
||||
if (result.IsErrorResult())
|
||||
return;
|
||||
|
||||
// Let the UI settle to avoid lag when deep linking
|
||||
await grace;
|
||||
|
||||
Entry = result.Data?.Entry;
|
||||
EntryInfoViewModel = Entry != null ? _getEntryInfoViewModel(Entry) : null;
|
||||
EntryInfoViewModel.SetEntry(Entry);
|
||||
EntryReleasesViewModel = Entry != null ? _getEntryReleasesViewModel(Entry) : null;
|
||||
EntryImagesViewModel = Entry != null ? _getEntryImagesViewModel(Entry) : null;
|
||||
|
||||
await ProfileDescriptionViewModel.SetEntry(Entry, cancellationToken);
|
||||
await _profileDescriptionViewModel.SetEntry(Entry, cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,8 @@ public partial class ProfileListView : ReactiveUserControl<ProfileListViewModel>
|
||||
{
|
||||
InitializeComponent();
|
||||
this.WhenActivated(d => ViewModel.WhenAnyValue(vm => vm.Screen)
|
||||
.Subscribe(screen => RouterFrame.NavigateFromObject(screen ?? ViewModel?.EntryListViewModel))
|
||||
.WhereNotNull()
|
||||
.Subscribe(screen => RouterFrame.NavigateFromObject(screen))
|
||||
.DisposeWith(d));
|
||||
}
|
||||
}
|
||||
@@ -6,11 +6,12 @@ namespace Artemis.UI.Screens.Workshop.Profile;
|
||||
|
||||
public class ProfileListViewModel : RoutableHostScreen<RoutableScreen>
|
||||
{
|
||||
public EntryListViewModel EntryListViewModel { get; }
|
||||
private readonly EntryListViewModel _entryListViewModel;
|
||||
public override RoutableScreen DefaultScreen => _entryListViewModel;
|
||||
|
||||
public ProfileListViewModel(EntryListViewModel entryListViewModel)
|
||||
{
|
||||
EntryListViewModel = entryListViewModel;
|
||||
EntryListViewModel.EntryType = EntryType.Profile;
|
||||
_entryListViewModel = entryListViewModel;
|
||||
_entryListViewModel.EntryType = EntryType.Profile;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user