2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Support slowmode restrictions in Replies section.

This commit is contained in:
John Preston
2020-09-30 14:06:08 +03:00
parent 719bed6e85
commit 94c2969f8b
11 changed files with 174 additions and 27 deletions

View File

@@ -836,6 +836,31 @@ bool PeerData::slowmodeApplied() const {
return false;
}
rpl::producer<bool> PeerData::slowmodeAppliedValue() const {
using namespace rpl::mappers;
const auto channel = asChannel();
if (!channel) {
return rpl::single(false);
}
auto hasAdminRights = channel->adminRightsValue(
) | rpl::map([=] {
return channel->hasAdminRights();
}) | rpl::distinct_until_changed();
auto slowmodeEnabled = channel->flagsValue(
) | rpl::filter([=](const ChannelData::Flags::Change &change) {
return (change.diff & MTPDchannel::Flag::f_slowmode_enabled) != 0;
}) | rpl::map([=](const ChannelData::Flags::Change &change) {
return (change.value & MTPDchannel::Flag::f_slowmode_enabled) != 0;
}) | rpl::distinct_until_changed();
return rpl::combine(
std::move(hasAdminRights),
std::move(slowmodeEnabled),
!_1 && _2);
}
int PeerData::slowmodeSecondsLeft() const {
if (const auto channel = asChannel()) {
if (const auto seconds = channel->slowmodeSeconds()) {