mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Added ability to retrieve required boost level for peer colors to api.
This commit is contained in:
@@ -97,21 +97,27 @@ const base::flat_map<uint8, int> &PeerColors::requiredLevelsChannel() const {
|
||||
return _requiredLevelsChannel;
|
||||
}
|
||||
|
||||
int PeerColors::requiredGroupLevelFor(PeerId channel, uint8 index) const {
|
||||
int PeerColors::requiredLevelFor(
|
||||
PeerId channel,
|
||||
uint8 index,
|
||||
bool isMegagroup,
|
||||
bool profile) const {
|
||||
if (Data::DecideColorIndex(channel) == index) {
|
||||
return 0;
|
||||
} else if (const auto i = _requiredLevelsGroup.find(index)
|
||||
; i != end(_requiredLevelsGroup)) {
|
||||
return i->second;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int PeerColors::requiredChannelLevelFor(PeerId channel, uint8 index) const {
|
||||
if (Data::DecideColorIndex(channel) == index) {
|
||||
return 0;
|
||||
} else if (const auto i = _requiredLevelsChannel.find(index)
|
||||
; i != end(_requiredLevelsChannel)) {
|
||||
if (profile) {
|
||||
const auto it = _profileColors.find(index);
|
||||
if (it != end(_profileColors)) {
|
||||
return isMegagroup
|
||||
? it->second.requiredLevelsGroup
|
||||
: it->second.requiredLevelsChannel;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
const auto &levels = isMegagroup
|
||||
? _requiredLevelsGroup
|
||||
: _requiredLevelsChannel;
|
||||
if (const auto i = levels.find(index); i != end(levels)) {
|
||||
return i->second;
|
||||
}
|
||||
return 1;
|
||||
|
||||
@@ -35,12 +35,11 @@ public:
|
||||
[[nodiscard]] auto requiredLevelsChannel() const
|
||||
-> const base::flat_map<uint8, int> &;
|
||||
|
||||
[[nodiscard]] int requiredGroupLevelFor(
|
||||
[[nodiscard]] int requiredLevelFor(
|
||||
PeerId channel,
|
||||
uint8 index) const;
|
||||
[[nodiscard]] int requiredChannelLevelFor(
|
||||
PeerId channel,
|
||||
uint8 index) const;
|
||||
uint8 index,
|
||||
bool isMegagroup,
|
||||
bool profile) const;
|
||||
|
||||
[[nodiscard]] std::optional<Data::ColorProfileSet> colorProfileFor(
|
||||
not_null<PeerData*> peer) const;
|
||||
|
||||
@@ -572,13 +572,11 @@ void Apply(
|
||||
} else {
|
||||
CheckBoostLevel(show, peer, [=](int level) {
|
||||
const auto peerColors = &peer->session().api().peerColors();
|
||||
const auto colorRequired = peer->isMegagroup()
|
||||
? peerColors->requiredGroupLevelFor(
|
||||
peer->id,
|
||||
values.colorIndex)
|
||||
: peerColors->requiredChannelLevelFor(
|
||||
peer->id,
|
||||
values.colorIndex);
|
||||
const auto colorRequired = peerColors->requiredLevelFor(
|
||||
peer->id,
|
||||
values.colorIndex,
|
||||
peer->isMegagroup(),
|
||||
values.forProfile);
|
||||
const auto limits = Data::LevelLimits(&peer->session());
|
||||
const auto iconRequired = values.backgroundEmojiId
|
||||
? limits.channelBgIconLevelMin()
|
||||
|
||||
Reference in New Issue
Block a user