mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-07-11 16:22:55 +02:00
Fix editing price per message.
This commit is contained in:
parent
33671e7737
commit
fd24f7045e
6 changed files with 29 additions and 7 deletions
|
@ -255,7 +255,7 @@ void SaveStarsPerMessage(
|
|||
api->clearModifyRequest(key);
|
||||
api->applyUpdates(result);
|
||||
if (!broadcast) {
|
||||
channel->setStarsPerMessage(starsPerMessage);
|
||||
channel->owner().editStarsPerMessage(channel, starsPerMessage);
|
||||
}
|
||||
done(true);
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
|
@ -265,7 +265,9 @@ void SaveStarsPerMessage(
|
|||
done(false);
|
||||
} else {
|
||||
if (!broadcast) {
|
||||
channel->setStarsPerMessage(starsPerMessage);
|
||||
channel->owner().editStarsPerMessage(
|
||||
channel,
|
||||
starsPerMessage);
|
||||
}
|
||||
done(true);
|
||||
}
|
||||
|
@ -362,7 +364,7 @@ void ShowEditPermissions(
|
|||
|
||||
[[nodiscard]] int CurrentPricePerMessage(ChannelData *monoforumLink) {
|
||||
return monoforumLink
|
||||
? monoforumLink->owner().commonStarsPerMessage(monoforumLink)
|
||||
? monoforumLink->commonStarsPerMessage()
|
||||
: -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1179,7 +1179,7 @@ void ShowEditPeerPermissionsBox(
|
|||
if (available) {
|
||||
Ui::AddSkip(inner);
|
||||
const auto starsPerMessage = peer->isChannel()
|
||||
? peer->asChannel()->starsPerMessage()
|
||||
? peer->asChannel()->commonStarsPerMessage()
|
||||
: 0;
|
||||
charging = inner->add(object_ptr<Ui::SettingsButton>(
|
||||
inner,
|
||||
|
|
|
@ -957,6 +957,10 @@ int ChannelData::starsPerMessage() const {
|
|||
return _starsPerMessage;
|
||||
}
|
||||
|
||||
int ChannelData::commonStarsPerMessage() const {
|
||||
return owner().commonStarsPerMessage(this);
|
||||
}
|
||||
|
||||
void ChannelData::setStarsPerMessage(int stars) {
|
||||
if (_starsPerMessage != stars) {
|
||||
_starsPerMessage = stars;
|
||||
|
|
|
@ -502,6 +502,7 @@ public:
|
|||
|
||||
void setStarsPerMessage(int stars);
|
||||
[[nodiscard]] int starsPerMessage() const;
|
||||
[[nodiscard]] int commonStarsPerMessage() const;
|
||||
|
||||
[[nodiscard]] int peerGiftsCount() const;
|
||||
void setPeerGiftsCount(int count);
|
||||
|
|
|
@ -999,6 +999,7 @@ not_null<PeerData*> Session::processChat(const MTPChat &data) {
|
|||
= data.vsend_paid_messages_stars().has_value();
|
||||
if (!hasStarsPerMessage) {
|
||||
channel->setStarsPerMessage(0);
|
||||
_commonStarsPerMessage.remove(channel);
|
||||
} else if (const auto count = data.vsend_paid_messages_stars()->v) {
|
||||
_commonStarsPerMessage[channel] = count;
|
||||
} else {
|
||||
|
@ -5141,7 +5142,20 @@ rpl::producer<SentFromScheduled> Session::sentFromScheduled() const {
|
|||
return _sentFromScheduled.events();
|
||||
}
|
||||
|
||||
int Session::commonStarsPerMessage(not_null<ChannelData*> channel) const {
|
||||
void Session::editStarsPerMessage(
|
||||
not_null<ChannelData*> channel,
|
||||
int count) {
|
||||
// For admin it's zero, we're admin if we can edit it.
|
||||
channel->setStarsPerMessage(0);
|
||||
if (count) {
|
||||
_commonStarsPerMessage[channel] = count;
|
||||
} else {
|
||||
_commonStarsPerMessage.remove(channel);
|
||||
}
|
||||
}
|
||||
|
||||
int Session::commonStarsPerMessage(
|
||||
not_null<const ChannelData*> channel) const {
|
||||
const auto i = _commonStarsPerMessage.find(channel);
|
||||
return (i != end(_commonStarsPerMessage)) ? i->second : 0;
|
||||
}
|
||||
|
|
|
@ -860,8 +860,9 @@ public:
|
|||
void sentFromScheduled(SentFromScheduled value);
|
||||
[[nodiscard]] rpl::producer<SentFromScheduled> sentFromScheduled() const;
|
||||
|
||||
void editStarsPerMessage(not_null<ChannelData*> channel, int count);
|
||||
[[nodiscard]] int commonStarsPerMessage(
|
||||
not_null<ChannelData*> channel) const;
|
||||
not_null<const ChannelData*> channel) const;
|
||||
|
||||
void clearLocalStorage();
|
||||
|
||||
|
@ -1169,7 +1170,7 @@ private:
|
|||
ChannelId>> _postponedMonoforumLinkedIds;
|
||||
|
||||
// This one from `channel`, not `channelFull`.
|
||||
base::flat_map<not_null<ChannelData*>, int> _commonStarsPerMessage;
|
||||
base::flat_map<not_null<const ChannelData*>, int> _commonStarsPerMessage;
|
||||
|
||||
MessageIdsList _mimeForwardIds;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue