mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 14:34:23 +01:00
Use proper divisibility for payments in crowdfund and do not show tooltip if identical data
fixes #1037 and fixes #1003
This commit is contained in:
@@ -75,6 +75,7 @@ namespace BTCPayServer.Models.AppViewModels
|
||||
public bool DisplayPerksRanking { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
public string ResetEvery { get; set; }
|
||||
public Dictionary<string, CurrencyData> CurrencyDataPayments { get; set; }
|
||||
}
|
||||
|
||||
public class ContributeToCrowdfund
|
||||
|
||||
@@ -153,6 +153,10 @@ namespace BTCPayServer.Services.Apps
|
||||
Sounds = settings.Sounds,
|
||||
AnimationColors = settings.AnimationColors,
|
||||
CurrencyData = _Currencies.GetCurrencyData(settings.TargetCurrency, true),
|
||||
CurrencyDataPayments = currentPayments.Select(pair => pair.Key)
|
||||
.Concat(pendingPayments.Select(pair => pair.Key)).Distinct()
|
||||
.Select(id => _Currencies.GetCurrencyData(id.CryptoCode, true))
|
||||
.ToDictionary(data => data.Code, data => data),
|
||||
Info = new ViewCrowdfundViewModel.CrowdfundInfo()
|
||||
{
|
||||
TotalContributors = paidInvoices.Length,
|
||||
|
||||
@@ -128,7 +128,7 @@
|
||||
<b-tooltip target="crowdfund-body-raised-amount" v-if="paymentStats && paymentStats.length > 0">
|
||||
<ul class="p-0 text-uppercase">
|
||||
<li v-for="stat of paymentStats" class="list-unstyled">
|
||||
{{stat.label}} <span v-if="stat.lightning" class="fa fa-bolt"></span> {{stat.value.toFixed(srvModel.currencyData.divisibility)}}
|
||||
{{stat.label}} <span v-if="stat.lightning" class="fa fa-bolt"></span> {{stat.value}}
|
||||
</li>
|
||||
</ul>
|
||||
</b-tooltip>
|
||||
|
||||
@@ -110,10 +110,7 @@ addLoadEvent(function (ev) {
|
||||
},
|
||||
paymentStats: function(){
|
||||
var result= [];
|
||||
|
||||
var combinedStats = {};
|
||||
|
||||
|
||||
var keys = Object.keys(this.srvModel.info.paymentStats);
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
@@ -137,18 +134,22 @@ addLoadEvent(function (ev) {
|
||||
keys = Object.keys(combinedStats);
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var newItem = {key:keys[i], value: combinedStats[keys[i]], label: keys[i].replace("_","")};
|
||||
result.push(newItem);
|
||||
|
||||
}
|
||||
for (var i = 0; i < result.length; i++) {
|
||||
var current = result[i];
|
||||
if(current.label.endsWith("LightningLike")){
|
||||
current.label = current.label.substr(0,current.label.indexOf("LightningLike"));
|
||||
current.lightning = true;
|
||||
if(!combinedStats[keys[i]]){
|
||||
continue;
|
||||
}
|
||||
var paymentMethodId = keys[i].split("_");
|
||||
var value = combinedStats[keys[i]].toFixed(this.srvModel.currencyDataPayments[paymentMethodId[0]].divisibility);
|
||||
var newItem = {key:keys[i], value: value, label: paymentMethodId[0]};
|
||||
|
||||
if(paymentMethodId.length > 1 && paymentMethodId[1].endsWith("LightningLike")){
|
||||
newItem.lightning = true;
|
||||
}
|
||||
result.push(newItem);
|
||||
}
|
||||
|
||||
if(result.length === 1 && result[0].label === srvModel.targetCurrency){
|
||||
return [];
|
||||
}
|
||||
return result;
|
||||
},
|
||||
perks: function(){
|
||||
@@ -255,7 +256,7 @@ addLoadEvent(function (ev) {
|
||||
} );
|
||||
});
|
||||
eventAggregator.$on("payment-received", function (amount, cryptoCode, type) {
|
||||
var onChain = type.toLowerCase() === "btclike";
|
||||
var onChain = type.toLowerCase() !== "lightninglike";
|
||||
if(self.sound) {
|
||||
playRandomSound();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user