Skip to content

Commit

Permalink
fix(cache): Exclude custom assets from cache retrieval logic FE-1122 (#…
Browse files Browse the repository at this point in the history
…1710)

Custom assets when added or updated required a page reload or a 5
minutes timeout to be updated in the wallet.
By excluding these custom assets from the cache, they are refetched
locally instantly whenever the user adds or updates the asset data.

As this is not a network request, a simple local refetch should not
affect performance.
Before:

https://github.com/user-attachments/assets/573f3d9c-64c2-4e25-8650-3bbb997e42ae

After:

https://github.com/user-attachments/assets/e027e4ec-bffa-4a3d-b8d3-66da3bda1713

---------

Co-authored-by: Luiz Gomes <[email protected]>
  • Loading branch information
nelitow and LuizAsFight authored Jan 3, 2025
1 parent 7cfef80 commit 4c53007
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/plenty-grapes-itch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"fuels-wallet": minor
---

Improve handling of custom assets.
7 changes: 5 additions & 2 deletions packages/app/src/systems/Asset/cache/AssetsCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ export class AssetsCache {
if (
cachedEntry?.name !== undefined &&
cachedEntry.fetchedAt &&
now - cachedEntry.fetchedAt < FIVE_MINUTES
now - cachedEntry.fetchedAt < FIVE_MINUTES &&
!cachedEntry.isCustom &&
cachedEntry?.name !== ''
) {
return cachedEntry;
}
Expand All @@ -145,7 +147,8 @@ export class AssetsCache {
if (
assetFromDb?.name &&
assetFromDb.fetchedAt &&
now - assetFromDb.fetchedAt < FIVE_MINUTES
now - assetFromDb.fetchedAt < FIVE_MINUTES &&
!assetFromDb.isCustom
) {
this.cache[chainId][assetId] = assetFromDb;
return assetFromDb as FuelCachedAsset;
Expand Down

0 comments on commit 4c53007

Please sign in to comment.