mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-07-27 07:52:57 +02:00
Improve conditions / phrases.
This commit is contained in:
parent
ef280dae3e
commit
24121fbbce
5 changed files with 76 additions and 11 deletions
|
@ -4452,6 +4452,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_suggest_options_date_publish" = "Publish";
|
||||
"lng_suggest_options_date_now" = "Publish Now";
|
||||
"lng_suggest_options_date_about" = "Select the date and time you want the message to be published.";
|
||||
"lng_suggest_options_you_get" = "You will receive {amount} ({percent}) for publishing this post.";
|
||||
"lng_suggest_options_offer" = "Offer {amount}";
|
||||
"lng_suggest_options_offer_free" = "Offer for Free";
|
||||
"lng_suggest_options_update" = "Update Terms";
|
||||
|
|
|
@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "history/history.h"
|
||||
#include "history/history_item.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "main/main_app_config.h"
|
||||
#include "main/main_session.h"
|
||||
#include "menu/menu_ttl_validator.h"
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
|
@ -33,12 +34,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "styles/style_layers.h"
|
||||
#include "styles/style_boxes.h"
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr auto kPaidShowLive = 86400;
|
||||
|
||||
} // namespace
|
||||
|
||||
DeleteMessagesBox::DeleteMessagesBox(
|
||||
QWidget*,
|
||||
not_null<HistoryItem*> item,
|
||||
|
@ -507,7 +502,9 @@ PaidPostType DeleteMessagesBox::paidPostType() const {
|
|||
const auto type = item->paidType();
|
||||
if (type != PaidPostType::None) {
|
||||
const auto date = item->date();
|
||||
if (now < date || now - date <= kPaidShowLive) {
|
||||
const auto config = &item->history()->session().appConfig();
|
||||
const auto limit = config->suggestedPostAgeMin();
|
||||
if (now < date || now - date <= limit) {
|
||||
if (type == PaidPostType::Ton) {
|
||||
return type;
|
||||
} else if (type == PaidPostType::Stars) {
|
||||
|
|
|
@ -109,6 +109,38 @@ void ChooseSuggestPriceBox(
|
|||
}
|
||||
};
|
||||
|
||||
const auto appConfig = &args.peer->session().appConfig();
|
||||
const auto starsMul = appConfig->suggestedPostCommissionStars();
|
||||
const auto tonMul = appConfig->suggestedPostCommissionTon();
|
||||
|
||||
const auto starsPrice = [=] {
|
||||
return rpl::single(
|
||||
CreditsAmount()
|
||||
) | rpl::then(state->price.value(
|
||||
) | rpl::filter([=](CreditsAmount amount) {
|
||||
return amount.stars();
|
||||
}));
|
||||
};
|
||||
const auto tonPrice = [=] {
|
||||
return rpl::single(
|
||||
CreditsAmount(0, 0, CreditsType::Ton)
|
||||
) | rpl::then(state->price.value(
|
||||
) | rpl::filter([=](CreditsAmount amount) {
|
||||
return amount.ton();
|
||||
}));
|
||||
};
|
||||
const auto formatPrice = [=](int mul) {
|
||||
return [=](CreditsAmount amount) {
|
||||
const auto value = (amount.value() * mul / 1000.);
|
||||
const auto whole = int(std::floor(value));
|
||||
//const auto nano = int(base::SafeRound(
|
||||
// (value - whole) * Ui::kNanosInOne));
|
||||
const auto nano = 0;
|
||||
return Lang::FormatCreditsAmountWithCurrency(
|
||||
CreditsAmount(whole, nano, amount.type()));
|
||||
};
|
||||
};
|
||||
|
||||
const auto peer = args.peer;
|
||||
const auto admin = peer->amMonoforumAdmin();
|
||||
const auto broadcast = peer->monoforumBroadcast();
|
||||
|
@ -118,7 +150,7 @@ void ChooseSuggestPriceBox(
|
|||
session->credits().load();
|
||||
session->credits().tonLoad();
|
||||
}
|
||||
const auto starsMin = 0;
|
||||
const auto starsMin = session->appConfig().suggestedPostStarsMin();
|
||||
const auto starsMax = session->appConfig().suggestedPostStarsMax();
|
||||
const auto nanoTonMin = session->appConfig().suggestedPostNanoTonMin();
|
||||
const auto nanoTonMax = session->appConfig().suggestedPostNanoTonMax();
|
||||
|
@ -299,11 +331,20 @@ void ChooseSuggestPriceBox(
|
|||
starsFieldWrap->resize(width, starsField->height());
|
||||
}, starsFieldWrap->lifetime());
|
||||
|
||||
const auto starsCommission = QString::number(starsMul / 10.) + '%';
|
||||
const auto tonCommission = QString::number(tonMul / 10.) + '%';
|
||||
|
||||
Ui::AddSkip(starsInner);
|
||||
Ui::AddSkip(starsInner);
|
||||
Ui::AddDividerText(
|
||||
starsInner,
|
||||
tr::lng_suggest_options_stars_price_about());
|
||||
(admin
|
||||
? tr::lng_suggest_options_you_get(
|
||||
lt_amount,
|
||||
starsPrice() | rpl::map(formatPrice(starsMul)),
|
||||
lt_percent,
|
||||
rpl::single(starsCommission))
|
||||
: tr::lng_suggest_options_stars_price_about()));
|
||||
|
||||
const auto tonWrap = container->add(
|
||||
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
||||
|
@ -352,7 +393,13 @@ void ChooseSuggestPriceBox(
|
|||
Ui::AddSkip(tonInner);
|
||||
Ui::AddDividerText(
|
||||
tonInner,
|
||||
tr::lng_suggest_options_ton_price_about());
|
||||
(admin
|
||||
? tr::lng_suggest_options_you_get(
|
||||
lt_amount,
|
||||
tonPrice() | rpl::map(formatPrice(tonMul)),
|
||||
lt_percent,
|
||||
rpl::single(tonCommission))
|
||||
: tr::lng_suggest_options_ton_price_about()));
|
||||
|
||||
tonWrap->toggleOn(state->ton.value(), anim::type::instant);
|
||||
starsWrap->toggleOn(
|
||||
|
@ -374,7 +421,7 @@ void ChooseSuggestPriceBox(
|
|||
nanos = now.value_or(0);
|
||||
} else {
|
||||
const auto now = starsField->getLastText().toLongLong();
|
||||
if (now < starsMin || now > starsMax) {
|
||||
if (now && (now < starsMin || now > starsMax)) {
|
||||
starsField->showError();
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -170,6 +170,18 @@ int AppConfig::todoListItemTextLimit() const {
|
|||
return get<int>(u"todo_item_length_max"_q, 64);
|
||||
}
|
||||
|
||||
int AppConfig::suggestedPostCommissionStars() const {
|
||||
return get<int>(u"stars_suggested_post_commission_permille"_q, 850);
|
||||
}
|
||||
|
||||
int AppConfig::suggestedPostCommissionTon() const {
|
||||
return get<int>(u"ton_suggested_post_commission_permille"_q, 850);
|
||||
}
|
||||
|
||||
int AppConfig::suggestedPostStarsMin() const {
|
||||
return get<int>(u"stars_suggested_post_amount_min"_q, 5);
|
||||
}
|
||||
|
||||
int AppConfig::suggestedPostStarsMax() const {
|
||||
return get<int>(u"stars_suggested_post_amount_max"_q, 100'000);
|
||||
}
|
||||
|
@ -192,6 +204,10 @@ int AppConfig::suggestedPostDelayMax() const {
|
|||
return get<int>(u"appConfig.stars_suggested_post_future_max"_q, 2678400);
|
||||
}
|
||||
|
||||
TimeId AppConfig::suggestedPostAgeMin() const {
|
||||
return get<int>(u"stars_suggested_post_age_min"_q, 86400);
|
||||
}
|
||||
|
||||
void AppConfig::refresh(bool force) {
|
||||
if (_requestId || !_api) {
|
||||
if (force) {
|
||||
|
|
|
@ -92,11 +92,15 @@ public:
|
|||
[[nodiscard]] int todoListTitleLimit() const;
|
||||
[[nodiscard]] int todoListItemTextLimit() const;
|
||||
|
||||
[[nodiscard]] int suggestedPostCommissionStars() const;
|
||||
[[nodiscard]] int suggestedPostCommissionTon() const;
|
||||
[[nodiscard]] int suggestedPostStarsMin() const;
|
||||
[[nodiscard]] int suggestedPostStarsMax() const;
|
||||
[[nodiscard]] int64 suggestedPostNanoTonMin() const;
|
||||
[[nodiscard]] int64 suggestedPostNanoTonMax() const;
|
||||
[[nodiscard]] int suggestedPostDelayMin() const;
|
||||
[[nodiscard]] int suggestedPostDelayMax() const;
|
||||
[[nodiscard]] TimeId suggestedPostAgeMin() const;
|
||||
|
||||
void refresh(bool force = false);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue