Fix bug with already used colors being used first for new tx labels (#2077)

* Extend list of available tx label colors

* Ensure unknown label colors are given the least priority

closes #2072

* Remove new label colors
This commit is contained in:
Umar Bolatov
2020-12-01 22:38:05 -08:00
committed by GitHub
parent a78c1c8278
commit 6714eb9f7f

View File

@@ -115,7 +115,7 @@ namespace BTCPayServer.Controllers
"#ff7619",
"#84b6eb",
"#5319e7",
"#000000",
"#cdcdcd",
"#cc317c",
};
@@ -173,7 +173,12 @@ namespace BTCPayServer.Controllers
allColors
.GroupBy(k => k)
.OrderBy(k => k.Count())
.ThenBy(k => Array.IndexOf(LabelColorScheme, k.Key))
.ThenBy(k => {
var indexInColorScheme = Array.IndexOf(LabelColorScheme, k.Key);
// Ensures that any label color which may not be in our label color scheme is given the least priority
return indexInColorScheme == -1 ? double.PositiveInfinity : indexInColorScheme;
})
.First().Key;
walletBlobInfo.LabelColors.Add(addlabel, chosenColor);
await WalletRepository.SetWalletInfo(walletId, walletBlobInfo);