Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #786 from 39aldo39/fix-remove-category
Browse files Browse the repository at this point in the history
When a category is removed, uncategorize feeds/categories explicitly to plugins
  • Loading branch information
jangernert authored Nov 26, 2018
2 parents 568e492 + 736b3b7 commit d02a805
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
18 changes: 18 additions & 0 deletions src/Backend/Backend.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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); });

Expand Down
20 changes: 0 additions & 20 deletions src/DataBaseWriteAccess.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d02a805

Please sign in to comment.