fix red color not showing for errorneous feeds
This commit is contained in:
parent
4d1c9810cd
commit
86a53e011b
2 changed files with 30 additions and 30 deletions
|
@ -212,47 +212,47 @@ bool Feed::markAsReadUnread(RootItem::ReadStatus status) {
|
||||||
int Feed::updateMessages(const QList<Message>& messages, bool error_during_obtaining) {
|
int Feed::updateMessages(const QList<Message>& messages, bool error_during_obtaining) {
|
||||||
QList<RootItem*> items_to_update;
|
QList<RootItem*> items_to_update;
|
||||||
int updated_messages = 0;
|
int updated_messages = 0;
|
||||||
bool is_main_thread = QThread::currentThread() == qApp->thread();
|
|
||||||
|
|
||||||
qDebug("Updating messages in DB. Main thread: '%s'.", qPrintable(is_main_thread ? "true" : "false"));
|
if (!error_during_obtaining) {
|
||||||
|
bool is_main_thread = QThread::currentThread() == qApp->thread();
|
||||||
|
|
||||||
bool anything_updated = false;
|
qDebug("Updating messages in DB. Main thread: '%s'.", qPrintable(is_main_thread ? "true" : "false"));
|
||||||
bool ok = true;
|
|
||||||
|
|
||||||
if (!messages.isEmpty()) {
|
bool anything_updated = false;
|
||||||
qDebug("There are some messages to be updated/added to DB.");
|
bool ok = true;
|
||||||
|
|
||||||
QString custom_id = customId();
|
if (!messages.isEmpty()) {
|
||||||
int account_id = getParentServiceRoot()->accountId();
|
qDebug("There are some messages to be updated/added to DB.");
|
||||||
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);
|
QString custom_id = customId();
|
||||||
}
|
int account_id = getParentServiceRoot()->accountId();
|
||||||
else {
|
QSqlDatabase database = is_main_thread ?
|
||||||
qWarning("There are no messages for update.");
|
qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings) :
|
||||||
}
|
qApp->database()->connection(QSL("feed_upd"), DatabaseFactory::FromSettings);
|
||||||
|
|
||||||
if (ok) {
|
updated_messages = DatabaseQueries::updateMessages(database, messages, custom_id, account_id, url(), &anything_updated, &ok);
|
||||||
setStatus(updated_messages > 0 ? NewMessages : Normal);
|
}
|
||||||
updateCounts(true);
|
else {
|
||||||
|
qWarning("There are no messages for update.");
|
||||||
|
}
|
||||||
|
|
||||||
if (getParentServiceRoot()->recycleBin() != nullptr && anything_updated) {
|
if (ok) {
|
||||||
getParentServiceRoot()->recycleBin()->updateCounts(true);
|
setStatus(updated_messages > 0 ? NewMessages : Normal);
|
||||||
items_to_update.append(getParentServiceRoot()->recycleBin());
|
updateCounts(true);
|
||||||
|
|
||||||
|
if (getParentServiceRoot()->recycleBin() != nullptr && anything_updated) {
|
||||||
|
getParentServiceRoot()->recycleBin()->updateCounts(true);
|
||||||
|
items_to_update.append(getParentServiceRoot()->recycleBin());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
if (error_during_obtaining) {
|
|
||||||
qCritical("There is indication that there was error during messages obtaining.");
|
qCritical("There is indication that there was error during messages obtaining.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ok && !messages.isEmpty()) {
|
// Some messages were really added to DB, reload feed in model.
|
||||||
// Some messages were really added to DB, reload feed in model.
|
items_to_update.append(this);
|
||||||
items_to_update.append(this);
|
getParentServiceRoot()->itemChanged(items_to_update);
|
||||||
getParentServiceRoot()->itemChanged(items_to_update);
|
|
||||||
}
|
|
||||||
|
|
||||||
return updated_messages;
|
return updated_messages;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ QList<QAction*> StandardFeed::contextMenu() {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString StandardFeed::additionalTooltip() const {
|
QString StandardFeed::additionalTooltip() const {
|
||||||
return Feed::additionalTooltip() + tr("Network status: %1\n"
|
return Feed::additionalTooltip() + tr("\nNetwork status: %1\n"
|
||||||
"Encoding: %2\n"
|
"Encoding: %2\n"
|
||||||
"Type: %3").arg(NetworkFactory::networkErrorText(m_networkError),
|
"Type: %3").arg(NetworkFactory::networkErrorText(m_networkError),
|
||||||
encoding(),
|
encoding(),
|
||||||
|
|
Loading…
Add table
Reference in a new issue