Fix thumbnail loading and startup gallery refresh.

Refresh gallery metadata after thumbnail generation so new thumb URLs are available immediately, and lazy-load gallery thumbnails with IntersectionObserver to avoid fetching all images on initial page load.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-03 00:16:38 +12:00
parent 45b31be9a7
commit a9095727bf
3 changed files with 55 additions and 1 deletions

View File

@@ -70,6 +70,17 @@ func New(imagesDir, staticDir string, mailCfg *mail.Config) (*Server, error) {
} else {
log.Print("gallery thumbnails: ready")
}
// Thumbnail URLs are resolved during gallery.List. Re-list after derivative
// generation so newly-created thumbs appear immediately on first load.
if refreshed, err := gallery.List(imagesDir); err != nil {
log.Printf("gallery refresh after thumbnails: %v", err)
} else {
srv.Images = refreshed
if hero, hasHero := gallery.SelectHero(refreshed); hasHero {
srv.Hero = hero
srv.HasHero = true
}
}
return srv, nil
}