From f4808ccb502cc57e00187a5512c3cae839f0ffe2 Mon Sep 17 00:00:00 2001 From: TheXamlGuy Date: Sat, 29 Jun 2024 22:06:08 +0100 Subject: [PATCH] Ensure profile images show on newly created wallets --- Wallet/WalletActivatedHandler.cs | 6 +++++- Wallet/WalletCollectionInitializer.cs | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Wallet/WalletActivatedHandler.cs b/Wallet/WalletActivatedHandler.cs index 4330e71..533aee8 100644 --- a/Wallet/WalletActivatedHandler.cs +++ b/Wallet/WalletActivatedHandler.cs @@ -22,8 +22,12 @@ public class WalletActivatedHandler(IWalletHostCollection Wallets, { if (host.Services.GetRequiredService() is IServiceFactory serviceFactory) { + IDecoratorService> profileImageDecorator = + host.Services.GetRequiredService>>(); + + ProfileImage? profileImage = profileImageDecorator.Service; if (serviceFactory.Create(args => args.Initialize(), - descriptor.Name, false) + descriptor.Name, profileImage?.Value, false) is WalletNavigationViewModel viewModel) { publisher.Publish(Insert.As(index, viewModel), diff --git a/Wallet/WalletCollectionInitializer.cs b/Wallet/WalletCollectionInitializer.cs index bf88978..4624aeb 100644 --- a/Wallet/WalletCollectionInitializer.cs +++ b/Wallet/WalletCollectionInitializer.cs @@ -10,7 +10,13 @@ public class WalletCollectionInitializer(IHostEnvironment environment, { public void Initialize() { - foreach (string wallet in Directory.EnumerateDirectories(Path.Combine(environment.ContentRootPath, "Wallet"))) + string path = Path.Combine(environment.ContentRootPath, "Wallet"); + if (!Directory.Exists(path)) + { + return; + } + + foreach (string wallet in Directory.EnumerateDirectories(path)) { string name = Path.GetFileName(wallet); string section = $"Wallet:{name}";