Add members from info to mgInfo->lastParticipants.

This commit is contained in:
John Preston 2017-11-22 13:56:00 +04:00
parent f6ba59ed14
commit 5803edb77b
4 changed files with 47 additions and 8 deletions

View file

@ -1776,6 +1776,28 @@ void ApiWrap::parseChannelParticipants(
}));
};
void ApiWrap::parseRecentChannelParticipants(
not_null<ChannelData*> channel,
const MTPchannels_ChannelParticipants &result,
base::lambda<void(int fullCount, const QVector<MTPChannelParticipant> &list)> callbackList,
base::lambda<void()> callbackNotModified) {
parseChannelParticipants(result, [&](
int fullCount,
const QVector<MTPChannelParticipant> &list) {
auto applyLast = channel->isMegagroup()
&& (channel->mgInfo->lastParticipants.size() <= list.size());
if (applyLast) {
applyLastParticipantsList(
channel,
fullCount,
list,
false,
true);
}
callbackList(fullCount, list);
}, std::move(callbackNotModified));
}
void ApiWrap::applyUpdatesNoPtsCheck(const MTPUpdates &updates) {
switch (updates.type()) {
case mtpc_updateShortMessage: {

View file

@ -147,6 +147,11 @@ public:
const MTPchannels_ChannelParticipants &result,
base::lambda<void(int fullCount, const QVector<MTPChannelParticipant> &list)> callbackList,
base::lambda<void()> callbackNotModified = nullptr);
void parseRecentChannelParticipants(
not_null<ChannelData*> channel,
const MTPchannels_ChannelParticipants &result,
base::lambda<void(int fullCount, const QVector<MTPChannelParticipant> &list)> callbackList,
base::lambda<void()> callbackNotModified = nullptr);
~ApiWrap();

View file

@ -133,16 +133,14 @@ int LayerWidget::resizeGetHeight(int newWidth) {
auto parentSize = parentWidget()->size();
auto windowWidth = parentSize.width();
auto windowHeight = parentSize.height();
auto newHeight = st::boxRadius + _desiredHeight + st::boxRadius;
if (newHeight > windowHeight || newWidth >= windowWidth) {
newHeight = windowHeight;
}
auto layerTop = snap(
auto newTop = snap(
windowHeight / 24,
st::infoLayerTopMinimal,
st::infoLayerTopMaximal);
auto newHeight = st::boxRadius + _desiredHeight + st::boxRadius;
accumulate_min(newHeight, windowHeight - newTop);
setRoundedCorners(layerTop + newHeight < windowHeight);
setRoundedCorners(newTop + newHeight < windowHeight);
// First resize content to new width and get the new desired height.
auto contentTop = st::boxRadius;
@ -152,7 +150,7 @@ int LayerWidget::resizeGetHeight(int newWidth) {
}
_content->setGeometry(0, contentTop, newWidth, contentHeight);
moveToLeft((windowWidth - newWidth) / 2, layerTop);
moveToLeft((windowWidth - newWidth) / 2, newTop);
return newHeight;
}

View file

@ -465,7 +465,21 @@ void ParticipantsBoxController::loadMoreRows() {
auto firstLoad = !_offset;
_loadRequestId = 0;
Auth().api().parseChannelParticipants(result, [&](
auto wasRecentRequest = firstLoad
&& (_role == Role::Members || _role == Role::Profile);
auto parseParticipants = [&](auto &&result, auto &&callback) {
if (wasRecentRequest) {
Auth().api().parseRecentChannelParticipants(
_channel,
result,
callback);
} else {
Auth().api().parseChannelParticipants(
result,
callback);
}
};
parseParticipants(result, [&](
int fullCount,
const QVector<MTPChannelParticipant> &list) {
for (auto &participant : list) {