Moved out credits currency to single place.

This commit is contained in:
23rd 2024-05-24 21:13:14 +03:00 committed by John Preston
parent d73313479b
commit e9fb580ba4
3 changed files with 6 additions and 2 deletions

View File

@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "smartglocal/smartglocal_token.h"
#include "storage/storage_account.h"
#include "ui/image/image.h"
#include "ui/text/format_values.h"
#include "ui/text/text_entity.h"
#include "apiwrap.h"
#include "core/core_cloud_password.h"
@ -385,7 +386,7 @@ void Form::requestForm() {
const auto amount = tlPrices.empty()
? 0
: tlPrices.front().data().vamount().v;
if (currency != "XTR" || !amount) {
if (currency != ::Ui::kCreditsCurrency || !amount) {
using Type = Error::Type;
_updates.fire(Error{ Type::Form, u"Bad Stars Form."_q });
return;

View File

@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "payments/payments_form.h"
#include "history/history_item.h"
#include "ui/layers/generic_box.h"
#include "ui/text/format_values.h"
#include "window/window_session_controller.h"
#include "boxes/send_credits_box.h"
@ -20,7 +21,7 @@ namespace {
bool IsCreditsInvoice(not_null<HistoryItem*> item) {
const auto media = item->media();
const auto invoice = media ? media->invoice() : nullptr;
return invoice && (invoice->currency == "XTR");
return invoice && (invoice->currency == Ui::kCreditsCurrency);
}
} // namespace

View File

@ -13,6 +13,8 @@ inline constexpr auto FileStatusSizeReady = 0xFFFFFFF0LL;
inline constexpr auto FileStatusSizeLoaded = 0xFFFFFFF1LL;
inline constexpr auto FileStatusSizeFailed = 0xFFFFFFF2LL;
inline const QString kCreditsCurrency = u"XTR"_q;
[[nodiscard]] QString FormatSizeText(qint64 size);
[[nodiscard]] QString FormatDownloadText(qint64 ready, qint64 total);
[[nodiscard]] QString FormatProgressText(qint64 ready, qint64 total);