Slightly improved invoice view in messages for credits.

This commit is contained in:
23rd 2024-05-22 21:48:57 +03:00 committed by John Preston
parent 3d81414c71
commit 84cde1354d
2 changed files with 17 additions and 7 deletions

View File

@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "apiwrap.h"
#include "api/api_cloud_password.h"
#include "api/api_send_progress.h"
#include "boxes/send_credits_box.h"
#include "boxes/share_box.h"
#include "boxes/passcode_box.h"
#include "boxes/url_auth_box.h"
@ -330,12 +331,16 @@ void ActivateBotCommand(ClickHandlerContext context, int row, int column) {
} break;
case ButtonType::Buy: {
Payments::CheckoutProcess::Start(
item,
Payments::Mode::Payment,
crl::guard(controller, [=](auto) {
controller->widget()->activate();
}));
if (Ui::IsCreditsInvoice(item)) {
controller->uiShow()->show(Box(Ui::SendCreditsBox, item));
} else {
Payments::CheckoutProcess::Start(
item,
Payments::Mode::Payment,
crl::guard(controller, [=](auto) {
controller->widget()->activate();
}));
}
} break;
case ButtonType::Url: {

View File

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "history/view/media/history_view_invoice.h"
#include "boxes/send_credits_box.h" // IsCreditsInvoice.
#include "lang/lang_keys.h"
#include "history/view/history_view_element.h"
#include "history/view/history_view_cursor_state.h"
@ -34,7 +35,8 @@ Invoice::Invoice(
}
void Invoice::fillFromData(not_null<Data::Invoice*> invoice) {
if (invoice->photo) {
const auto isCreditsCurrency = Ui::IsCreditsInvoice(_parent->data());
if (invoice->photo && !isCreditsCurrency) {
const auto spoiler = false;
_attach = std::make_unique<Photo>(
_parent,
@ -64,6 +66,9 @@ void Invoice::fillFromData(not_null<Data::Invoice*> invoice) {
0,
int(statusText.text.size()) });
statusText.text += ' ' + labelText().toUpper();
if (isCreditsCurrency) {
statusText = {};
}
_status.setMarkedText(
st::defaultTextStyle,
statusText,