fix: mtime filter + lightbox navigation (arrows, swipe, keyboard)
This commit is contained in:
@@ -66,15 +66,26 @@ async def admin_get_photos(
|
||||
photos = [p for p in all_photos if _is_image(p)]
|
||||
|
||||
# Enrichit chaque photo avec mtime depuis le disque
|
||||
# Indexe par stem ET par nom complet pour couvrir les deux formats d'id
|
||||
mtime_index: dict[str, float] = {}
|
||||
if media_dir.exists():
|
||||
for f in media_dir.iterdir():
|
||||
mtime_index[f.stem] = f.stat().st_mtime
|
||||
for media_dir_candidate in [
|
||||
media_dir,
|
||||
Path("/home/pi/photobooth-data/media/processed_full"),
|
||||
Path("/home/pi/photobooth-data/media"),
|
||||
]:
|
||||
if media_dir_candidate.exists():
|
||||
for f in media_dir_candidate.iterdir():
|
||||
if f.is_file():
|
||||
mt = f.stat().st_mtime
|
||||
mtime_index[f.name] = mt # uuid.jpg
|
||||
mtime_index[f.stem] = mt # uuid
|
||||
break
|
||||
|
||||
for p in photos:
|
||||
pid = _get_id(p)
|
||||
p["photo_id"] = pid
|
||||
mt = mtime_index.get(pid, 0.0)
|
||||
stem = pid.rsplit(".", 1)[0] if "." in pid else pid
|
||||
mt = mtime_index.get(pid) or mtime_index.get(stem) or 0.0
|
||||
p["mtime"] = mt
|
||||
p["date_iso"] = datetime.fromtimestamp(mt).strftime("%Y-%m-%d") if mt else ""
|
||||
p["date_label"] = datetime.fromtimestamp(mt).strftime("%d/%m/%Y %H:%M") if mt else ""
|
||||
|
||||
Reference in New Issue
Block a user