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

fix #5989

Merged
merged 1 commit into from
Aug 6, 2024
Merged

fix #5989

Show file tree
Hide file tree
Changes from all commits
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
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
Loading