mirror of https://github.com/procxx/kepka.git
parent
5b77bd5aa0
commit
52195ff95a
|
@ -336,14 +336,12 @@ bool PeerListBox::peerListIsRowSelected(not_null<PeerData*> peer) {
|
|||
}
|
||||
|
||||
int PeerListBox::peerListSelectedRowsCount() {
|
||||
Expects(_select != nullptr);
|
||||
return _select->entity()->getItemsCount();
|
||||
return _select ? _select->entity()->getItemsCount() : 0;
|
||||
}
|
||||
|
||||
std::vector<not_null<PeerData*>> PeerListBox::peerListCollectSelectedRows() {
|
||||
Expects(_select != nullptr);
|
||||
auto result = std::vector<not_null<PeerData*>>();
|
||||
auto items = _select->entity()->getItems();
|
||||
auto result = std::vector<not_null<PeerData*>> {};
|
||||
auto items = _select ? _select->entity()->getItems() : QVector<uint64> {};
|
||||
if (!items.empty()) {
|
||||
result.reserve(items.size());
|
||||
for_const (auto itemId, items) {
|
||||
|
|
|
@ -672,17 +672,15 @@ void EditChatAdminsBoxController::Start(not_null<ChatData*> chat) {
|
|||
auto initBox = [chat, controller = controller.get()](not_null<PeerListBox*> box) {
|
||||
box->addButton(langFactory(lng_settings_save), [box, chat, controller] {
|
||||
auto rows = box->peerListCollectSelectedRows();
|
||||
if (!rows.empty()) {
|
||||
auto users = std::vector<not_null<UserData*>>();
|
||||
for (auto peer : rows) {
|
||||
auto user = peer->asUser();
|
||||
Assert(user != nullptr);
|
||||
Assert(!user->isSelf());
|
||||
users.push_back(peer->asUser());
|
||||
}
|
||||
Auth().api().editChatAdmins(chat, !controller->allAreAdmins(), { users.cbegin(), users.cend() });
|
||||
box->closeBox();
|
||||
auto users = std::vector<not_null<UserData*>>();
|
||||
for (auto peer : rows) {
|
||||
auto user = peer->asUser();
|
||||
Assert(user != nullptr);
|
||||
Assert(!user->isSelf());
|
||||
users.push_back(peer->asUser());
|
||||
}
|
||||
Auth().api().editChatAdmins(chat, !controller->allAreAdmins(), { users.cbegin(), users.cend() });
|
||||
box->closeBox();
|
||||
});
|
||||
box->addButton(langFactory(lng_cancel), [box] { box->closeBox(); });
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue