diff --git a/Wallet/CreateWalletHandler.cs b/Wallet/CreateWalletHandler.cs index 223df36..e1af3e8 100644 --- a/Wallet/CreateWalletHandler.cs +++ b/Wallet/CreateWalletHandler.cs @@ -14,7 +14,7 @@ public class CreateWalletHandler(IWalletFactory componentFactory, { if (args.Sender is Wallet <(string, string)> Wallet) { - if (Wallet.Value is (string name, string password) && + if (Wallet.Sender is (string name, string password) && name is { Length: > 0 } && password is { Length: > 0 }) { @@ -36,7 +36,7 @@ public class CreateWalletHandler(IWalletFactory componentFactory, configuration.Write(args => args.Key = $"{Convert.ToBase64String(key.Salt)}:{Convert.ToBase64String(key.EncryptedKey)}:{Convert.ToBase64String(key.DecryptedKey)}"); host.Start(); - publisher.Publish(Activated.As(host), cancellationToken); + publisher.Publish(Activated.As(new Wallet(host))); return true; } } diff --git a/Wallet/MainViewModel.cs b/Wallet/MainViewModel.cs index d1fe9c8..e0af474 100644 --- a/Wallet/MainViewModel.cs +++ b/Wallet/MainViewModel.cs @@ -1,10 +1,10 @@ using CommunityToolkit.Mvvm.ComponentModel; -using Microsoft.Extensions.DependencyInjection; using Toolkit.Foundation; namespace Wallet; [Notification(typeof(CreateEventArgs), nameof(MainViewModel))] +[Notification(typeof(InsertEventArgs), nameof(MainViewModel))] public partial class MainViewModel : ObservableCollection { diff --git a/Wallet/OpenWalletHandler.cs b/Wallet/OpenWalletHandler.cs index d597c57..07a4dff 100644 --- a/Wallet/OpenWalletHandler.cs +++ b/Wallet/OpenWalletHandler.cs @@ -13,7 +13,7 @@ public class OpenWalletHandler(IConfigurationDescriptor des { if (args.Sender is Wallet Wallet && descriptor.Name is { Length: > 0 } name && - Wallet.Value is { Length: > 0 } password) + Wallet.Sender is { Length: > 0 } password) { WalletConfiguration configuration = descriptor.Value; if (configuration.Key?.Split(':') is { Length: >= 2 } keyPart) diff --git a/Wallet/QueryWalletHandler.cs b/Wallet/QueryWalletHandler.cs index 28f7bb9..24fcc65 100644 --- a/Wallet/QueryWalletHandler.cs +++ b/Wallet/QueryWalletHandler.cs @@ -14,7 +14,7 @@ public class QueryWalletHandler(IDbContextFactory dbContextFactor List<(Guid Id, string? Name, string Category, bool Favourite, bool Archived)> items = []; if (args.Value is Wallet<(string, string)> Wallet) { - (string filter, string text) = Wallet.Value; + (string filter, string text) = Wallet.Sender; ExpressionStarter predicate = PredicateBuilder.New(true); diff --git a/Wallet/Wallet.cs b/Wallet/Wallet.cs index ad27b79..700514e 100644 --- a/Wallet/Wallet.cs +++ b/Wallet/Wallet.cs @@ -1,5 +1,5 @@ namespace Wallet; -public record Wallet(TValue Value); +public record Wallet(TSender Sender); public record Wallet; \ No newline at end of file diff --git a/Wallet/WalletActivatedHandler.cs b/Wallet/WalletActivatedHandler.cs index 5577510..4a7919a 100644 --- a/Wallet/WalletActivatedHandler.cs +++ b/Wallet/WalletActivatedHandler.cs @@ -5,25 +5,27 @@ namespace Wallet; public class WalletActivatedHandler(IWalletHostCollection Wallets, IPublisher publisher) : - INotificationHandler> + INotificationHandler>> { - public Task Handle(ActivatedEventArgs args) + public Task Handle(ActivatedEventArgs> args) { - if (args.Sender is IComponentHost Wallet) + if (args.Sender is Wallet wallet && wallet.Sender is IComponentHost host) { - List sortedWallets = [.. Wallets, Wallet]; + List sortedWallets = [.. Wallets, host]; sortedWallets = [.. sortedWallets.OrderBy(x => x.Services.GetRequiredService>() is IConfigurationDescriptor descriptor ? descriptor.Name : null)]; - int index = sortedWallets.IndexOf(Wallet); + int index = sortedWallets.IndexOf(host); - if (Wallet.Services.GetRequiredService>() is ConfigurationDescriptor descriptor) + if (host.Services.GetRequiredService>() is + ConfigurationDescriptor descriptor) { - if (Wallet.Services.GetRequiredService() is IServiceFactory serviceFactory) + if (host.Services.GetRequiredService() is IServiceFactory serviceFactory) { - if (serviceFactory.Create(descriptor.Name) is WalletNavigationViewModel viewModel) + if (serviceFactory.Create(descriptor.Name, false) + is WalletNavigationViewModel viewModel) { - publisher.Publish(new InsertEventArgs(index, viewModel), + publisher.Publish(Insert.As(index, viewModel), nameof(MainViewModel)); } }