don't rely on implicit typecast when using postgres
[quassel.git] / src / core / corebacklogmanager.cpp
index 39feb2a..9ef4b89 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <QDebug>
 
+INIT_SYNCABLE_OBJECT(CoreBacklogManager)
 CoreBacklogManager::CoreBacklogManager(CoreSession *coreSession)
   : BacklogManager(coreSession),
     _coreSession(coreSession)
@@ -42,8 +43,8 @@ QVariantList CoreBacklogManager::requestBacklog(BufferId bufferId, MsgId first,
     msgIter++;
   }
 
-  if(additional) {
-    MsgId oldestMessage;
+  if(additional && limit != 0) {
+    MsgId oldestMessage = first;
     if(!msgList.isEmpty()) {
       if(msgList.first().msgId() < msgList.last().msgId())
         oldestMessage = msgList.first().msgId();
@@ -57,9 +58,9 @@ QVariantList CoreBacklogManager::requestBacklog(BufferId bufferId, MsgId first,
       last = oldestMessage;
     }
 
-    // only fetch additional messages if they they continue seemlessly
+    // only fetch additional messages if they continue seemlessly
     // that is, if the list of messages is not truncated by the limit
-    if(last.isValid() && last == oldestMessage) {
+    if(last == oldestMessage) {
       msgList = Core::requestMsgs(coreSession()->user(), bufferId, -1, last, additional);
       msgIter = msgList.constBegin();
       msgListEnd = msgList.constEnd();
@@ -74,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<Message> msgList;
   msgList = Core::requestAllMsgs(coreSession()->user(), first, last, limit);