mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Show nice star in stars payments.
This commit is contained in:
parent
0bfb0fd045
commit
54ce85f8e6
4 changed files with 41 additions and 13 deletions
|
@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "history/history_item_helpers.h"
|
#include "history/history_item_helpers.h"
|
||||||
#include "history/history_translation.h"
|
#include "history/history_translation.h"
|
||||||
#include "history/history_unread_things.h"
|
#include "history/history_unread_things.h"
|
||||||
|
#include "core/ui_integration.h"
|
||||||
#include "dialogs/ui/dialogs_layout.h"
|
#include "dialogs/ui/dialogs_layout.h"
|
||||||
#include "data/business/data_shortcut_messages.h"
|
#include "data/business/data_shortcut_messages.h"
|
||||||
#include "data/components/scheduled_messages.h"
|
#include "data/components/scheduled_messages.h"
|
||||||
|
@ -1128,14 +1129,23 @@ void History::applyServiceChanges(
|
||||||
}
|
}
|
||||||
if (paid) {
|
if (paid) {
|
||||||
// Toast on a current active window.
|
// Toast on a current active window.
|
||||||
|
const auto context = [=](not_null<QWidget*> toast) {
|
||||||
|
return Core::MarkedTextContext{
|
||||||
|
.session = &session(),
|
||||||
|
.customEmojiRepaint = [=] { toast->update(); },
|
||||||
|
};
|
||||||
|
};
|
||||||
Ui::Toast::Show({
|
Ui::Toast::Show({
|
||||||
.text = tr::lng_payments_success(
|
.text = tr::lng_payments_success(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_amount,
|
lt_amount,
|
||||||
Ui::Text::Bold(payment->amount),
|
Ui::Text::Wrapped(
|
||||||
|
payment->amount,
|
||||||
|
EntityType::Bold),
|
||||||
lt_title,
|
lt_title,
|
||||||
Ui::Text::Bold(paid->title),
|
Ui::Text::Bold(paid->title),
|
||||||
Ui::Text::WithEntities),
|
Ui::Text::WithEntities),
|
||||||
|
.textContext = context,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "core/click_handler_types.h"
|
#include "core/click_handler_types.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "base/timer_rpl.h"
|
#include "base/timer_rpl.h"
|
||||||
|
#include "boxes/send_credits_box.h"
|
||||||
#include "api/api_text_entities.h"
|
#include "api/api_text_entities.h"
|
||||||
#include "api/api_updates.h"
|
#include "api/api_updates.h"
|
||||||
#include "data/components/scheduled_messages.h"
|
#include "data/components/scheduled_messages.h"
|
||||||
|
@ -137,6 +138,17 @@ template <typename T>
|
||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] TextWithEntities AmountAndStarCurrency(
|
||||||
|
not_null<Main::Session*> session,
|
||||||
|
int64 amount,
|
||||||
|
const QString ¤cy) {
|
||||||
|
if (currency == Ui::kCreditsCurrency) {
|
||||||
|
return Ui::CreditsEmojiSmall(session).append(
|
||||||
|
Lang::FormatCountDecimal(std::abs(amount)));
|
||||||
|
}
|
||||||
|
return { Ui::FillAmountAndCurrency(amount, currency) };
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void HistoryItem::HistoryItem::Destroyer::operator()(HistoryItem *value) {
|
void HistoryItem::HistoryItem::Destroyer::operator()(HistoryItem *value) {
|
||||||
|
@ -3957,7 +3969,10 @@ void HistoryItem::createServiceFromMtp(const MTPDmessageService &message) {
|
||||||
payment->recurringInit = data.is_recurring_init();
|
payment->recurringInit = data.is_recurring_init();
|
||||||
payment->recurringUsed = data.is_recurring_used();
|
payment->recurringUsed = data.is_recurring_used();
|
||||||
payment->isCreditsCurrency = (currency == Ui::kCreditsCurrency);
|
payment->isCreditsCurrency = (currency == Ui::kCreditsCurrency);
|
||||||
payment->amount = Ui::FillAmountAndCurrency(amount, currency);
|
payment->amount = AmountAndStarCurrency(
|
||||||
|
&_history->session(),
|
||||||
|
amount,
|
||||||
|
currency);
|
||||||
payment->invoiceLink = std::make_shared<LambdaClickHandler>([=](
|
payment->invoiceLink = std::make_shared<LambdaClickHandler>([=](
|
||||||
ClickContext context) {
|
ClickContext context) {
|
||||||
using namespace Payments;
|
using namespace Payments;
|
||||||
|
@ -4692,7 +4707,7 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
|
||||||
lt_user,
|
lt_user,
|
||||||
Ui::Text::Link(peer->name(), 1), // Link 1.
|
Ui::Text::Link(peer->name(), 1), // Link 1.
|
||||||
lt_cost,
|
lt_cost,
|
||||||
{ Ui::FillAmountAndCurrency(amount, currency) },
|
AmountAndStarCurrency(&peer->session(), amount, currency),
|
||||||
Ui::Text::WithEntities);
|
Ui::Text::WithEntities);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
@ -4905,9 +4920,10 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
|
||||||
lt_user,
|
lt_user,
|
||||||
Ui::Text::Link(peer->name(), 1), // Link 1.
|
Ui::Text::Link(peer->name(), 1), // Link 1.
|
||||||
lt_cost,
|
lt_cost,
|
||||||
{ Ui::FillAmountAndCurrency(
|
AmountAndStarCurrency(
|
||||||
|
&_history->session(),
|
||||||
action.vamount().value_or_empty(),
|
action.vamount().value_or_empty(),
|
||||||
qs(action.vcurrency().value_or_empty())) },
|
qs(action.vcurrency().value_or_empty())),
|
||||||
Ui::Text::WithEntities);
|
Ui::Text::WithEntities);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4957,7 +4973,6 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
|
||||||
Ui::Text::WithEntities);
|
Ui::Text::WithEntities);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto preparePaymentRefunded = [&](const MTPDmessageActionPaymentRefunded &action) {
|
auto preparePaymentRefunded = [&](const MTPDmessageActionPaymentRefunded &action) {
|
||||||
auto result = PreparedServiceText();
|
auto result = PreparedServiceText();
|
||||||
const auto refund = Get<HistoryServicePaymentRefund>();
|
const auto refund = Get<HistoryServicePaymentRefund>();
|
||||||
|
@ -4972,7 +4987,7 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
|
||||||
lt_peer,
|
lt_peer,
|
||||||
Ui::Text::Link(refund->peer->name(), 1), // Link 1.
|
Ui::Text::Link(refund->peer->name(), 1), // Link 1.
|
||||||
lt_amount,
|
lt_amount,
|
||||||
{ Ui::FillAmountAndCurrency(amount, currency) },
|
AmountAndStarCurrency(&_history->session(), amount, currency),
|
||||||
Ui::Text::WithEntities);
|
Ui::Text::WithEntities);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
@ -4993,7 +5008,10 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
|
||||||
lt_user,
|
lt_user,
|
||||||
Ui::Text::Link(peer->name(), 1), // Link 1.
|
Ui::Text::Link(peer->name(), 1), // Link 1.
|
||||||
lt_cost,
|
lt_cost,
|
||||||
{ Ui::FillAmountAndCurrency(amount, currency) },
|
AmountAndStarCurrency(
|
||||||
|
&_history->session(),
|
||||||
|
amount,
|
||||||
|
currency),
|
||||||
Ui::Text::WithEntities);
|
Ui::Text::WithEntities);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
@ -5412,7 +5430,7 @@ PreparedServiceText HistoryItem::preparePaymentSentText() {
|
||||||
result.text = tr::lng_action_payment_used_recurring(
|
result.text = tr::lng_action_payment_used_recurring(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_amount,
|
lt_amount,
|
||||||
{ .text = payment->amount },
|
payment->amount,
|
||||||
Ui::Text::WithEntities);
|
Ui::Text::WithEntities);
|
||||||
} else {
|
} else {
|
||||||
result.text = (payment->recurringInit
|
result.text = (payment->recurringInit
|
||||||
|
@ -5420,7 +5438,7 @@ PreparedServiceText HistoryItem::preparePaymentSentText() {
|
||||||
: tr::lng_action_payment_done)(
|
: tr::lng_action_payment_done)(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_amount,
|
lt_amount,
|
||||||
{ .text = payment->amount },
|
payment->amount,
|
||||||
lt_user,
|
lt_user,
|
||||||
{ .text = _history->peer->name() },
|
{ .text = _history->peer->name() },
|
||||||
Ui::Text::WithEntities);
|
Ui::Text::WithEntities);
|
||||||
|
@ -5431,7 +5449,7 @@ PreparedServiceText HistoryItem::preparePaymentSentText() {
|
||||||
: tr::lng_action_payment_done_for)(
|
: tr::lng_action_payment_done_for)(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_amount,
|
lt_amount,
|
||||||
{ .text = payment->amount },
|
payment->amount,
|
||||||
lt_user,
|
lt_user,
|
||||||
{ .text = _history->peer->name() },
|
{ .text = _history->peer->name() },
|
||||||
lt_invoice,
|
lt_invoice,
|
||||||
|
|
|
@ -649,7 +649,7 @@ struct HistoryServicePayment
|
||||||
: public RuntimeComponent<HistoryServicePayment, HistoryItem>
|
: public RuntimeComponent<HistoryServicePayment, HistoryItem>
|
||||||
, public HistoryServiceDependentData {
|
, public HistoryServiceDependentData {
|
||||||
QString slug;
|
QString slug;
|
||||||
QString amount;
|
TextWithEntities amount;
|
||||||
ClickHandlerPtr invoiceLink;
|
ClickHandlerPtr invoiceLink;
|
||||||
bool recurringInit = false;
|
bool recurringInit = false;
|
||||||
bool recurringUsed = false;
|
bool recurringUsed = false;
|
||||||
|
|
|
@ -146,11 +146,11 @@ QString FillAmountAndCurrency(
|
||||||
// std::abs doesn't work on that one :/
|
// std::abs doesn't work on that one :/
|
||||||
Expects(amount != std::numeric_limits<int64>::min());
|
Expects(amount != std::numeric_limits<int64>::min());
|
||||||
|
|
||||||
const auto rule = LookupCurrencyRule(currency);
|
|
||||||
if (currency == kCreditsCurrency) {
|
if (currency == kCreditsCurrency) {
|
||||||
return QChar(0x2B50) + Lang::FormatCountDecimal(std::abs(amount));
|
return QChar(0x2B50) + Lang::FormatCountDecimal(std::abs(amount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto rule = LookupCurrencyRule(currency);
|
||||||
const auto prefix = (amount < 0)
|
const auto prefix = (amount < 0)
|
||||||
? QString::fromUtf8("\xe2\x88\x92")
|
? QString::fromUtf8("\xe2\x88\x92")
|
||||||
: QString();
|
: QString();
|
||||||
|
|
Loading…
Add table
Reference in a new issue