Fix slideshow state buttons for favorites and saved files
Check actual filesystem for saved state instead of relying on thumbnail cache. Also works on the favorites tab now — always shows as favorited, checks library by folder.
This commit is contained in:
parent
252cc4e6f3
commit
cb249d9b36
@ -746,14 +746,47 @@ class BooruApp(QMainWindow):
|
||||
"""Update slideshow button states for the current post."""
|
||||
if not self._fullscreen_window:
|
||||
return
|
||||
idx = self._grid.selected_index
|
||||
from ..core.config import saved_dir, saved_folder_dir, MEDIA_EXTENSIONS
|
||||
site_id = self._site_combo.currentData()
|
||||
|
||||
if self._stack.currentIndex() == 1:
|
||||
# Favorites view
|
||||
grid = self._favorites_view._grid
|
||||
favs = self._favorites_view._favorites
|
||||
idx = grid.selected_index
|
||||
if 0 <= idx < len(favs):
|
||||
fav = favs[idx]
|
||||
saved = False
|
||||
if fav.folder:
|
||||
saved = any(
|
||||
(saved_folder_dir(fav.folder) / f"{fav.post_id}{ext}").exists()
|
||||
for ext in MEDIA_EXTENSIONS
|
||||
)
|
||||
else:
|
||||
saved = any(
|
||||
(saved_dir() / f"{fav.post_id}{ext}").exists()
|
||||
for ext in MEDIA_EXTENSIONS
|
||||
)
|
||||
self._fullscreen_window.update_state(True, saved)
|
||||
else:
|
||||
self._fullscreen_window.update_state(False, False)
|
||||
else:
|
||||
idx = self._grid.selected_index
|
||||
if 0 <= idx < len(self._posts) and site_id:
|
||||
post = self._posts[idx]
|
||||
favorited = self._db.is_favorited(site_id, post.id)
|
||||
saved = False
|
||||
if 0 <= idx < len(self._grid._thumbs):
|
||||
saved = self._grid._thumbs[idx]._saved_locally
|
||||
saved = any(
|
||||
(saved_dir() / f"{post.id}{ext}").exists()
|
||||
for ext in MEDIA_EXTENSIONS
|
||||
)
|
||||
if not saved:
|
||||
for folder in self._db.get_folders():
|
||||
saved = any(
|
||||
(saved_folder_dir(folder) / f"{post.id}{ext}").exists()
|
||||
for ext in MEDIA_EXTENSIONS
|
||||
)
|
||||
if saved:
|
||||
break
|
||||
self._fullscreen_window.update_state(favorited, saved)
|
||||
else:
|
||||
self._fullscreen_window.update_state(False, False)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user