Skip to content

Commit

Permalink
Minor fixes in filtering and recents screen (#853)
Browse files Browse the repository at this point in the history
  • Loading branch information
Haaruun-I authored Jul 22, 2024
1 parent 1fd3144 commit 6389282
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cozy/ui/library_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def _on_library_view_mode_changed(self):
visible_child_name = RECENT_PAGE
elif view_mode == LibraryViewMode.CURRENT:
visible_child_name = RECENT_PAGE
if not self._view_model.is_any_book_in_progress:
if not self._view_model.is_any_book_recent:
books_view_page = NO_RECENT_PAGE
elif view_mode == LibraryViewMode.AUTHOR:
visible_child_name = AUTHOR_PAGE
Expand Down
15 changes: 9 additions & 6 deletions cozy/view_model/library_view_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ def selected_filter(self, value):
self._notify("selected_filter")

@property
def is_any_book_in_progress(self) -> bool:
return any(book.position > 0 for book in self.books)
def is_any_book_recent(self) -> bool:
return any(book.last_played > 0 for book in self.books)

@property
def authors(self):
Expand Down Expand Up @@ -129,12 +129,15 @@ def display_book_filter(self, book_element: BookCard):
hide_offline_books = self._application_settings.hide_offline
book_is_online = self._fs_monitor.get_book_online(book)

if self.selected_filter == _("All"):
return True
elif hide_offline_books and not book_is_online and not book.downloaded:

if hide_offline_books and not book_is_online and not book.downloaded:
return False
elif self.library_view_mode == LibraryViewMode.CURRENT:

if self.library_view_mode == LibraryViewMode.CURRENT:
return book.last_played > 0

if self.selected_filter == _("All"):
return True
elif self.library_view_mode == LibraryViewMode.AUTHOR:
return self.selected_filter in book.author
elif self.library_view_mode == LibraryViewMode.READER:
Expand Down

0 comments on commit 6389282

Please sign in to comment.