1
0
Fork 0
mirror of https://codeberg.org/Reuh/feather.git synced 2025-10-27 18:19:32 +00:00

fix: properly keep category order

This commit is contained in:
Étienne Fildadut 2025-10-10 16:57:34 +02:00
parent b100d8f0b8
commit 2557db7502
2 changed files with 12 additions and 6 deletions

View file

@ -235,20 +235,21 @@ class TRRSession(ClientSession):
self.feeds = {}
def get_categories_recursive(parent_category, parent_categories=[]):
categories = []
for i in range(len(parent_category["items"])):
item = parent_category["items"][i]
index = 0
for item in parent_category["items"]:
# skip special categories and feeds
if item["bare_id"] <= 0:
continue
# category
elif item.get("type") == "category":
category = Category(id=item["bare_id"], parents=parent_categories, title=item["name"], order=i)
category = Category(id=item["bare_id"], parents=parent_categories, title=item["name"], order=index)
categories.append(category)
categories += get_categories_recursive(item, parent_categories+[category])
# feeds
elif "type" not in item:
self.feeds[item["bare_id"]] = item
self.feeds[item["bare_id"]]["order"] = i
self.feeds[item["bare_id"]]["order"] = index
index += 1
return categories
tree = self.ttrss.get_feed_tree()
return get_categories_recursive(tree["categories"])