From f322ea8e731ca83363acb26088d2eff7a838af35 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Thu, 11 Jun 2020 14:33:12 +0200 Subject: [PATCH] We need to greatly simplify service API to allow for some extra features and preferably make service-specific code smaller, easily manageable + fixed crash when doins "sync-in" in TT-RSS. --- .../services/abstract/serviceroot.cpp | 28 ++++--------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/src/librssguard/services/abstract/serviceroot.cpp b/src/librssguard/services/abstract/serviceroot.cpp index 57611aedf..03dc658b4 100644 --- a/src/librssguard/services/abstract/serviceroot.cpp +++ b/src/librssguard/services/abstract/serviceroot.cpp @@ -139,7 +139,7 @@ void ServiceRoot::removeOldFeedTree(bool including_messages) { void ServiceRoot::cleanAllItems() { for (RootItem* top_level_item : childItems()) { - if (top_level_item->kind() != RootItemKind::Bin) { + if (top_level_item->kind() != RootItemKind::Bin && top_level_item->kind() != RootItemKind::Important) { requestItemRemoval(top_level_item); } } @@ -298,12 +298,11 @@ void ServiceRoot::syncIn() { RootItem* new_tree = obtainNewTreeForSyncIn(); if (new_tree != nullptr) { - // Purge old data from SQL and clean all model items. - requestItemExpandStateSave(this); QMap feed_custom_data = storeCustomFeedsData(); - removeOldFeedTree(false); + // Remove from feeds model, then from SQL but leave messages intact. cleanAllItems(); + removeOldFeedTree(false); restoreCustomFeedsData(feed_custom_data, new_tree->getHashedSubTreeFeeds()); // Model is clean, now store new tree into DB and @@ -319,32 +318,15 @@ void ServiceRoot::syncIn() { requestItemReassignment(top_level_item, this); } - updateCounts(true); new_tree->clearChildren(); new_tree->deleteLater(); - QList all_items = getSubTree(); - itemChanged(all_items); + updateCounts(true); requestReloadMessageList(true); - - // Now we must refresh expand states. - QList items_to_expand; - - for (RootItem* item : all_items) { - if (qApp->settings()->value(GROUP(CategoriesExpandStates), item->hashCode(), item->childCount() > 0).toBool()) { - items_to_expand.append(item); - } - } - - if (!items_to_expand.contains(this)) { - items_to_expand.prepend(this); - } - - requestItemExpand(items_to_expand, true); } setIcon(original_icon); - itemChanged(QList() << this); + itemChanged(getSubTree()); } RootItem* ServiceRoot::obtainNewTreeForSyncIn() const {