pagination added to inline bots results, preloading thumbs when creating layouts for results

This commit is contained in:
John Preston 2016-01-02 21:09:39 +08:00
parent 63037d6f1a
commit 20b93d969f
2 changed files with 12 additions and 5 deletions

View File

@ -1672,6 +1672,7 @@ void StickerPanInner::inlineRowsAddItem(DocumentData *savedGif, InlineResult *re
}
if (!layout) return;
layout->preload();
if (inlineRowFinalize(row, sumWidth, layout->fullLine())) {
layout->setPosition(_inlineRows.size() * MatrixRowShift);
}
@ -3458,6 +3459,9 @@ void EmojiPan::onScroll() {
if (_stickersShown) {
updatePanelsPositions(s_panels, st);
validateSelectedIcon(true);
if (st + s_scroll.height() > s_scroll.scrollTopMax()) {
onInlineRequest();
}
}
s_inner.setScrollTop(st);
}
@ -3633,9 +3637,9 @@ void EmojiPan::inlineResultsDone(const MTPmessages_BotResults &result) {
if (!adding) {
it = _inlineCache.insert(_inlineQuery, new InlineCacheEntry());
}
it.value()->nextOffset = v.isEmpty() ? QString() : qs(d.vnext_offset);
it.value()->nextOffset = qs(d.vnext_offset);
int32 count = v.size();
int32 count = v.size(), added = 0;
if (count) {
it.value()->results.reserve(it.value()->results.size() + count);
}
@ -3704,14 +3708,19 @@ void EmojiPan::inlineResultsDone(const MTPmessages_BotResults &result) {
if (result->type.isEmpty() || badAttachment || !canSend) {
delete result;
} else {
++added;
it.value()->results.push_back(result);
}
}
if (!added) {
it.value()->nextOffset = QString();
}
} else if (adding) {
it.value()->clearResults();
it.value()->nextOffset = QString();
}
showInlineRows(!adding);
onScroll();
}
bool EmojiPan::inlineResultsFail(const RPCError &error) {

View File

@ -880,7 +880,6 @@ public:
return error();
}
if (ms >= _nextUpdateMs) {
LOG(("Slow frame, keeping up.."));
if (!prepareNextFrame()) {
return error();
}
@ -1075,7 +1074,6 @@ bool ClipReadManager::handleProcessResult(ClipReaderPrivate *reader, ClipProcess
ClipReader::Frame *other = it.key()->frameToWriteNext(false);
t_assert(other != 0);
if (other->when && other->when + WaitBeforeGifPause < qMax(reader->_previousMs, ms)) {
LOG(("Pausing reader.."));
reader->_paused = true;
it.key()->_paused.storeRelease(1);
result = ClipProcessPaused;