Improve phrases for paid messages.

This commit is contained in:
John Preston 2025-02-18 21:06:05 +04:00
parent 960cf7a34b
commit 4729e51e14
4 changed files with 51 additions and 13 deletions

View file

@ -4826,10 +4826,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_payment_confirm_title" = "Confirm payment";
"lng_payment_confirm_text#one" = "{name} charges **{count}** Star per message.";
"lng_payment_confirm_text#other" = "{name} charges **{count}** Stars per message.";
"lng_payment_confirm_sure#one" = "Would you like to pay **{count}** Star to send one message?";
"lng_payment_confirm_sure#other" = "Would you like to pay **{count}** Stars to send one message?";
"lng_payment_confirm_amount#one" = "**{count}** Star";
"lng_payment_confirm_amount#other" = "**{count}** Stars";
"lng_payment_confirm_sure#one" = "Would you like to pay {amount} to send **{count}** message?";
"lng_payment_confirm_sure#other" = "Would you like to pay {amount} to send **{count}** messages?";
"lng_payment_confirm_dont_ask" = "Don't ask me again";
"lng_payment_confirm_button" = "Pay for 1 Message";
"lng_payment_confirm_button#one" = "Pay for {count} Message";
"lng_payment_confirm_button#other" = "Pay for {count} Messages";
"lng_payment_bar_text" = "{name} must pay {cost} for each message to you.";
"lng_payment_bar_button" = "Remove Fee";
"lng_payment_refund_title" = "Remove Fee";

View file

@ -3298,7 +3298,7 @@ void ApiWrap::finishForwarding(const SendAction &action) {
void ApiWrap::forwardMessages(
Data::ResolvedForwardDraft &&draft,
const SendAction &action,
SendAction action,
FnMut<void()> &&successCallback) {
Expects(!draft.items.empty());
@ -3373,9 +3373,17 @@ void ApiWrap::forwardMessages(
const auto requestType = Data::Histories::RequestType::Send;
const auto idsCopy = localIds;
const auto scheduled = action.options.scheduled;
auto paidStars = std::min(
action.options.starsApproved,
int(ids.size() * peer->starsPerMessageChecked()));
auto oneFlags = sendFlags;
if (paidStars) {
action.options.starsApproved -= paidStars;
oneFlags |= SendFlag::f_allow_paid_stars;
}
histories.sendRequest(history, requestType, [=](Fn<void()> finish) {
history->sendRequestId = request(MTPmessages_ForwardMessages(
MTP_flags(sendFlags),
MTP_flags(oneFlags),
forwardFrom->input,
MTP_vector<MTPint>(ids),
MTP_vector<MTPlong>(randomIds),
@ -3385,7 +3393,7 @@ void ApiWrap::forwardMessages(
(sendAs ? sendAs->input : MTP_inputPeerEmpty()),
Data::ShortcutIdToMTP(_session, action.options.shortcutId),
MTPint(), // video_timestamp
MTPlong() // allow_paid_stars
MTP_long(paidStars)
)).done([=](const MTPUpdates &result) {
if (!scheduled) {
this->updates().checkForSentToScheduled(result);

View file

@ -306,7 +306,7 @@ public:
void finishForwarding(const SendAction &action);
void forwardMessages(
Data::ResolvedForwardDraft &&draft,
const SendAction &action,
SendAction action,
FnMut<void()> &&successCallback = nullptr);
void shareContact(
const QString &phone,

View file

@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_user.h"
#include "lang/lang_keys.h"
#include "main/main_session.h"
#include "settings/settings_credits_graphics.h"
#include "storage/storage_account.h"
#include "ui/boxes/confirm_box.h"
#include "ui/chat/attach/attach_prepare.h"
@ -443,12 +444,30 @@ void ShowSendPaidConfirm(
not_null<PeerData*> peer,
Data::SendError error,
Fn<void()> confirmed) {
const auto check = [=] {
const auto required = error.paidStars;
if (!required) {
return;
}
const auto done = [=](Settings::SmallBalanceResult result) {
if (result == Settings::SmallBalanceResult::Success
|| result == Settings::SmallBalanceResult::Already) {
confirmed();
}
};
Settings::MaybeRequestBalanceIncrease(
show,
required,
Settings::SmallBalanceForMessage{ .recipientId = peer->id },
done);
};
const auto session = &peer->session();
if (session->local().isPeerTrustedPayForMessage(peer->id)) {
confirmed();
check();
return;
}
//const auto messages = error.paidMessages;
const auto messages = error.paidMessages;
const auto stars = error.paidStars;
show->showBox(Box([=](not_null<Ui::GenericBox*> box) {
const auto trust = std::make_shared<QPointer<Ui::Checkbox>>();
@ -456,24 +475,32 @@ void ShowSendPaidConfirm(
if ((*trust)->checked()) {
session->local().markPeerTrustedPayForMessage(peer->id);
}
confirmed();
check();
close();
};
Ui::ConfirmBox(box, {
.text = tr::lng_payment_confirm_text(
tr::now,
lt_count,
stars,
stars / messages,
lt_name,
Ui::Text::Bold(peer->shortName()),
Ui::Text::RichLangValue).append(' ').append(
tr::lng_payment_confirm_sure(
tr::now,
lt_count,
stars,
messages,
lt_amount,
tr::lng_payment_confirm_amount(
tr::now,
lt_count,
stars,
Ui::Text::RichLangValue),
Ui::Text::RichLangValue)),
.confirmed = proceed,
.confirmText = tr::lng_payment_confirm_button(),
.confirmText = tr::lng_payment_confirm_button(
lt_count,
rpl::single(messages * 1.)),
.title = tr::lng_payment_confirm_title(),
});
const auto skip = st::defaultCheckbox.margin.top();