mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Stop calling _findTopQuoteAggId twice in _findTopQuoteAggId (#9530)
* Stop calling _findTopQuoteAggId twice in _findTopQuoteAggId * Update app/scripts/controllers/swaps.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> Co-authored-by: Mark Stacey <markjstacey@gmail.com>
This commit is contained in:
parent
4505ab5f2b
commit
5fd4657588
@ -164,13 +164,9 @@ export default class SwapsController {
|
||||
}
|
||||
}
|
||||
|
||||
const topAggIdData = await this._findTopQuoteAggId(newQuotes)
|
||||
let { topAggId } = topAggIdData
|
||||
const { isBest } = topAggIdData
|
||||
|
||||
if (isBest) {
|
||||
newQuotes[topAggId].isBestQuote = true
|
||||
}
|
||||
let topAggIdData
|
||||
let topAggId
|
||||
let isBest
|
||||
|
||||
// We can reduce time on the loading screen by only doing this after the
|
||||
// loading screen and best quote have rendered.
|
||||
@ -181,15 +177,20 @@ export default class SwapsController {
|
||||
this.setSwapsErrorKey(QUOTES_NOT_AVAILABLE_ERROR)
|
||||
} else {
|
||||
const {
|
||||
topAggId: topAggIdAfterGasEstimates,
|
||||
isBest: isBestAfterGasEstimates,
|
||||
topAggId: topAggIdAfterModifications,
|
||||
isBest: isBestAfterModifications,
|
||||
} = await this._findTopQuoteAggId(newQuotes)
|
||||
topAggId = topAggIdAfterGasEstimates
|
||||
if (isBestAfterGasEstimates) {
|
||||
newQuotes = mapValues(newQuotes, (quote) => ({ ...quote, isBestQuote: false }))
|
||||
newQuotes[topAggId].isBestQuote = true
|
||||
}
|
||||
topAggId = topAggIdAfterModifications
|
||||
isBest = isBestAfterModifications
|
||||
}
|
||||
} else {
|
||||
topAggIdData = await this._findTopQuoteAggId(newQuotes)
|
||||
topAggId = topAggIdData.topAggId
|
||||
isBest = topAggIdData.isBest
|
||||
}
|
||||
|
||||
if (isBest) {
|
||||
newQuotes[topAggId].isBestQuote = true
|
||||
}
|
||||
|
||||
const { swapsState } = this.store.getState()
|
||||
|
Loading…
Reference in New Issue
Block a user