Fixed bug with left over messages.

This commit is contained in:
Martin Rotter 2016-01-18 19:08:00 +01:00
parent 55dadfe238
commit 04d2b1392d
3 changed files with 20 additions and 0 deletions

View File

@ -17,6 +17,7 @@ Changed:
Fixed: Fixed:
▪ Left over messages are now correctly deleted after sync-in is performed in TT-RSS account.
▪ Made some rather big changes to sorting/filtering of feeds, which is now dynamic. ▪ Made some rather big changes to sorting/filtering of feeds, which is now dynamic.
▪ Feeds are now (re)sorted when batch update finishes. (bug #150) ▪ Feeds are now (re)sorted when batch update finishes. (bug #150)
▪ Expand status if items in feed list are now persistent when performing sync-in of TT-RSS accounts. (bug #149) ▪ Expand status if items in feed list are now persistent when performing sync-in of TT-RSS accounts. (bug #149)

View File

@ -587,6 +587,10 @@ void TtRssServiceRoot::syncIn() {
// set primary IDs of the items. // set primary IDs of the items.
storeNewFeedTree(new_tree); storeNewFeedTree(new_tree);
// We have new feed, some feeds were maybe removed,
// so remove left over messages.
removeLeftOverMessages();
foreach (RootItem *top_level_item, new_tree->childItems()) { foreach (RootItem *top_level_item, new_tree->childItems()) {
top_level_item->setParent(NULL); top_level_item->setParent(NULL);
requestItemReassignment(top_level_item, this); requestItemReassignment(top_level_item, this);
@ -669,6 +673,20 @@ void TtRssServiceRoot::removeOldFeedTree(bool including_messages) {
} }
} }
void TtRssServiceRoot::removeLeftOverMessages() {
QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
QSqlQuery query(database);
int account_id = accountId();
query.setForwardOnly(true);
query.prepare(QSL("DELETE FROM Messages WHERE account_id = :account_id AND feed NOT IN (SELECT custom_id FROM Feeds WHERE account_id = :account_id);"));
query.bindValue(QSL(":account_id"), account_id);
if (!query.exec()) {
qWarning("Removing of left over messages failed: '%s'.", qPrintable(query.lastError().text()));
}
}
void TtRssServiceRoot::cleanAllItems() { void TtRssServiceRoot::cleanAllItems() {
foreach (RootItem *top_level_item, childItems()) { foreach (RootItem *top_level_item, childItems()) {
if (top_level_item->kind() != RootItemKind::Bin) { if (top_level_item->kind() != RootItemKind::Bin) {

View File

@ -99,6 +99,7 @@ class TtRssServiceRoot : public ServiceRoot {
QStringList textualFeedIds(const QList<Feed*> &feeds); QStringList textualFeedIds(const QList<Feed*> &feeds);
void removeOldFeedTree(bool including_messages); void removeOldFeedTree(bool including_messages);
void removeLeftOverMessages();
void cleanAllItems(); void cleanAllItems();
void storeNewFeedTree(RootItem *root); void storeNewFeedTree(RootItem *root);
void loadFromDatabase(); void loadFromDatabase();