diff --git a/BTCPayServer/Models/AppViewModels/ViewCrowdfundViewModel.cs b/BTCPayServer/Models/AppViewModels/ViewCrowdfundViewModel.cs index 8ad197977..8fa7a5964 100644 --- a/BTCPayServer/Models/AppViewModels/ViewCrowdfundViewModel.cs +++ b/BTCPayServer/Models/AppViewModels/ViewCrowdfundViewModel.cs @@ -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 CurrencyDataPayments { get; set; } } public class ContributeToCrowdfund diff --git a/BTCPayServer/Services/Apps/AppService.cs b/BTCPayServer/Services/Apps/AppService.cs index e824fdcfd..75e28a6e4 100644 --- a/BTCPayServer/Services/Apps/AppService.cs +++ b/BTCPayServer/Services/Apps/AppService.cs @@ -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, diff --git a/BTCPayServer/Views/AppsPublic/Crowdfund/VueCrowdfund.cshtml b/BTCPayServer/Views/AppsPublic/Crowdfund/VueCrowdfund.cshtml index bff5e07fb..ade4f0c3a 100644 --- a/BTCPayServer/Views/AppsPublic/Crowdfund/VueCrowdfund.cshtml +++ b/BTCPayServer/Views/AppsPublic/Crowdfund/VueCrowdfund.cshtml @@ -128,7 +128,7 @@ diff --git a/BTCPayServer/wwwroot/crowdfund/app.js b/BTCPayServer/wwwroot/crowdfund/app.js index 7d9e3242d..60f8dc9f8 100644 --- a/BTCPayServer/wwwroot/crowdfund/app.js +++ b/BTCPayServer/wwwroot/crowdfund/app.js @@ -109,11 +109,8 @@ addLoadEvent(function (ev) { return this.srvModel.targetCurrency.toUpperCase(); }, paymentStats: function(){ - var result= []; - + var result= []; var combinedStats = {}; - - var keys = Object.keys(this.srvModel.info.paymentStats); for (var i = 0; i < keys.length; i++) { @@ -135,20 +132,24 @@ 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(); }