X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcore%2Fcorebacklogmanager.cpp;h=39feb2ab66a65b66d09f964c358867c2efc09038;hb=dee6c478632feeae5c845be82251117556ff1511;hp=5e3724f3cd984c72ed2c5fcd9968f0900910a549;hpb=335e1e55ee8df69b37b1b4d839950ced9ac08cc4;p=quassel.git diff --git a/src/core/corebacklogmanager.cpp b/src/core/corebacklogmanager.cpp index 5e3724f3..39feb2ab 100644 --- a/src/core/corebacklogmanager.cpp +++ b/src/core/corebacklogmanager.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel IRC Team * + * Copyright (C) 2005-09 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -43,23 +43,30 @@ QVariantList CoreBacklogManager::requestBacklog(BufferId bufferId, MsgId first, } if(additional) { + MsgId oldestMessage; + 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 they continue seemlessly + // that is, if the list of messages is not truncated by the limit + if(last.isValid() && last == oldestMessage) { + msgList = Core::requestMsgs(coreSession()->user(), bufferId, -1, last, additional); + msgIter = msgList.constBegin(); + msgListEnd = msgList.constEnd(); + while(msgIter != msgListEnd) { + backlog << qVariantFromValue(*msgIter); + msgIter++; + } } }