Fix wallet ordering on creation
This commit is contained in:
@@ -5,6 +5,7 @@ using Toolkit.Foundation;
|
||||
namespace Wallet;
|
||||
|
||||
public class CreateWalletHandler(IWalletHostFactory componentFactory,
|
||||
IWalletHostCollection wallets,
|
||||
IPublisher publisher) :
|
||||
IHandler<CreateEventArgs<Wallet<(string, string, IImageDescriptor?)>>, bool>
|
||||
{
|
||||
@@ -23,9 +24,10 @@ public class CreateWalletHandler(IWalletHostFactory componentFactory,
|
||||
IWalletFactory walletFactory = host.Services.GetRequiredService<IWalletFactory>();
|
||||
if (await walletFactory.Create(name, password, imageDescriptor))
|
||||
{
|
||||
wallets.Add(host);
|
||||
host.Start();
|
||||
publisher.Publish(Activated.As(new Wallet<IComponentHost>(host)));
|
||||
|
||||
publisher.Publish(Activated.As(new Wallet<IComponentHost>(host)));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Wallet;
|
||||
|
||||
public class WalletActivatedHandler(IWalletHostCollection Wallets,
|
||||
public class WalletActivatedHandler(IWalletHostCollection wallets,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<ActivatedEventArgs<Wallet<IComponentHost>>>
|
||||
{
|
||||
@@ -11,8 +11,7 @@ public class WalletActivatedHandler(IWalletHostCollection Wallets,
|
||||
{
|
||||
if (args.Sender is Wallet<IComponentHost> wallet && wallet.Value is IComponentHost host)
|
||||
{
|
||||
List<IComponentHost> sortedWallets = [.. Wallets, host];
|
||||
sortedWallets = [.. sortedWallets.OrderBy(x => x.Services.GetRequiredService<IConfigurationDescriptor<WalletConfiguration>>() is
|
||||
List<IComponentHost> sortedWallets = [.. wallets.OrderBy(x => x.Services.GetRequiredService<IConfigurationDescriptor<WalletConfiguration>>() is
|
||||
IConfigurationDescriptor<WalletConfiguration> descriptor ? descriptor.Name : null)];
|
||||
|
||||
int index = sortedWallets.IndexOf(host);
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Wallet;
|
||||
|
||||
public class WalletCollectionInitializer(IHostEnvironment environment,
|
||||
IComponentFactory componentFactory,
|
||||
IWalletHostCollection Wallets) :
|
||||
IWalletHostCollection wallets) :
|
||||
IInitialization
|
||||
{
|
||||
public void Initialize()
|
||||
@@ -25,7 +25,7 @@ public class WalletCollectionInitializer(IHostEnvironment environment,
|
||||
WalletConfiguration>(section, new WalletConfiguration())
|
||||
is IComponentHost host)
|
||||
{
|
||||
Wallets.Add(host);
|
||||
wallets.Add(host);
|
||||
host.Start();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user