Skip to content

Commit

Permalink
Improved Tezos token scanner: saving changes of tokens metadata to DB…
Browse files Browse the repository at this point in the history
… if it has been changed;
  • Loading branch information
k-karuna committed Feb 28, 2023
1 parent 007f45f commit 25a9315
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Atomex.Client.Desktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<UseAppHost>true</UseAppHost>
<ApplicationIcon>Resources/Images/atomex_logo_256x256_ico.ico</ApplicationIcon>

<AssemblyVersion>1.2.62</AssemblyVersion>
<Version>1.2.62</Version>
<AssemblyVersion>1.2.63</AssemblyVersion>
<Version>1.2.63</Version>
</PropertyGroup>
<Choose>
<When Condition=" '$(Configuration)' == 'Debug' ">
Expand Down
2 changes: 1 addition & 1 deletion ViewModels/CurrencyViewModels/TezosTokenViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public TezosTokenViewModel()
.WhereNotNull()
.Where(_ => AtomexApp != null)
.Skip(1)
.SubscribeInMainThread(_ => UpdateQuotesInBaseCurrency(AtomexApp!.QuotesProvider));
.SubscribeInMainThread(_ => UpdateQuotesInBaseCurrency(AtomexApp.QuotesProvider));

SendCommand.Merge(ReceiveCommand)
.SubscribeInMainThread(_ => IsPopupOpened = false);
Expand Down
17 changes: 15 additions & 2 deletions ViewModels/CurrencyViewModels/TezosTokenViewModelCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,21 @@ public static async Task<IEnumerable<TezosTokenViewModel>> CreateOrGet(
{
if (Instances.TryGetValue((contract.Address, tokenGroup.Key), out var cachedTokenViewModel))
{
resultTokens.Add(cachedTokenViewModel);
continue;
var dbTokenBalance = tokenGroup.First().TokenBalance;

// return cached if metadata don't changed
if (dbTokenBalance?.ArtifactUri == cachedTokenViewModel.TokenBalance.ArtifactUri &&
dbTokenBalance?.DisplayUri == cachedTokenViewModel.TokenBalance.DisplayUri &&
dbTokenBalance?.ThumbnailUri == cachedTokenViewModel.TokenBalance.ThumbnailUri &&
dbTokenBalance?.Name == cachedTokenViewModel.TokenBalance.Name &&
dbTokenBalance?.Description == cachedTokenViewModel.TokenBalance.Description)
{
resultTokens.Add(cachedTokenViewModel);
continue;
}

cachedTokenViewModel.Dispose();
Instances.TryRemove((contract.Address, tokenGroup.Key), out _);
}

var tokenBalance = tokenGroup
Expand Down
2 changes: 1 addition & 1 deletion atomex.client.core

0 comments on commit 25a9315

Please sign in to comment.