From 972d6e84417c4d3d68d3d069e9528a7a995575df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Reuh=20Fildadut?= Date: Sat, 11 Oct 2025 21:51:34 +0200 Subject: [PATCH] feat: update local state on read/unread without waiting for next sync --- src/feather/feather.py | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/feather/feather.py b/src/feather/feather.py index 1c393d4..aa299ed 100755 --- a/src/feather/feather.py +++ b/src/feather/feather.py @@ -65,27 +65,42 @@ class FeatherApp: ) return + # gather articles to mark as read/unread marked_as_read, marked_as_unread = 0, 0 to_mark_as_read = [] to_mark_as_unread = [] for article in self.iter_articles(): if not article.has_html(): if article.unread: - to_mark_as_read.append(article.id) + to_mark_as_read.append(article) marked_as_read += 1 else: - to_mark_as_unread.append(article.id) + to_mark_as_unread.append(article) marked_as_unread += 1 - for i in range(0, len(to_mark_as_read), config.articles_per_query): + # change read state on server + to_mark_as_read_id = [article.id for article in to_mark_as_read] + for i in range(0, len(to_mark_as_read_id), config.articles_per_query): client_session.set_read_flag( - to_mark_as_read[i : i + config.articles_per_query], True + to_mark_as_read_id[i : i + config.articles_per_query], True ) - for i in range(0, len(to_mark_as_unread), config.articles_per_query): + to_mark_as_unread_id = [article.id for article in to_mark_as_unread] + for i in range(0, len(to_mark_as_unread_id), config.articles_per_query): client_session.set_read_flag( - to_mark_as_unread[i : i + config.articles_per_query], False + to_mark_as_unread_id[i : i + config.articles_per_query], False ) + # regenerate/delete local file with new read/unread state + for article in to_mark_as_read: + article.unread = False + if config.only_sync_unread_articles: + article.delete() + else: + article.regenerate() + for article in to_mark_as_unread: + article.unread = True + article.regenerate() + print(f"Marked {marked_as_read} articles as read, {marked_as_unread} unread") def synchronize_with_server(self):