X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fcorebacklogmanager.cpp;h=9ef4b8990e2279fbe46b8c29c38e7e62dda710ef;hp=d9f3d9088c03d064a45f51db546f4d7d51dd1eb8;hb=23c207ca5991b8c913114eb216debaddeb0de6e1;hpb=f824db0e31b54969e0b7fa0b5405b1e9173d482c diff --git a/src/core/corebacklogmanager.cpp b/src/core/corebacklogmanager.cpp index d9f3d908..9ef4b899 100644 --- a/src/core/corebacklogmanager.cpp +++ b/src/core/corebacklogmanager.cpp @@ -24,6 +24,7 @@ #include +INIT_SYNCABLE_OBJECT(CoreBacklogManager) CoreBacklogManager::CoreBacklogManager(CoreSession *coreSession) : BacklogManager(coreSession), _coreSession(coreSession) @@ -42,24 +43,31 @@ QVariantList CoreBacklogManager::requestBacklog(BufferId bufferId, MsgId first, msgIter++; } - if(additional) { + if(additional && limit != 0) { + MsgId oldestMessage = first; + if(!msgList.isEmpty()) { + if(msgList.first().msgId() < msgList.last().msgId()) + oldestMessage = msgList.first().msgId(); + else + oldestMessage = msgList.last().msgId(); + } + if(first != -1) { last = first; } else { - last = -1; - if(!msgList.isEmpty()) { - if(msgList.first().msgId() < msgList.last().msgId()) - last = msgList.first().msgId(); - else - last = msgList.last().msgId(); - } + last = oldestMessage; } - msgList = Core::requestMsgs(coreSession()->user(), bufferId, -1, last, additional); - msgIter = msgList.constBegin(); - msgListEnd = msgList.constEnd(); - while(msgIter != msgListEnd) { - backlog << qVariantFromValue(*msgIter); - msgIter++; + + // only fetch additional messages if they continue seemlessly + // that is, if the list of messages is not truncated by the limit + if(last == oldestMessage) { + msgList = Core::requestMsgs(coreSession()->user(), bufferId, -1, last, additional); + msgIter = msgList.constBegin(); + msgListEnd = msgList.constEnd(); + while(msgIter != msgListEnd) { + backlog << qVariantFromValue(*msgIter); + msgIter++; + } } } @@ -67,7 +75,6 @@ QVariantList CoreBacklogManager::requestBacklog(BufferId bufferId, MsgId first, } QVariantList CoreBacklogManager::requestBacklogAll(MsgId first, MsgId last, int limit, int additional) { - qDebug() << "CoreBacklogManager::requestBacklogAll" << first << last << limit << additional; QVariantList backlog; QList msgList; msgList = Core::requestAllMsgs(coreSession()->user(), first, last, limit);