mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-07-25 15:03:03 +02:00
Use server provided default stars count for direct.
This commit is contained in:
parent
8654ffb6fb
commit
a72782e232
3 changed files with 32 additions and 19 deletions
|
@ -45,7 +45,6 @@ namespace {
|
|||
|
||||
constexpr auto kPremiumsRowId = PeerId(FakeChatId(BareId(1))).value;
|
||||
constexpr auto kMiniAppsRowId = PeerId(FakeChatId(BareId(2))).value;
|
||||
constexpr auto kDefaultDirectMessagesPrice = 10;
|
||||
constexpr auto kDefaultPrivateMessagesPrice = 10;
|
||||
|
||||
using Exceptions = Api::UserPrivacy::Exceptions;
|
||||
|
@ -1227,24 +1226,33 @@ rpl::producer<int> SetupChargeSlider(
|
|||
const auto skip = 2 * st::defaultVerticalListSkip;
|
||||
Ui::AddSkip(container, skip);
|
||||
|
||||
auto dollars = state->stars.value() | rpl::map([=](int stars) {
|
||||
const auto ratio = peer->session().appConfig().starsWithdrawRate();
|
||||
const auto details = container->add(
|
||||
object_ptr<Ui::VerticalLayout>(container));
|
||||
state->stars.value() | rpl::start_with_next([=](int stars) {
|
||||
while (details->count()) {
|
||||
delete details->widgetAt(0);
|
||||
}
|
||||
if (!stars) {
|
||||
Ui::AddDivider(details);
|
||||
return;
|
||||
}
|
||||
const auto &appConfig = peer->session().appConfig();
|
||||
const auto percent = appConfig.paidMessageCommission();
|
||||
const auto ratio = appConfig.starsWithdrawRate();
|
||||
const auto dollars = int(base::SafeRound(stars * ratio));
|
||||
return '~' + Ui::FillAmountAndCurrency(dollars, u"USD"_q);
|
||||
});
|
||||
const auto percent = peer->session().appConfig().paidMessageCommission();
|
||||
Ui::AddDividerText(
|
||||
container,
|
||||
(broadcast
|
||||
? tr::lng_manage_monoforum_price_about
|
||||
: group
|
||||
? tr::lng_rights_charge_price_about
|
||||
: tr::lng_messages_privacy_price_about)(
|
||||
lt_percent,
|
||||
rpl::single(QString::number(percent / 10.) + '%'),
|
||||
lt_amount,
|
||||
std::move(dollars)));
|
||||
|
||||
const auto amount = Ui::FillAmountAndCurrency(dollars, u"USD"_q);
|
||||
Ui::AddDividerText(
|
||||
details,
|
||||
(broadcast
|
||||
? tr::lng_manage_monoforum_price_about
|
||||
: group
|
||||
? tr::lng_rights_charge_price_about
|
||||
: tr::lng_messages_privacy_price_about)(
|
||||
lt_percent,
|
||||
rpl::single(QString::number(percent / 10.) + '%'),
|
||||
lt_amount,
|
||||
rpl::single('~' + amount)));
|
||||
}, details->lifetime());
|
||||
return state->stars.value();
|
||||
}
|
||||
|
||||
|
@ -1298,7 +1306,7 @@ void EditDirectMessagesPriceBox(
|
|||
inner,
|
||||
channel,
|
||||
savedValue,
|
||||
kDefaultDirectMessagesPrice,
|
||||
channel->session().appConfig().paidMessageChannelStarsDefault(),
|
||||
true
|
||||
) | rpl::start_with_next([=](int stars) {
|
||||
*result = stars;
|
||||
|
|
|
@ -105,6 +105,10 @@ int AppConfig::paidMessageCommission() const {
|
|||
return get<int>(u"stars_paid_message_commission_permille"_q, 850);
|
||||
}
|
||||
|
||||
int AppConfig::paidMessageChannelStarsDefault() const {
|
||||
return get<int>(u"stars_paid_messages_channel_amount_default"_q, 10);
|
||||
}
|
||||
|
||||
int AppConfig::pinnedGiftsLimit() const {
|
||||
return get<int>(u"stargifts_pinned_to_top_limit"_q, 6);
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@ public:
|
|||
[[nodiscard]] bool paidMessagesAvailable() const;
|
||||
[[nodiscard]] int paidMessageStarsMax() const;
|
||||
[[nodiscard]] int paidMessageCommission() const;
|
||||
[[nodiscard]] int paidMessageChannelStarsDefault() const;
|
||||
|
||||
[[nodiscard]] int pinnedGiftsLimit() const;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue