mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-07-26 15:33:02 +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)));
|
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 {
|
class Controller : public base::has_weak_ptr {
|
||||||
public:
|
public:
|
||||||
Controller(
|
Controller(
|
||||||
|
@ -1083,8 +1089,8 @@ void Controller::fillDirectMessagesButton() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto monoforumLink = _peer->asChannel()->monoforumLink();
|
const auto monoforumLink = _peer->asChannel()->monoforumLink();
|
||||||
_starsPerDirectMessageSavedValue = rpl::variable<int>(
|
const auto perMessage = CurrentPricePerMessage(monoforumLink);
|
||||||
monoforumLink ? monoforumLink->starsPerMessage() : -1);
|
_starsPerDirectMessageSavedValue = rpl::variable<int>(perMessage);
|
||||||
|
|
||||||
auto label = _starsPerDirectMessageSavedValue->value(
|
auto label = _starsPerDirectMessageSavedValue->value(
|
||||||
) | rpl::map([](int starsPerMessage) {
|
) | rpl::map([](int starsPerMessage) {
|
||||||
|
@ -2401,7 +2407,7 @@ void Controller::saveDirectMessagesPrice() {
|
||||||
return continueSave();
|
return continueSave();
|
||||||
}
|
}
|
||||||
const auto monoforumLink = channel->monoforumLink();
|
const auto monoforumLink = channel->monoforumLink();
|
||||||
const auto current = monoforumLink ? monoforumLink->starsPerMessage() : -1;
|
const auto current = CurrentPricePerMessage(monoforumLink);
|
||||||
const auto desired = _savingData.starsPerDirectMessage
|
const auto desired = _savingData.starsPerDirectMessage
|
||||||
? *_savingData.starsPerDirectMessage
|
? *_savingData.starsPerDirectMessage
|
||||||
: current;
|
: current;
|
||||||
|
|
|
@ -999,6 +999,10 @@ 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);
|
||||||
|
} else if (const auto count = data.vsend_paid_messages_stars()->v) {
|
||||||
|
_commonStarsPerMessage[channel] = count;
|
||||||
|
} else {
|
||||||
|
_commonStarsPerMessage.remove(channel);
|
||||||
}
|
}
|
||||||
const auto storiesState = minimal
|
const auto storiesState = minimal
|
||||||
? std::optional<Data::Stories::PeerSourceState>()
|
? std::optional<Data::Stories::PeerSourceState>()
|
||||||
|
@ -5137,6 +5141,11 @@ rpl::producer<SentFromScheduled> Session::sentFromScheduled() const {
|
||||||
return _sentFromScheduled.events();
|
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() {
|
void Session::clearLocalStorage() {
|
||||||
_cache->close();
|
_cache->close();
|
||||||
_cache->clear();
|
_cache->clear();
|
||||||
|
|
|
@ -860,6 +860,9 @@ public:
|
||||||
void sentFromScheduled(SentFromScheduled value);
|
void sentFromScheduled(SentFromScheduled value);
|
||||||
[[nodiscard]] rpl::producer<SentFromScheduled> sentFromScheduled() const;
|
[[nodiscard]] rpl::producer<SentFromScheduled> sentFromScheduled() const;
|
||||||
|
|
||||||
|
[[nodiscard]] int commonStarsPerMessage(
|
||||||
|
not_null<ChannelData*> channel) const;
|
||||||
|
|
||||||
void clearLocalStorage();
|
void clearLocalStorage();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -1165,6 +1168,9 @@ private:
|
||||||
not_null<ChannelData*>,
|
not_null<ChannelData*>,
|
||||||
ChannelId>> _postponedMonoforumLinkedIds;
|
ChannelId>> _postponedMonoforumLinkedIds;
|
||||||
|
|
||||||
|
// This one from `channel`, not `channelFull`.
|
||||||
|
base::flat_map<not_null<ChannelData*>, int> _commonStarsPerMessage;
|
||||||
|
|
||||||
MessageIdsList _mimeForwardIds;
|
MessageIdsList _mimeForwardIds;
|
||||||
|
|
||||||
std::weak_ptr<CreditsSubsRebuilder> _creditsSubsRebuilder;
|
std::weak_ptr<CreditsSubsRebuilder> _creditsSubsRebuilder;
|
||||||
|
|
Loading…
Add table
Reference in a new issue