mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-28 13:08:56 +00:00
Fix editing price per message.
This commit is contained in:
parent
33671e7737
commit
fd24f7045e
@ -255,7 +255,7 @@ void SaveStarsPerMessage(
|
|||||||
api->clearModifyRequest(key);
|
api->clearModifyRequest(key);
|
||||||
api->applyUpdates(result);
|
api->applyUpdates(result);
|
||||||
if (!broadcast) {
|
if (!broadcast) {
|
||||||
channel->setStarsPerMessage(starsPerMessage);
|
channel->owner().editStarsPerMessage(channel, starsPerMessage);
|
||||||
}
|
}
|
||||||
done(true);
|
done(true);
|
||||||
}).fail([=](const MTP::Error &error) {
|
}).fail([=](const MTP::Error &error) {
|
||||||
@ -265,7 +265,9 @@ void SaveStarsPerMessage(
|
|||||||
done(false);
|
done(false);
|
||||||
} else {
|
} else {
|
||||||
if (!broadcast) {
|
if (!broadcast) {
|
||||||
channel->setStarsPerMessage(starsPerMessage);
|
channel->owner().editStarsPerMessage(
|
||||||
|
channel,
|
||||||
|
starsPerMessage);
|
||||||
}
|
}
|
||||||
done(true);
|
done(true);
|
||||||
}
|
}
|
||||||
@ -362,7 +364,7 @@ void ShowEditPermissions(
|
|||||||
|
|
||||||
[[nodiscard]] int CurrentPricePerMessage(ChannelData *monoforumLink) {
|
[[nodiscard]] int CurrentPricePerMessage(ChannelData *monoforumLink) {
|
||||||
return monoforumLink
|
return monoforumLink
|
||||||
? monoforumLink->owner().commonStarsPerMessage(monoforumLink)
|
? monoforumLink->commonStarsPerMessage()
|
||||||
: -1;
|
: -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1179,7 +1179,7 @@ void ShowEditPeerPermissionsBox(
|
|||||||
if (available) {
|
if (available) {
|
||||||
Ui::AddSkip(inner);
|
Ui::AddSkip(inner);
|
||||||
const auto starsPerMessage = peer->isChannel()
|
const auto starsPerMessage = peer->isChannel()
|
||||||
? peer->asChannel()->starsPerMessage()
|
? peer->asChannel()->commonStarsPerMessage()
|
||||||
: 0;
|
: 0;
|
||||||
charging = inner->add(object_ptr<Ui::SettingsButton>(
|
charging = inner->add(object_ptr<Ui::SettingsButton>(
|
||||||
inner,
|
inner,
|
||||||
|
@ -957,6 +957,10 @@ int ChannelData::starsPerMessage() const {
|
|||||||
return _starsPerMessage;
|
return _starsPerMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ChannelData::commonStarsPerMessage() const {
|
||||||
|
return owner().commonStarsPerMessage(this);
|
||||||
|
}
|
||||||
|
|
||||||
void ChannelData::setStarsPerMessage(int stars) {
|
void ChannelData::setStarsPerMessage(int stars) {
|
||||||
if (_starsPerMessage != stars) {
|
if (_starsPerMessage != stars) {
|
||||||
_starsPerMessage = stars;
|
_starsPerMessage = stars;
|
||||||
|
@ -502,6 +502,7 @@ public:
|
|||||||
|
|
||||||
void setStarsPerMessage(int stars);
|
void setStarsPerMessage(int stars);
|
||||||
[[nodiscard]] int starsPerMessage() const;
|
[[nodiscard]] int starsPerMessage() const;
|
||||||
|
[[nodiscard]] int commonStarsPerMessage() const;
|
||||||
|
|
||||||
[[nodiscard]] int peerGiftsCount() const;
|
[[nodiscard]] int peerGiftsCount() const;
|
||||||
void setPeerGiftsCount(int count);
|
void setPeerGiftsCount(int count);
|
||||||
|
@ -999,6 +999,7 @@ not_null<PeerData*> Session::processChat(const MTPChat &data) {
|
|||||||
= data.vsend_paid_messages_stars().has_value();
|
= data.vsend_paid_messages_stars().has_value();
|
||||||
if (!hasStarsPerMessage) {
|
if (!hasStarsPerMessage) {
|
||||||
channel->setStarsPerMessage(0);
|
channel->setStarsPerMessage(0);
|
||||||
|
_commonStarsPerMessage.remove(channel);
|
||||||
} else if (const auto count = data.vsend_paid_messages_stars()->v) {
|
} else if (const auto count = data.vsend_paid_messages_stars()->v) {
|
||||||
_commonStarsPerMessage[channel] = count;
|
_commonStarsPerMessage[channel] = count;
|
||||||
} else {
|
} else {
|
||||||
@ -5141,7 +5142,20 @@ rpl::producer<SentFromScheduled> Session::sentFromScheduled() const {
|
|||||||
return _sentFromScheduled.events();
|
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);
|
const auto i = _commonStarsPerMessage.find(channel);
|
||||||
return (i != end(_commonStarsPerMessage)) ? i->second : 0;
|
return (i != end(_commonStarsPerMessage)) ? i->second : 0;
|
||||||
}
|
}
|
||||||
|
@ -860,8 +860,9 @@ public:
|
|||||||
void sentFromScheduled(SentFromScheduled value);
|
void sentFromScheduled(SentFromScheduled value);
|
||||||
[[nodiscard]] rpl::producer<SentFromScheduled> sentFromScheduled() const;
|
[[nodiscard]] rpl::producer<SentFromScheduled> sentFromScheduled() const;
|
||||||
|
|
||||||
|
void editStarsPerMessage(not_null<ChannelData*> channel, int count);
|
||||||
[[nodiscard]] int commonStarsPerMessage(
|
[[nodiscard]] int commonStarsPerMessage(
|
||||||
not_null<ChannelData*> channel) const;
|
not_null<const ChannelData*> channel) const;
|
||||||
|
|
||||||
void clearLocalStorage();
|
void clearLocalStorage();
|
||||||
|
|
||||||
@ -1169,7 +1170,7 @@ private:
|
|||||||
ChannelId>> _postponedMonoforumLinkedIds;
|
ChannelId>> _postponedMonoforumLinkedIds;
|
||||||
|
|
||||||
// This one from `channel`, not `channelFull`.
|
// 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;
|
MessageIdsList _mimeForwardIds;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user