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