mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-07-25 15:03:03 +02:00
Save correct starsPerMessage for admins.
This commit is contained in:
parent
13ecc6a56b
commit
33671e7737
3 changed files with 24 additions and 3 deletions
|
@ -360,6 +360,12 @@ void ShowEditPermissions(
|
|||
navigation->parentController()->show(Box(std::move(createBox)));
|
||||
}
|
||||
|
||||
[[nodiscard]] int CurrentPricePerMessage(ChannelData *monoforumLink) {
|
||||
return monoforumLink
|
||||
? monoforumLink->owner().commonStarsPerMessage(monoforumLink)
|
||||
: -1;
|
||||
}
|
||||
|
||||
class Controller : public base::has_weak_ptr {
|
||||
public:
|
||||
Controller(
|
||||
|
@ -1083,8 +1089,8 @@ void Controller::fillDirectMessagesButton() {
|
|||
}
|
||||
|
||||
const auto monoforumLink = _peer->asChannel()->monoforumLink();
|
||||
_starsPerDirectMessageSavedValue = rpl::variable<int>(
|
||||
monoforumLink ? monoforumLink->starsPerMessage() : -1);
|
||||
const auto perMessage = CurrentPricePerMessage(monoforumLink);
|
||||
_starsPerDirectMessageSavedValue = rpl::variable<int>(perMessage);
|
||||
|
||||
auto label = _starsPerDirectMessageSavedValue->value(
|
||||
) | rpl::map([](int starsPerMessage) {
|
||||
|
@ -2401,7 +2407,7 @@ void Controller::saveDirectMessagesPrice() {
|
|||
return continueSave();
|
||||
}
|
||||
const auto monoforumLink = channel->monoforumLink();
|
||||
const auto current = monoforumLink ? monoforumLink->starsPerMessage() : -1;
|
||||
const auto current = CurrentPricePerMessage(monoforumLink);
|
||||
const auto desired = _savingData.starsPerDirectMessage
|
||||
? *_savingData.starsPerDirectMessage
|
||||
: current;
|
||||
|
|
|
@ -999,6 +999,10 @@ not_null<PeerData*> Session::processChat(const MTPChat &data) {
|
|||
= data.vsend_paid_messages_stars().has_value();
|
||||
if (!hasStarsPerMessage) {
|
||||
channel->setStarsPerMessage(0);
|
||||
} else if (const auto count = data.vsend_paid_messages_stars()->v) {
|
||||
_commonStarsPerMessage[channel] = count;
|
||||
} else {
|
||||
_commonStarsPerMessage.remove(channel);
|
||||
}
|
||||
const auto storiesState = minimal
|
||||
? std::optional<Data::Stories::PeerSourceState>()
|
||||
|
@ -5137,6 +5141,11 @@ rpl::producer<SentFromScheduled> Session::sentFromScheduled() const {
|
|||
return _sentFromScheduled.events();
|
||||
}
|
||||
|
||||
int Session::commonStarsPerMessage(not_null<ChannelData*> channel) const {
|
||||
const auto i = _commonStarsPerMessage.find(channel);
|
||||
return (i != end(_commonStarsPerMessage)) ? i->second : 0;
|
||||
}
|
||||
|
||||
void Session::clearLocalStorage() {
|
||||
_cache->close();
|
||||
_cache->clear();
|
||||
|
|
|
@ -860,6 +860,9 @@ public:
|
|||
void sentFromScheduled(SentFromScheduled value);
|
||||
[[nodiscard]] rpl::producer<SentFromScheduled> sentFromScheduled() const;
|
||||
|
||||
[[nodiscard]] int commonStarsPerMessage(
|
||||
not_null<ChannelData*> channel) const;
|
||||
|
||||
void clearLocalStorage();
|
||||
|
||||
private:
|
||||
|
@ -1165,6 +1168,9 @@ private:
|
|||
not_null<ChannelData*>,
|
||||
ChannelId>> _postponedMonoforumLinkedIds;
|
||||
|
||||
// This one from `channel`, not `channelFull`.
|
||||
base::flat_map<not_null<ChannelData*>, int> _commonStarsPerMessage;
|
||||
|
||||
MessageIdsList _mimeForwardIds;
|
||||
|
||||
std::weak_ptr<CreditsSubsRebuilder> _creditsSubsRebuilder;
|
||||
|
|
Loading…
Add table
Reference in a new issue