diff --git a/Wallet.Avalonia.Desktop/Program.cs b/Wallet.Avalonia.Desktop/Program.cs index a26d417..ca2de76 100644 --- a/Wallet.Avalonia.Desktop/Program.cs +++ b/Wallet.Avalonia.Desktop/Program.cs @@ -5,14 +5,10 @@ namespace Wallet.Avalonia.Desktop; internal class Program { - // Initialization code. Don't use any Avalonia, third-party APIs or any - // SynchronizationContext-reliant code before AppMain is called: things aren't initialized - // yet and stuff might break. [STAThread] public static void Main(string[] args) => BuildAvaloniaApp() .StartWithClassicDesktopLifetime(args); - // Avalonia configuration, don't remove; also used by visual designer. public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure() .UsePlatformDetect() diff --git a/Wallet.Avalonia/CategoryNavigationView.axaml b/Wallet.Avalonia/CategoryNavigationView.axaml index 565f3e6..7b44830 100644 --- a/Wallet.Avalonia/CategoryNavigationView.axaml +++ b/Wallet.Avalonia/CategoryNavigationView.axaml @@ -33,4 +33,7 @@ + + + diff --git a/Wallet.Avalonia/CreateWalletNavigationView.axaml b/Wallet.Avalonia/CreateWalletNavigationView.axaml index d57145d..a453ca2 100644 --- a/Wallet.Avalonia/CreateWalletNavigationView.axaml +++ b/Wallet.Avalonia/CreateWalletNavigationView.axaml @@ -8,7 +8,7 @@ diff --git a/Wallet/CategoryNavigationViewModel.cs b/Wallet/CategoryNavigationViewModel.cs index dc1077a..5dca3b5 100644 --- a/Wallet/CategoryNavigationViewModel.cs +++ b/Wallet/CategoryNavigationViewModel.cs @@ -8,4 +8,5 @@ public partial class CategoryNavigationViewModel(IServiceProvider provider, IPublisher publisher, ISubscriber subscriber, IDisposer disposer, - string value) : FilterNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, 0, value); \ No newline at end of file + int key, + string value) : FilterNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, key, value); \ No newline at end of file diff --git a/Wallet/ItemChangedHandler.cs b/Wallet/ItemChangedHandler.cs index 8d9b9c9..805bdb4 100644 --- a/Wallet/ItemChangedHandler.cs +++ b/Wallet/ItemChangedHandler.cs @@ -8,12 +8,12 @@ public class ItemChangedHandler(IMediator mediator, { public async Task Handle(ChangedEventArgs args) { - IReadOnlyCollection<(string, int)>? categoryCounts = await mediator.Handle, + IReadOnlyCollection<(string, int)>? counts = await mediator.Handle, IReadOnlyCollection<(string, int)>>(Count.As()); - if (categoryCounts is { Count: > 0 } ) + if (counts is { Count: > 0 } ) { - foreach ((string key, int count) in categoryCounts) + foreach ((string key, int count) in counts) { publisher.Publish(Notify.As(new Item(count)), key); } diff --git a/Wallet/ItemCollectionViewModel.cs b/Wallet/ItemCollectionViewModel.cs index f8a3bb5..45e1c62 100644 --- a/Wallet/ItemCollectionViewModel.cs +++ b/Wallet/ItemCollectionViewModel.cs @@ -11,7 +11,7 @@ public partial class ItemCollectionViewModel : ObservableCollection, INotificationHandler>, INotificationHandler>>, - INavigationBackStack + IKeepAlive { [ObservableProperty] public string? named; diff --git a/Wallet/QueryWalletHandler.cs b/Wallet/QueryWalletHandler.cs index a196179..30ef939 100644 --- a/Wallet/QueryWalletHandler.cs +++ b/Wallet/QueryWalletHandler.cs @@ -28,7 +28,7 @@ public class QueryWalletHandler(IDbContextFactory dbContextFactor { predicate = predicate.And(x => x.State != 2); } - else if (filter == "Starred") + else if (filter == "Favourites") { predicate = predicate.And(x => x.State != 2 && x.State == 1); } diff --git a/Wallet/SynchronizeCategoriesNavigationViewModelHandler.cs b/Wallet/SynchronizeCategoriesNavigationViewModelHandler.cs index cff3778..af351c7 100644 --- a/Wallet/SynchronizeCategoriesNavigationViewModelHandler.cs +++ b/Wallet/SynchronizeCategoriesNavigationViewModelHandler.cs @@ -2,23 +2,27 @@ namespace Wallet; -public class SynchronizeCategoriesNavigationViewModelHandler(IItemConfigurationCollection configurations, +public class SynchronizeCategoriesNavigationViewModelHandler(IMediator mediator, + IItemConfigurationCollection configurations, IServiceFactory serviceFactory, IPublisher publisher) : INotificationHandler> { - public Task Handle(SynchronizeEventArgs args) + public async Task Handle(SynchronizeEventArgs args) { + IReadOnlyCollection<(string Name, int Count)>? counts = await mediator.Handle, + IReadOnlyCollection<(string, int)>>(Count.As()); + foreach (KeyValuePair> configuration in configurations) { - if (serviceFactory.Create(args => args.Initialize(), - configuration.Key) + int count = counts?.FirstOrDefault(x => x.Name == configuration.Key).Count ?? 0; + string name = configuration.Key; + + if (serviceFactory.Create(args => args.Initialize(), count, name) is CategoryNavigationViewModel viewModel) { publisher.Publish(Create.As(viewModel), nameof(CategoriesNavigationViewModel)); } } - - return Task.CompletedTask; } } diff --git a/Wallet/SynchronizeItemCollectionViewModelHandler.cs b/Wallet/SynchronizeItemCollectionViewModelHandler.cs index ab4154d..bb53f02 100644 --- a/Wallet/SynchronizeItemCollectionViewModelHandler.cs +++ b/Wallet/SynchronizeItemCollectionViewModelHandler.cs @@ -19,7 +19,8 @@ public class SynchronizeItemCollectionViewModelHandler(IMediator mediator, IReadOnlyCollection<(Guid Id, string Name, string Category, bool Favourite, bool Archived)>? results = await mediator.Handle>, - IReadOnlyCollection<(Guid Id, string Name, string Category, bool Favourite, bool Archived)>>(Query.As(new Wallet<(string?, string?)>((configuration.Filter, configuration.Query)))); + IReadOnlyCollection<(Guid Id, string Name, string Category, bool Favourite, + bool Archived)>>(Query.As(new Wallet<(string?, string?)>((configuration.Filter, configuration.Query)))); if (results is not null) { @@ -27,7 +28,8 @@ public class SynchronizeItemCollectionViewModelHandler(IMediator mediator, { IServiceScope serviceScope = serviceProvider.CreateScope(); IServiceFactory serviceFactory = serviceScope.ServiceProvider.GetRequiredService(); - IDecoratorService> decoratorService = serviceScope.ServiceProvider.GetRequiredService>>(); + IDecoratorService> decoratorService = serviceScope.ServiceProvider + .GetRequiredService>>(); if (serviceFactory.Create(args => args.Initialize(), Id, Name, "Description", Category, selected, Favourite, Archived) diff --git a/Wallet/SynchronizeItemContentViewModelHandler.cs b/Wallet/SynchronizeItemContentViewModelHandler.cs index 5b725a7..b057605 100644 --- a/Wallet/SynchronizeItemContentViewModelHandler.cs +++ b/Wallet/SynchronizeItemContentViewModelHandler.cs @@ -16,8 +16,8 @@ public class SynchronizeItemContentViewModelHandler(IDecoratorService>, (Guid, string, string?, string, - ItemConfiguration?)>(Request.As(new Item(Id))); + (_, _, _, _, ItemConfiguration? configuration) = await mediator.Handle>, + (Guid, string, string?, string, ItemConfiguration?)>(Request.As(new Item(Id))); if (configuration is not null) {