do not try to mention payout ids/ pull payments if they were not saved for labels

fixes #4078
This commit is contained in:
Kukks 2022-08-26 09:41:48 +02:00
parent db2c29a6e1
commit f67bd69ecc
No known key found for this signature in database
GPG Key ID: 8E5530D9D1C93097

View File

@ -60,12 +60,13 @@ namespace BTCPayServer.Services.Labels
TextColor = TextColor(color) TextColor = TextColor(color)
}; };
string PayoutLabelText(KeyValuePair<string, List<string>> pair) string PayoutLabelText(KeyValuePair<string, List<string>>? pair = null)
{ {
if (pair.Value.Count == 1) if (pair is null)
return $"Paid a payout {(string.IsNullOrEmpty(pair.Key)? string.Empty: $"of a pull payment ({pair.Key})")}"; {
else return "Paid a payout";
return $"Paid {pair.Value.Count} payouts {(string.IsNullOrEmpty(pair.Key)? string.Empty: $"of a pull payment ({pair.Key})")}"; }
return pair.Value.Value.Count == 1 ? $"Paid a payout {(string.IsNullOrEmpty(pair.Value.Key)? string.Empty: $"of a pull payment ({pair.Value.Key})")}" : $"Paid {pair.Value.Value.Count} payouts {(string.IsNullOrEmpty(pair.Value.Key)? string.Empty: $"of a pull payment ({pair.Value.Key})")}";
} }
if (uncoloredLabel is ReferenceLabel refLabel) if (uncoloredLabel is ReferenceLabel refLabel)
@ -101,9 +102,13 @@ namespace BTCPayServer.Services.Labels
} }
else if (uncoloredLabel is PayoutLabel payoutLabel) else if (uncoloredLabel is PayoutLabel payoutLabel)
{ {
coloredLabel.Tooltip = payoutLabel.PullPaymentPayouts.Count > 1 coloredLabel.Tooltip = payoutLabel.PullPaymentPayouts.Count switch
? $"<ul>{string.Join(string.Empty, payoutLabel.PullPaymentPayouts.Select(pair => $"<li>{PayoutLabelText(pair)}</li>"))}</ul>" {
: PayoutLabelText(payoutLabel.PullPaymentPayouts.First()); 0 => PayoutLabelText(),
1 => PayoutLabelText(payoutLabel.PullPaymentPayouts.First()),
_ =>
$"<ul>{string.Join(string.Empty, payoutLabel.PullPaymentPayouts.Select(pair => $"<li>{PayoutLabelText(pair)}</li>"))}</ul>"
};
coloredLabel.Link = string.IsNullOrEmpty(payoutLabel.WalletId) coloredLabel.Link = string.IsNullOrEmpty(payoutLabel.WalletId)
? null ? null