mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-06-16 02:49:16 -04:00
fix(gui): If two asbs have the same relevancy score, sort by price
This commit is contained in:
parent
288a13e8e7
commit
c5958c4dc1
1 changed files with 4 additions and 7 deletions
|
@ -12,20 +12,17 @@ export function sortProviderList(list: ExtendedProviderStatus[]) {
|
||||||
if (isProviderOutdated(firstEl) && !isProviderOutdated(secondEl)) return 1;
|
if (isProviderOutdated(firstEl) && !isProviderOutdated(secondEl)) return 1;
|
||||||
if (!isProviderOutdated(firstEl) && isProviderOutdated(secondEl)) return -1;
|
if (!isProviderOutdated(firstEl) && isProviderOutdated(secondEl)) return -1;
|
||||||
|
|
||||||
// If neither of them have a relevancy score, sort by price
|
// If neither of them have a relevancy score or they are the same, sort by price
|
||||||
if (firstEl.relevancy == null && secondEl.relevancy == null) {
|
if (firstEl.relevancy == secondEl.relevancy) {
|
||||||
return firstEl.price - secondEl.price;
|
return firstEl.price - secondEl.price;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If only on of the two don't have a relevancy score, prioritize the one that does
|
// If only one of the two doesn't have a relevancy score, prioritize the one that does
|
||||||
if (firstEl.relevancy == null) return 1;
|
if (firstEl.relevancy == null) return 1;
|
||||||
if (secondEl.relevancy == null) return -1;
|
if (secondEl.relevancy == null) return -1;
|
||||||
|
|
||||||
// Otherwise, sort by relevancy score
|
// Otherwise, sort by relevancy score
|
||||||
if (firstEl.relevancy > secondEl.relevancy) {
|
return secondEl.relevancy - firstEl.relevancy;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
})
|
})
|
||||||
// Remove duplicate providers
|
// Remove duplicate providers
|
||||||
.filter((provider, index, self) =>
|
.filter((provider, index, self) =>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue