2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Begin of EditPeerBox redesigning.

- Moved buttons from ManageGroupBox to EditPeerBox.
 - Added counting of permissions.
This commit is contained in:
23rd
2019-03-15 11:20:12 +03:00
committed by John Preston
parent 3a5bad4b7a
commit 0f3ec47074
9 changed files with 442 additions and 16 deletions

View File

@@ -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(