Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wallet download helper cache issue #125

Merged
merged 2 commits into from
Apr 18, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace MirageSDK.WalletConnect.VersionShared.Utils
{
public static class WalletDownloadHelper
{
private static Dictionary<string, WalletEntry> _walletEntriesCache = new Dictionary<string, WalletEntry>();
private static Dictionary<string, WalletEntry> _walletEntriesCache;

public static async UniTask<WalletEntry> FindWalletEntryByName(string walletName, bool invalidateCache = false)
{
Expand Down Expand Up @@ -84,21 +84,32 @@ public static async UniTask<Dictionary<string, WalletEntry>> FetchWalletList(boo
return supportedWallets;
}

var filteredSupportedWallets = GetAllSupportedWallets(walletconnectSupportedWallets: supportedWallets);
foreach (var wallet in filteredSupportedWallets.Values)
var filteredSupportedWallets = GetAllSupportedWallets(walletConnectSupportedWallets: supportedWallets);

if (filteredSupportedWallets != null)
{
await wallet.DownloadImages();
foreach (var wallet in filteredSupportedWallets.Values)
{
await wallet.DownloadImages();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we construct a list of tasks and use UniTask.WhenAll to avoid waiting for the images one by one?

}
}

_walletEntriesCache = filteredSupportedWallets;

return filteredSupportedWallets;
}
}

private static Dictionary<string, WalletEntry> GetAllSupportedWallets(
Dictionary<string, WalletEntry> walletconnectSupportedWallets)
Dictionary<string, WalletEntry> walletConnectSupportedWallets)
{
if (walletConnectSupportedWallets == null)
{
return null;
}

var walletsSupportedBySDK = WalletNameHelper.GetSupportedWalletNames();
return walletconnectSupportedWallets
return walletConnectSupportedWallets
.Where(predicate: w => walletsSupportedBySDK.Contains(value: w.Value.name))
.ToDictionary(keySelector: i => i.Key, elementSelector: i => i.Value);
}
Expand Down