Change msg update logic a bit.

This commit is contained in:
Martin Rotter 2017-10-26 20:33:48 +02:00
parent d9757f2814
commit d24f249788
1 changed files with 17 additions and 19 deletions

View File

@ -215,30 +215,28 @@ int Feed::updateMessages(const QList<Message>& messages, bool error_during_obtai
qDebug("Updating messages in DB. Main thread: '%s'.", qPrintable(is_main_thread ? "true" : "false")); qDebug("Updating messages in DB. Main thread: '%s'.", qPrintable(is_main_thread ? "true" : "false"));
bool anything_updated = false;
bool ok = true;
if (!messages.isEmpty()) { if (!messages.isEmpty()) {
bool anything_updated = false; qDebug("There are some messages to be updated/added to DB.");
bool ok = true;
if (!messages.isEmpty()) { QString custom_id = customId();
qDebug("There are some messages to be updated in DB."); int account_id = getParentServiceRoot()->accountId();
QSqlDatabase database = is_main_thread ?
qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings) :
qApp->database()->connection(QSL("feed_upd"), DatabaseFactory::FromSettings);
QString custom_id = customId(); updated_messages = DatabaseQueries::updateMessages(database, messages, custom_id, account_id, url(), &anything_updated, &ok);
int account_id = getParentServiceRoot()->accountId(); }
QSqlDatabase database = is_main_thread ?
qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings) :
qApp->database()->connection(QSL("feed_upd"), DatabaseFactory::FromSettings);
updated_messages = DatabaseQueries::updateMessages(database, messages, custom_id, account_id, url(), &anything_updated, &ok); if (ok) {
} setStatus(updated_messages > 0 ? NewMessages : Normal);
updateCounts(true);
if (ok) { if (getParentServiceRoot()->recycleBin() != nullptr && anything_updated) {
setStatus(updated_messages > 0 ? NewMessages : Normal); getParentServiceRoot()->recycleBin()->updateCounts(true);
updateCounts(true); items_to_update.append(getParentServiceRoot()->recycleBin());
if (getParentServiceRoot()->recycleBin() != nullptr && anything_updated) {
getParentServiceRoot()->recycleBin()->updateCounts(true);
items_to_update.append(getParentServiceRoot()->recycleBin());
}
} }
} }