mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 14:38:15 +00:00
Boost community features list.
This commit is contained in:
@@ -527,9 +527,13 @@ void Apply(
|
||||
} else {
|
||||
CheckBoostLevel(show, peer, [=](int level) {
|
||||
const auto peerColors = &peer->session().api().peerColors();
|
||||
const auto colorRequired = peerColors->requiredLevelFor(
|
||||
peer->id,
|
||||
values.colorIndex);
|
||||
const auto colorRequired = peer->isMegagroup()
|
||||
? peerColors->requiredGroupLevelFor(
|
||||
peer->id,
|
||||
values.colorIndex)
|
||||
: peerColors->requiredChannelLevelFor(
|
||||
peer->id,
|
||||
values.colorIndex);
|
||||
const auto iconRequired = values.backgroundEmojiId
|
||||
? session->account().appConfig().get<int>(
|
||||
"channel_bg_icon_level_min",
|
||||
|
@@ -7,10 +7,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "boxes/peers/replace_boost_box.h"
|
||||
|
||||
#include "api/api_peer_colors.h"
|
||||
#include "apiwrap.h"
|
||||
#include "base/event_filter.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "boxes/peer_list_box.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_cloud_themes.h"
|
||||
#include "data/data_session.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "main/main_account.h"
|
||||
@@ -419,6 +422,47 @@ Ui::BoostCounters ParseBoostCounters(
|
||||
};
|
||||
}
|
||||
|
||||
Ui::BoostFeatures LookupBoostFeatures(not_null<ChannelData*> channel) {
|
||||
const auto group = channel->isMegagroup();
|
||||
const auto appConfig = &channel->session().account().appConfig();
|
||||
const auto get = [&](const QString &key, int fallback, bool ok = true) {
|
||||
return ok ? appConfig->get<int>(key, fallback) : 0;
|
||||
};
|
||||
|
||||
auto nameColorsByLevel = base::flat_map<int, int>();
|
||||
auto linkStylesByLevel = base::flat_map<int, int>();
|
||||
const auto peerColors = &channel->session().api().peerColors();
|
||||
const auto &list = group
|
||||
? peerColors->requiredLevelsGroup()
|
||||
: peerColors->requiredLevelsChannel();
|
||||
const auto indices = peerColors->indicesCurrent();
|
||||
for (const auto &[index, level] : list) {
|
||||
if (!Ui::ColorPatternIndex(indices, index, false)) {
|
||||
++nameColorsByLevel[level];
|
||||
}
|
||||
++linkStylesByLevel[level];
|
||||
}
|
||||
|
||||
return Ui::BoostFeatures{
|
||||
.nameColorsByLevel = std::move(nameColorsByLevel),
|
||||
.linkStylesByLevel = std::move(linkStylesByLevel),
|
||||
.linkLogoLevel = get(u"channel_bg_icon_level_min"_q, 4, !group),
|
||||
.transcribeLevel = get(u"group_transcribe_level_min"_q, 6, group),
|
||||
.emojiPackLevel = get(u"group_emoji_stickers_level_min"_q, 4, group),
|
||||
.emojiStatusLevel = get(group
|
||||
? u"group_emoji_status_level_min"_q
|
||||
: u"channel_emoji_status_level_min"_q, 8),
|
||||
.wallpaperLevel = get(group
|
||||
? u"group_wallpaper_level_min"_q
|
||||
: u"channel_wallpaper_level_min"_q, 9),
|
||||
.wallpapersCount = int(
|
||||
channel->owner().cloudThemes().chatThemes().size()),
|
||||
.customWallpaperLevel = get(group
|
||||
? u"channel_custom_wallpaper_level_min"_q
|
||||
: u"group_custom_wallpaper_level_min"_q, 10),
|
||||
};
|
||||
}
|
||||
|
||||
int BoostsForGift(not_null<Main::Session*> session) {
|
||||
const auto key = u"boosts_per_sent_gift"_q;
|
||||
return session->account().appConfig().get<int>(key, 0);
|
||||
|
@@ -9,12 +9,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
#include "base/object_ptr.h"
|
||||
|
||||
class ChannelData;
|
||||
|
||||
namespace Main {
|
||||
class Session;
|
||||
} // namespace Main
|
||||
|
||||
namespace Ui {
|
||||
struct BoostCounters;
|
||||
struct BoostFeatures;
|
||||
class BoxContent;
|
||||
class RpWidget;
|
||||
} // namespace Ui
|
||||
@@ -39,6 +42,9 @@ struct ForChannelBoostSlots {
|
||||
[[nodiscard]] Ui::BoostCounters ParseBoostCounters(
|
||||
const MTPpremium_BoostsStatus &status);
|
||||
|
||||
[[nodiscard]] Ui::BoostFeatures LookupBoostFeatures(
|
||||
not_null<ChannelData*> channel);
|
||||
|
||||
[[nodiscard]] int BoostsForGift(not_null<Main::Session*> session);
|
||||
|
||||
object_ptr<Ui::BoxContent> ReassignBoostsBox(
|
||||
|
Reference in New Issue
Block a user