Skip to content

Commit

Permalink
Fix a previous optimization that broke the search (#351)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruixhuang authored Feb 7, 2025
1 parent c9570fb commit 0fed997
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class dydxSimpleUIMarketListViewPresenter: HostedViewPresenter<dydxSimpleUIMarke
.store(in: &subscriptions)
}

private var lastSearchText: String?

private func updateMarketList(markets: [PerpetualMarket],
assetMap: [String: Asset],
positions: [SubaccountPosition],
Expand Down Expand Up @@ -99,7 +101,8 @@ class dydxSimpleUIMarketListViewPresenter: HostedViewPresenter<dydxSimpleUIMarke
return (lhs.volumn ?? 0) > (rhs.volumn ?? 0)
}

if launchableMarkets == nil {
if lastSearchText != searchText || launchedMarkets == nil {
lastSearchText = searchText
launchableMarkets = markets
.filter { $0.isLaunched == false }
.compactMap { market in
Expand All @@ -117,15 +120,14 @@ class dydxSimpleUIMarketListViewPresenter: HostedViewPresenter<dydxSimpleUIMarke
asset: asset,
position: nil,
onMarketSelected: { [weak self] in
self?.onMarketSelected?(market.id)
},
self?.onMarketSelected?(market.id)
},
onCancelAction: nil)
}
.sorted { lhs, rhs in
(lhs.marketCaps ?? 0) > (rhs.marketCaps ?? 0)
}
}

viewModel?.markets = (launchedMarkets ?? []) + (launchableMarkets ?? [])
}
}
Expand Down

0 comments on commit 0fed997

Please sign in to comment.