diff options
author | Jan Lukas Gernert <jangernert@gmail.com> | 2018-11-26 13:36:17 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-26 13:36:17 +0300 |
commit | d02a805923e7cf56aa83b0c095875165ff1ea8c2 (patch) | |
tree | b4e7b70efa7628ed5275fdbfb58d3c38bae5ffa9 /src | |
parent | 568e49290a58427255d55f7a860eec698ec58ba6 (diff) | |
parent | 736b3b701caded26e0dcb0fcc166b02b6416c852 (diff) |
Merge pull request #786 from 39aldo39/fix-remove-category
When a category is removed, uncategorize feeds/categories explicitly to plugins
Diffstat (limited to 'src')
-rw-r--r-- | src/Backend/Backend.vala | 18 | ||||
-rw-r--r-- | src/DataBaseWriteAccess.vala | 20 |
2 files changed, 18 insertions, 20 deletions
diff --git a/src/Backend/Backend.vala b/src/Backend/Backend.vala index 930e070c..1a0ccddd 100644 --- a/src/Backend/Backend.vala +++ b/src/Backend/Backend.vala @@ -576,6 +576,24 @@ namespace FeedReader { public void removeCategory(string catID) { + var feeds = DataBase.readOnly().read_feeds(); + foreach(Feed feed in feeds) + { + if(feed.hasCat(catID)) + { + moveFeed(feed.getFeedID(), catID); + } + } + + var cats = DataBase.readOnly().read_categories(feeds); + foreach(var cat in cats) + { + if(cat.getParent() == catID) + { + moveCategory(cat.getCatID(), uncategorizedID()); + } + } + asyncPayload pl = () => { FeedServer.get_default().deleteCategory(catID); }; callAsync.begin((owned)pl, (obj, res) => { callAsync.end(res); }); diff --git a/src/DataBaseWriteAccess.vala b/src/DataBaseWriteAccess.vala index 6f92ba06..95f77b63 100644 --- a/src/DataBaseWriteAccess.vala +++ b/src/DataBaseWriteAccess.vala @@ -624,26 +624,6 @@ public class FeedReader.DataBase : DataBaseReadOnly { public void delete_category(string catID) { m_db.execute("DELETE FROM main.categories WHERE categorieID = ?", { catID }); - - if(FeedServer.get_default().supportMultiCategoriesPerFeed()) - { - var rows = m_db.execute("SELECT feed_id, category_id FROM feeds WHERE instr(category_id, ?) > 0", { catID }); - foreach(var row in rows) - { - string feedID = row[0].to_string(); - string catIDs = row[1].to_string().replace(catID + ",", ""); - - m_db.execute("UPDATE main.feeds set category_id = ? WHERE feed_id = ?", { catIDs, feedID }); - } - } - else - { - m_db.execute("UPDATE main.feeds set category_id = ? WHERE category_id = ?", { FeedServer.get_default().uncategorizedID(), catID }); - if(FeedServer.get_default().supportMultiLevelCategories()) - { - m_db.execute("UPDATE main.categories set Parent = \"-2\" WHERE categorieID = ?", { catID }); - } - } } public void rename_category(string catID, string newName) |