Overview filling fix when you scroll the history down till the bottom.

This commit is contained in:
John Preston 2016-08-14 22:15:45 +03:00
parent 4cd7a7a695
commit 79eafbe71a
2 changed files with 30 additions and 18 deletions

View File

@ -1345,24 +1345,8 @@ void History::addNewerSlice(const QVector<MTPMessage> &slice) {
}
}
if (!wasLoadedAtBottom && loadedAtBottom()) { // add all loaded photos to overview
int32 mask = 0;
for (int32 i = 0; i < OverviewCount; ++i) {
if (overviewCountData[i] == 0) continue; // all loaded
if (!overview[i].isEmpty() || !overviewIds[i].isEmpty()) {
overview[i].clear();
overviewIds[i].clear();
mask |= (1 << i);
}
}
for_const (HistoryBlock *block, blocks) {
for_const (HistoryItem *item, block->items) {
mask |= item->addToOverview(AddToOverviewBack);
}
}
for (int32 t = 0; t < OverviewCount; ++t) {
if ((mask & (1 << t)) && App::wnd()) App::wnd()->mediaOverviewUpdated(peer, MediaOverviewType(t));
}
if (!wasLoadedAtBottom) {
checkAddAllToOverview();
}
if (isChannel()) asChannelHistory()->checkJoinedMessage();
@ -1373,12 +1357,37 @@ void History::checkLastMsg() {
if (lastMsg) {
if (!newLoaded && !lastMsg->detached()) {
newLoaded = true;
checkAddAllToOverview();
}
} else if (newLoaded) {
setLastMessage(lastImportantMessage());
}
}
void History::checkAddAllToOverview() {
if (!loadedAtBottom()) {
return;
}
int32 mask = 0;
for (int32 i = 0; i < OverviewCount; ++i) {
if (overviewCountData[i] == 0) continue; // all loaded
if (!overview[i].isEmpty() || !overviewIds[i].isEmpty()) {
overview[i].clear();
overviewIds[i].clear();
mask |= (1 << i);
}
}
for_const (HistoryBlock *block, blocks) {
for_const (HistoryItem *item, block->items) {
mask |= item->addToOverview(AddToOverviewBack);
}
}
for (int32 t = 0; t < OverviewCount; ++t) {
if ((mask & (1 << t)) && App::wnd()) App::wnd()->mediaOverviewUpdated(peer, MediaOverviewType(t));
}
}
int History::countUnread(MsgId upTo) {
int result = 0;
for (auto i = blocks.cend(), e = blocks.cbegin(); i != e;) {

View File

@ -494,6 +494,9 @@ private:
// After adding a new history slice check the lastMsg and newLoaded.
void checkLastMsg();
// Add all items to the media overview if we were not loaded at bottom and now are.
void checkAddAllToOverview();
enum class Flag {
f_has_pending_resized_items = (1 << 0),
f_pending_resize = (1 << 1),