mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 22:54:01 +02:00
Renamed SubscriptionOption with PremiumSubscriptionOption.
This commit is contained in:
parent
52a199a362
commit
c8a3b0ab80
10 changed files with 37 additions and 34 deletions
|
@ -39,9 +39,9 @@ namespace {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] Data::SubscriptionOptions GiftCodesFromTL(
|
[[nodiscard]] Data::PremiumSubscriptionOptions GiftCodesFromTL(
|
||||||
const QVector<MTPPremiumGiftCodeOption> &tlOptions) {
|
const QVector<MTPPremiumGiftCodeOption> &tlOptions) {
|
||||||
auto options = SubscriptionOptionsFromTL(tlOptions);
|
auto options = PremiumSubscriptionOptionsFromTL(tlOptions);
|
||||||
for (auto i = 0; i < options.size(); i++) {
|
for (auto i = 0; i < options.size(); i++) {
|
||||||
const auto &tlOption = tlOptions[i].data();
|
const auto &tlOption = tlOptions[i].data();
|
||||||
const auto perUserText = Ui::FillAmountAndCurrency(
|
const auto perUserText = Ui::FillAmountAndCurrency(
|
||||||
|
@ -143,7 +143,7 @@ void Premium::reloadPromo() {
|
||||||
const auto &data = result.data();
|
const auto &data = result.data();
|
||||||
_session->data().processUsers(data.vusers());
|
_session->data().processUsers(data.vusers());
|
||||||
|
|
||||||
_subscriptionOptions = SubscriptionOptionsFromTL(
|
_subscriptionOptions = PremiumSubscriptionOptionsFromTL(
|
||||||
data.vperiod_options().v);
|
data.vperiod_options().v);
|
||||||
for (const auto &option : data.vperiod_options().v) {
|
for (const auto &option : data.vperiod_options().v) {
|
||||||
if (option.data().vmonths().v == 1) {
|
if (option.data().vmonths().v == 1) {
|
||||||
|
@ -372,7 +372,7 @@ void Premium::resolveGiveawayInfo(
|
||||||
}).send();
|
}).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Data::SubscriptionOptions &Premium::subscriptionOptions() const {
|
const Data::PremiumSubscriptionOptions &Premium::subscriptionOptions() const {
|
||||||
return _subscriptionOptions;
|
return _subscriptionOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -547,7 +547,7 @@ Payments::InvoicePremiumGiftCode PremiumGiftCodeOptions::invoice(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Data::SubscriptionOptions PremiumGiftCodeOptions::options(int amount) {
|
Data::PremiumSubscriptionOptions PremiumGiftCodeOptions::options(int amount) {
|
||||||
const auto it = _subscriptionOptions.find(amount);
|
const auto it = _subscriptionOptions.find(amount);
|
||||||
if (it != end(_subscriptionOptions)) {
|
if (it != end(_subscriptionOptions)) {
|
||||||
return it->second;
|
return it->second;
|
||||||
|
|
|
@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "data/data_subscription_option.h"
|
#include "data/data_premium_subscription_option.h"
|
||||||
#include "mtproto/sender.h"
|
#include "mtproto/sender.h"
|
||||||
|
|
||||||
class History;
|
class History;
|
||||||
|
@ -106,7 +106,7 @@ public:
|
||||||
Fn<void(GiveawayInfo)> done);
|
Fn<void(GiveawayInfo)> done);
|
||||||
|
|
||||||
[[nodiscard]] auto subscriptionOptions() const
|
[[nodiscard]] auto subscriptionOptions() const
|
||||||
-> const Data::SubscriptionOptions &;
|
-> const Data::PremiumSubscriptionOptions &;
|
||||||
|
|
||||||
[[nodiscard]] rpl::producer<> somePremiumRequiredResolved() const;
|
[[nodiscard]] rpl::producer<> somePremiumRequiredResolved() const;
|
||||||
void resolvePremiumRequired(not_null<UserData*> user);
|
void resolvePremiumRequired(not_null<UserData*> user);
|
||||||
|
@ -156,7 +156,7 @@ private:
|
||||||
MsgId _giveawayInfoMessageId = 0;
|
MsgId _giveawayInfoMessageId = 0;
|
||||||
Fn<void(GiveawayInfo)> _giveawayInfoDone;
|
Fn<void(GiveawayInfo)> _giveawayInfoDone;
|
||||||
|
|
||||||
Data::SubscriptionOptions _subscriptionOptions;
|
Data::PremiumSubscriptionOptions _subscriptionOptions;
|
||||||
|
|
||||||
rpl::event_stream<> _somePremiumRequiredResolved;
|
rpl::event_stream<> _somePremiumRequiredResolved;
|
||||||
base::flat_set<not_null<UserData*>> _resolvePremiumRequiredUsers;
|
base::flat_set<not_null<UserData*>> _resolvePremiumRequiredUsers;
|
||||||
|
@ -170,7 +170,7 @@ public:
|
||||||
PremiumGiftCodeOptions(not_null<PeerData*> peer);
|
PremiumGiftCodeOptions(not_null<PeerData*> peer);
|
||||||
|
|
||||||
[[nodiscard]] rpl::producer<rpl::no_value, QString> request();
|
[[nodiscard]] rpl::producer<rpl::no_value, QString> request();
|
||||||
[[nodiscard]] Data::SubscriptionOptions options(int amount);
|
[[nodiscard]] Data::PremiumSubscriptionOptions options(int amount);
|
||||||
[[nodiscard]] const std::vector<int> &availablePresets() const;
|
[[nodiscard]] const std::vector<int> &availablePresets() const;
|
||||||
[[nodiscard]] int monthsFromPreset(int monthsIndex);
|
[[nodiscard]] int monthsFromPreset(int monthsIndex);
|
||||||
[[nodiscard]] Payments::InvoicePremiumGiftCode invoice(
|
[[nodiscard]] Payments::InvoicePremiumGiftCode invoice(
|
||||||
|
@ -200,8 +200,9 @@ private:
|
||||||
int quantity = 0;
|
int quantity = 0;
|
||||||
};
|
};
|
||||||
using Amount = int;
|
using Amount = int;
|
||||||
|
using PremiumSubscriptionOptions = Data::PremiumSubscriptionOptions;
|
||||||
const not_null<PeerData*> _peer;
|
const not_null<PeerData*> _peer;
|
||||||
base::flat_map<Amount, Data::SubscriptionOptions> _subscriptionOptions;
|
base::flat_map<Amount, PremiumSubscriptionOptions> _subscriptionOptions;
|
||||||
struct {
|
struct {
|
||||||
std::vector<int> months;
|
std::vector<int> months;
|
||||||
std::vector<float64> totalCosts;
|
std::vector<float64> totalCosts;
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace Api {
|
||||||
|
|
||||||
constexpr auto kDiscountDivider = 1.;
|
constexpr auto kDiscountDivider = 1.;
|
||||||
|
|
||||||
Data::SubscriptionOption CreateSubscriptionOption(
|
Data::PremiumSubscriptionOption CreateSubscriptionOption(
|
||||||
int months,
|
int months,
|
||||||
int monthlyAmount,
|
int monthlyAmount,
|
||||||
int64 amount,
|
int64 amount,
|
||||||
|
|
|
@ -7,11 +7,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "data/data_subscription_option.h"
|
#include "data/data_premium_subscription_option.h"
|
||||||
|
|
||||||
namespace Api {
|
namespace Api {
|
||||||
|
|
||||||
[[nodiscard]] Data::SubscriptionOption CreateSubscriptionOption(
|
[[nodiscard]] Data::PremiumSubscriptionOption CreateSubscriptionOption(
|
||||||
int months,
|
int months,
|
||||||
int monthlyAmount,
|
int monthlyAmount,
|
||||||
int64 amount,
|
int64 amount,
|
||||||
|
@ -19,22 +19,22 @@ namespace Api {
|
||||||
const QString &botUrl);
|
const QString &botUrl);
|
||||||
|
|
||||||
template<typename Option>
|
template<typename Option>
|
||||||
[[nodiscard]] Data::SubscriptionOptions SubscriptionOptionsFromTL(
|
[[nodiscard]] auto PremiumSubscriptionOptionsFromTL(
|
||||||
const QVector<Option> &tlOptions) {
|
const QVector<Option> &tlOpts) -> Data::PremiumSubscriptionOptions {
|
||||||
if (tlOptions.isEmpty()) {
|
if (tlOpts.isEmpty()) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
auto result = Data::SubscriptionOptions();
|
auto result = Data::PremiumSubscriptionOptions();
|
||||||
const auto monthlyAmount = [&] {
|
const auto monthlyAmount = [&] {
|
||||||
const auto &min = ranges::min_element(
|
const auto &min = ranges::min_element(
|
||||||
tlOptions,
|
tlOpts,
|
||||||
ranges::less(),
|
ranges::less(),
|
||||||
[](const Option &o) { return o.data().vamount().v; }
|
[](const Option &o) { return o.data().vamount().v; }
|
||||||
)->data();
|
)->data();
|
||||||
return min.vamount().v / float64(min.vmonths().v);
|
return min.vamount().v / float64(min.vmonths().v);
|
||||||
}();
|
}();
|
||||||
result.reserve(tlOptions.size());
|
result.reserve(tlOpts.size());
|
||||||
for (const auto &tlOption : tlOptions) {
|
for (const auto &tlOption : tlOpts) {
|
||||||
const auto &option = tlOption.data();
|
const auto &option = tlOption.data();
|
||||||
auto botUrl = QString();
|
auto botUrl = QString();
|
||||||
if constexpr (!std::is_same_v<Option, MTPPremiumGiftCodeOption>) {
|
if constexpr (!std::is_same_v<Option, MTPPremiumGiftCodeOption>) {
|
||||||
|
|
|
@ -23,7 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_media_types.h" // Data::GiveawayStart.
|
#include "data/data_media_types.h" // Data::GiveawayStart.
|
||||||
#include "data/data_peer_values.h" // Data::PeerPremiumValue.
|
#include "data/data_peer_values.h" // Data::PeerPremiumValue.
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_subscription_option.h"
|
#include "data/data_premium_subscription_option.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "data/stickers/data_custom_emoji.h"
|
#include "data/stickers/data_custom_emoji.h"
|
||||||
#include "info/channel_statistics/boosts/giveaway/boost_badge.h" // InfiniteRadialAnimationWidget.
|
#include "info/channel_statistics/boosts/giveaway/boost_badge.h" // InfiniteRadialAnimationWidget.
|
||||||
|
@ -66,8 +66,8 @@ namespace {
|
||||||
|
|
||||||
constexpr auto kUserpicsMax = size_t(3);
|
constexpr auto kUserpicsMax = size_t(3);
|
||||||
|
|
||||||
using GiftOption = Data::SubscriptionOption;
|
using GiftOption = Data::PremiumSubscriptionOption;
|
||||||
using GiftOptions = Data::SubscriptionOptions;
|
using GiftOptions = Data::PremiumSubscriptionOptions;
|
||||||
|
|
||||||
GiftOptions GiftOptionFromTL(const MTPDuserFull &data) {
|
GiftOptions GiftOptionFromTL(const MTPDuserFull &data) {
|
||||||
auto result = GiftOptions();
|
auto result = GiftOptions();
|
||||||
|
@ -75,7 +75,7 @@ GiftOptions GiftOptionFromTL(const MTPDuserFull &data) {
|
||||||
if (!gifts) {
|
if (!gifts) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
result = Api::SubscriptionOptionsFromTL(gifts->v);
|
result = Api::PremiumSubscriptionOptionsFromTL(gifts->v);
|
||||||
for (auto &option : result) {
|
for (auto &option : result) {
|
||||||
option.costPerMonth = tr::lng_premium_gift_per(
|
option.costPerMonth = tr::lng_premium_gift_per(
|
||||||
tr::now,
|
tr::now,
|
||||||
|
|
|
@ -9,7 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
|
|
||||||
struct SubscriptionOption {
|
struct PremiumSubscriptionOption {
|
||||||
QString duration;
|
QString duration;
|
||||||
QString discount;
|
QString discount;
|
||||||
QString costPerMonth;
|
QString costPerMonth;
|
||||||
|
@ -17,6 +17,6 @@ struct SubscriptionOption {
|
||||||
QString total;
|
QString total;
|
||||||
QString botUrl;
|
QString botUrl;
|
||||||
};
|
};
|
||||||
using SubscriptionOptions = std::vector<SubscriptionOption>;
|
using PremiumSubscriptionOptions = std::vector<PremiumSubscriptionOption>;
|
||||||
|
|
||||||
} // namespace Data
|
} // namespace Data
|
|
@ -67,8 +67,8 @@ namespace {
|
||||||
|
|
||||||
using SectionCustomTopBarData = Info::Settings::SectionCustomTopBarData;
|
using SectionCustomTopBarData = Info::Settings::SectionCustomTopBarData;
|
||||||
|
|
||||||
[[nodiscard]] Data::SubscriptionOptions SubscriptionOptionsForRows(
|
[[nodiscard]] Data::PremiumSubscriptionOptions SubscriptionOptionsForRows(
|
||||||
Data::SubscriptionOptions result) {
|
Data::PremiumSubscriptionOptions result) {
|
||||||
for (auto &option : result) {
|
for (auto &option : result) {
|
||||||
const auto total = option.costTotal;
|
const auto total = option.costTotal;
|
||||||
const auto perMonth = option.costPerMonth;
|
const auto perMonth = option.costPerMonth;
|
||||||
|
|
|
@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "ui/effects/premium_graphics.h"
|
#include "ui/effects/premium_graphics.h"
|
||||||
|
|
||||||
#include "data/data_subscription_option.h"
|
#include "data/data_premium_subscription_option.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "ui/abstract_button.h"
|
#include "ui/abstract_button.h"
|
||||||
#include "ui/effects/animations.h"
|
#include "ui/effects/animations.h"
|
||||||
|
@ -833,7 +833,7 @@ void ShowListBox(
|
||||||
void AddGiftOptions(
|
void AddGiftOptions(
|
||||||
not_null<Ui::VerticalLayout*> parent,
|
not_null<Ui::VerticalLayout*> parent,
|
||||||
std::shared_ptr<Ui::RadiobuttonGroup> group,
|
std::shared_ptr<Ui::RadiobuttonGroup> group,
|
||||||
std::vector<Data::SubscriptionOption> gifts,
|
std::vector<Data::PremiumSubscriptionOption> gifts,
|
||||||
const style::PremiumOption &st,
|
const style::PremiumOption &st,
|
||||||
bool topBadges) {
|
bool topBadges) {
|
||||||
|
|
||||||
|
@ -852,7 +852,9 @@ void AddGiftOptions(
|
||||||
|
|
||||||
const auto stops = GiftGradientStops();
|
const auto stops = GiftGradientStops();
|
||||||
|
|
||||||
const auto addRow = [&](const Data::SubscriptionOption &info, int index) {
|
const auto addRow = [&](
|
||||||
|
const Data::PremiumSubscriptionOption &info,
|
||||||
|
int index) {
|
||||||
const auto row = parent->add(
|
const auto row = parent->add(
|
||||||
object_ptr<Ui::AbstractButton>(parent),
|
object_ptr<Ui::AbstractButton>(parent),
|
||||||
st.rowPadding);
|
st.rowPadding);
|
||||||
|
|
|
@ -21,7 +21,7 @@ struct phrase;
|
||||||
enum lngtag_count : int;
|
enum lngtag_count : int;
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
struct SubscriptionOption;
|
struct PremiumSubscriptionOption;
|
||||||
} // namespace Data
|
} // namespace Data
|
||||||
|
|
||||||
namespace style {
|
namespace style {
|
||||||
|
@ -124,7 +124,7 @@ void ShowListBox(
|
||||||
void AddGiftOptions(
|
void AddGiftOptions(
|
||||||
not_null<Ui::VerticalLayout*> parent,
|
not_null<Ui::VerticalLayout*> parent,
|
||||||
std::shared_ptr<Ui::RadiobuttonGroup> group,
|
std::shared_ptr<Ui::RadiobuttonGroup> group,
|
||||||
std::vector<Data::SubscriptionOption> gifts,
|
std::vector<Data::PremiumSubscriptionOption> gifts,
|
||||||
const style::PremiumOption &st,
|
const style::PremiumOption &st,
|
||||||
bool topBadges = false);
|
bool topBadges = false);
|
||||||
|
|
||||||
|
|
|
@ -87,9 +87,9 @@ PRIVATE
|
||||||
data/data_channel_earn.h
|
data/data_channel_earn.h
|
||||||
data/data_credits.h
|
data/data_credits.h
|
||||||
data/data_credits_earn.h
|
data/data_credits_earn.h
|
||||||
|
data/data_premium_subscription_option.h
|
||||||
data/data_statistics_chart.cpp
|
data/data_statistics_chart.cpp
|
||||||
data/data_statistics_chart.h
|
data/data_statistics_chart.h
|
||||||
data/data_subscription_option.h
|
|
||||||
|
|
||||||
dialogs/dialogs_three_state_icon.h
|
dialogs/dialogs_three_state_icon.h
|
||||||
dialogs/ui/chat_search_empty.cpp
|
dialogs/ui/chat_search_empty.cpp
|
||||||
|
|
Loading…
Add table
Reference in a new issue