2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-03 07:56:03 +00:00

Fix editing price per message.

This commit is contained in:
John Preston
2025-07-02 12:36:07 +04:00
parent 33671e7737
commit fd24f7045e
6 changed files with 29 additions and 7 deletions

View File

@@ -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;
}