mirror of
https://codeberg.org/Reuh/feather.git
synced 2025-10-27 18:19:32 +00:00
feat: update local state on read/unread without waiting for next sync
This commit is contained in:
parent
ae0c10eb6d
commit
972d6e8441
1 changed files with 21 additions and 6 deletions
|
|
@ -65,27 +65,42 @@ class FeatherApp:
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# gather articles to mark as read/unread
|
||||||
marked_as_read, marked_as_unread = 0, 0
|
marked_as_read, marked_as_unread = 0, 0
|
||||||
to_mark_as_read = []
|
to_mark_as_read = []
|
||||||
to_mark_as_unread = []
|
to_mark_as_unread = []
|
||||||
for article in self.iter_articles():
|
for article in self.iter_articles():
|
||||||
if not article.has_html():
|
if not article.has_html():
|
||||||
if article.unread:
|
if article.unread:
|
||||||
to_mark_as_read.append(article.id)
|
to_mark_as_read.append(article)
|
||||||
marked_as_read += 1
|
marked_as_read += 1
|
||||||
else:
|
else:
|
||||||
to_mark_as_unread.append(article.id)
|
to_mark_as_unread.append(article)
|
||||||
marked_as_unread += 1
|
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(
|
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(
|
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")
|
print(f"Marked {marked_as_read} articles as read, {marked_as_unread} unread")
|
||||||
|
|
||||||
def synchronize_with_server(self):
|
def synchronize_with_server(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue