From e48c719a684e7c8432be3ee9f65221c63a9f5f7b Mon Sep 17 00:00:00 2001 From: mkelvers Date: Tue, 23 Jun 2026 15:32:24 +0200 Subject: [PATCH] refactor: lazy load audio availability via htmx --- internal/anime/details_handler.go | 6 +++++ templates/anime.gohtml | 11 +--------- .../components/anime_episode_count.gohtml | 22 +++++++++++++++++++ 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/internal/anime/details_handler.go b/internal/anime/details_handler.go index b55a767..9fe8bf7 100644 --- a/internal/anime/details_handler.go +++ b/internal/anime/details_handler.go @@ -271,6 +271,12 @@ func (h *AnimeHandler) loadAnimeDetailsSection(ctx context.Context, id int, sect return nil, "", err } return h.animeEpisodeCount(ctx, anime, time.Now()), "anime_episode_count", nil + case "audio-availability": + anime, err := h.svc.GetAnimeByID(ctx, id) + if err != nil { + return nil, "", err + } + return h.animeAudioAvailability(ctx, anime), "anime_audio_availability", nil case "themes": data, err := h.svc.GetThemes(ctx, id) return data, "anime_themes", err diff --git a/templates/anime.gohtml b/templates/anime.gohtml index 5b3e300..d3880ed 100644 --- a/templates/anime.gohtml +++ b/templates/anime.gohtml @@ -35,16 +35,7 @@ {{if $anime.Status}}{{$anime.Status}}{{end}} {{if $anime.Season}}{{$anime.Premiered}}{{end}} {{if $anime.ShortRating}}{{$anime.ShortRating}}{{end}} - {{if .AudioAvailability}} - - - {{.AudioAvailability}} - - {{end}} + {{template "anime_audio_availability_loading" dict "AnimeID" $anime.MalID}}
diff --git a/templates/components/anime_episode_count.gohtml b/templates/components/anime_episode_count.gohtml index cdb26b1..48e7571 100644 --- a/templates/components/anime_episode_count.gohtml +++ b/templates/components/anime_episode_count.gohtml @@ -15,6 +15,28 @@ {{end}} {{end}} +{{define "anime_audio_availability"}} +{{if .Items}} + + + {{.Items}} + +{{end}} +{{end}} + +{{define "anime_audio_availability_loading"}} + +{{end}} + {{define "anime_episode_count_loading"}} {{if .Count}}