mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 06:26:18 +00:00
Begin of EditPeerBox redesigning.
- Moved buttons from ManageGroupBox to EditPeerBox. - Added counting of permissions.
This commit is contained in:
@@ -23,6 +23,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "data/data_user.h"
|
||||
#include "data/data_session.h"
|
||||
|
||||
#include "boxes/peers/edit_peer_permissions_box.h"
|
||||
|
||||
namespace Info {
|
||||
namespace Profile {
|
||||
|
||||
@@ -215,6 +217,35 @@ rpl::producer<int> AdminsCountValue(not_null<PeerData*> peer) {
|
||||
Unexpected("User in AdminsCountValue().");
|
||||
}
|
||||
|
||||
|
||||
rpl::producer<int> RestrictionsCountValue(not_null<PeerData*> peer) {
|
||||
const auto countOfRestrictions = [](ChatRestrictions restrictions) {
|
||||
auto count = 0;
|
||||
for (const auto f : Data::ListOfRestrictions()) {
|
||||
if (restrictions & f) count++;
|
||||
}
|
||||
return int(Data::ListOfRestrictions().size()) - count;
|
||||
};
|
||||
|
||||
using Flag = Notify::PeerUpdate::Flag;
|
||||
if (const auto chat = peer->asChat()) {
|
||||
return Notify::PeerUpdateValue(
|
||||
chat,
|
||||
Flag::RightsChanged
|
||||
) | rpl::map([=] {
|
||||
return countOfRestrictions(chat->defaultRestrictions());
|
||||
});
|
||||
} else if (const auto channel = peer->asChannel()) {
|
||||
return Notify::PeerUpdateValue(
|
||||
channel,
|
||||
Flag::RightsChanged
|
||||
) | rpl::map([=] {
|
||||
return countOfRestrictions(channel->defaultRestrictions());
|
||||
});
|
||||
}
|
||||
Unexpected("User in RestrictionsCountValue().");
|
||||
}
|
||||
|
||||
rpl::producer<int> RestrictedCountValue(not_null<ChannelData*> channel) {
|
||||
using Flag = Notify::PeerUpdate::Flag;
|
||||
return Notify::PeerUpdateValue(
|
||||
|
Reference in New Issue
Block a user