Commit 7bd76322 authored by Michał Ziąbkowski's avatar Michał Ziąbkowski Committed by Rafał Malinowski

sql_history: query last messages from history in descending order and reverse...

sql_history: query last messages from history in descending order and reverse them afterwards. Fixes regression from b67955a5.
parent 491c58dc
......@@ -865,11 +865,11 @@ SortedMessages HistorySqlStorage::syncMessages(const HistoryQuery &historyQuery)
// it is reverted back manually below
if (historyQuery.limit() > 0)
{
queryString += " ORDER BY date DESC, kadu_messages.rowid ASC";
queryString += " ORDER BY date DESC, kadu_messages.rowid DESC";
queryString += " LIMIT :limit";
}
else
queryString += " ORDER BY date ASC, kadu_messages.rowid ASC";
queryString += " ORDER BY date ASC, kadu_messages.rowid DESC";
query.prepare(queryString);
......@@ -1045,6 +1045,9 @@ SortedMessages HistorySqlStorage::messagesFromQuery(QSqlQuery &query)
messages.push_back(message);
}
// the data was queried in descending order, so we need to reverse it
std::reverse(messages.begin(), messages.end());
return SortedMessages{messages};
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment