Skip to content

Commit

Permalink
fix (#5989)
Browse files Browse the repository at this point in the history
  • Loading branch information
walmat authored Aug 6, 2024
1 parent 0fd389f commit eabc40e
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 50 deletions.
2 changes: 0 additions & 2 deletions src/migrations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { migratePinnedAndHiddenTokenUniqueIds } from './migrations/migratePinned
import { migrateRemotePromoSheetsToZustand } from './migrations/migrateRemotePromoSheetsToZustand';
import { migrateUnlockableAppIconStorage } from './migrations/migrateUnlockableAppIconStorage';
import { purgeWcConnectionsWithoutAccounts } from './migrations/purgeWcConnectionsWithoutAccounts';
import { removeDuplicateRecentSwaps } from './migrations/removeDuplicateRecentSwaps';

/**
* Local storage for migrations only. Should not be exported.
Expand Down Expand Up @@ -44,7 +43,6 @@ const migrations: Migration[] = [
migratePersistedQueriesToMMKV(),
migrateRemotePromoSheetsToZustand(),
migrateFavoritesToV2(),
removeDuplicateRecentSwaps(),
];

/**
Expand Down
30 changes: 0 additions & 30 deletions src/migrations/migrations/removeDuplicateRecentSwaps.ts

This file was deleted.

19 changes: 1 addition & 18 deletions src/state/swaps/swapsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,27 +170,10 @@ export const swapsStore = createRainbowStore<SwapsState>(
const chainId = asset.chainId;
const chainSwaps = recentSwaps.get(chainId) || [];

const [latestSwap] = chainSwaps;

// Check if the most recent swap is the same as the incoming asset
if (latestSwap && latestSwap.uniqueId === asset.uniqueId) {
latestSwapAt.set(chainId, now);
recentSwaps.set(chainId, [
...chainSwaps.slice(1),
{
...latestSwap,
swappedAt: now,
},
]);

set({ latestSwapAt: new Map(latestSwapAt), recentSwaps: new Map(recentSwaps) });
return;
}

// Remove any existing entries of the same asset
const filteredSwaps = chainSwaps.filter(swap => swap.uniqueId !== asset.uniqueId);

const updatedSwaps = [...filteredSwaps, { ...asset, swappedAt: now }].slice(0, 3);
const updatedSwaps = [{ ...asset, swappedAt: now }, ...filteredSwaps].slice(0, 3);
recentSwaps.set(chainId, updatedSwaps);
latestSwapAt.set(chainId, now);

Expand Down

0 comments on commit eabc40e

Please sign in to comment.