Improve supergroup members list reusability.

This commit is contained in:
John Preston 2017-11-28 20:20:05 +04:00
parent 300e55e610
commit ff16897dde
2 changed files with 26 additions and 7 deletions

View File

@ -27,6 +27,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "info/profile/info_profile_values.h"
#include "info/profile/info_profile_button.h"
#include "info/profile/info_profile_members_controllers.h"
#include "info/members/info_members_widget.h"
#include "info/info_content_widget.h"
#include "info/info_controller.h"
#include "info/info_memento.h"
@ -181,9 +182,13 @@ void Members::setupButtons() {
using namespace rpl::mappers;
_openMembers->addClickHandler([this] {
_controller->window()->showSection(Info::Memento(
_controller->peerId(),
Section::Type::Members));
auto contentMemento = std::make_unique<Info::Members::Memento>(
_controller);
contentMemento->setState(saveState());
auto mementoStack = std::vector<std::unique_ptr<ContentMemento>>();
mementoStack.push_back(std::move(contentMemento));
_controller->window()->showSection(
Info::Memento(std::move(mementoStack)));
});
//_searchField->hide();

View File

@ -527,13 +527,27 @@ bool ParticipantsBoxController::feedMegagroupLastParticipants() {
return false;
}
auto info = megagroup->mgInfo.get();
if (info->lastParticipantsStatus != MegagroupInfo::LastParticipantsUpToDate) {
_channel->updateFull();
return false;
}
//
// channelFull and channels_channelParticipants members count is desynced
// so we almost always have LastParticipantsCountOutdated that is set
// inside setMembersCount() and so we almost never use lastParticipants.
//
// => disable this check temporarily.
//
//if (info->lastParticipantsStatus != MegagroupInfo::LastParticipantsUpToDate) {
// _channel->updateFull();
// return false;
//}
if (info->lastParticipants.isEmpty()) {
return false;
}
if ((info->lastParticipants.size() < Global::ChatSizeMax() / 2)
&& (_channel->membersCount() > Global::ChatSizeMax())) {
// If we have really small non-empty count of last participants.
// Request them from the beginning so that we won't do that each
// time we open megagroup profile.
Auth().api().requestLastParticipants(_channel);
}
if (info->creator) {
_additional.creator = info->creator;