Fix saving chat admins.

Regression was introduced in 0880c01a20.
This commit is contained in:
John Preston 2017-09-04 15:20:10 +03:00
parent 5b77bd5aa0
commit 52195ff95a
2 changed files with 11 additions and 15 deletions

View File

@ -336,14 +336,12 @@ bool PeerListBox::peerListIsRowSelected(not_null<PeerData*> peer) {
} }
int PeerListBox::peerListSelectedRowsCount() { int PeerListBox::peerListSelectedRowsCount() {
Expects(_select != nullptr); return _select ? _select->entity()->getItemsCount() : 0;
return _select->entity()->getItemsCount();
} }
std::vector<not_null<PeerData*>> PeerListBox::peerListCollectSelectedRows() { std::vector<not_null<PeerData*>> PeerListBox::peerListCollectSelectedRows() {
Expects(_select != nullptr); auto result = std::vector<not_null<PeerData*>> {};
auto result = std::vector<not_null<PeerData*>>(); auto items = _select ? _select->entity()->getItems() : QVector<uint64> {};
auto items = _select->entity()->getItems();
if (!items.empty()) { if (!items.empty()) {
result.reserve(items.size()); result.reserve(items.size());
for_const (auto itemId, items) { for_const (auto itemId, items) {

View File

@ -672,17 +672,15 @@ void EditChatAdminsBoxController::Start(not_null<ChatData*> chat) {
auto initBox = [chat, controller = controller.get()](not_null<PeerListBox*> box) { auto initBox = [chat, controller = controller.get()](not_null<PeerListBox*> box) {
box->addButton(langFactory(lng_settings_save), [box, chat, controller] { box->addButton(langFactory(lng_settings_save), [box, chat, controller] {
auto rows = box->peerListCollectSelectedRows(); auto rows = box->peerListCollectSelectedRows();
if (!rows.empty()) { auto users = std::vector<not_null<UserData*>>();
auto users = std::vector<not_null<UserData*>>(); for (auto peer : rows) {
for (auto peer : rows) { auto user = peer->asUser();
auto user = peer->asUser(); Assert(user != nullptr);
Assert(user != nullptr); Assert(!user->isSelf());
Assert(!user->isSelf()); users.push_back(peer->asUser());
users.push_back(peer->asUser());
}
Auth().api().editChatAdmins(chat, !controller->allAreAdmins(), { users.cbegin(), users.cend() });
box->closeBox();
} }
Auth().api().editChatAdmins(chat, !controller->allAreAdmins(), { users.cbegin(), users.cend() });
box->closeBox();
}); });
box->addButton(langFactory(lng_cancel), [box] { box->closeBox(); }); box->addButton(langFactory(lng_cancel), [box] { box->closeBox(); });
}; };