Removed flickering on iframes
This commit is contained in:
@ -2,6 +2,7 @@ package soundtracks
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
@ -31,3 +32,35 @@ func Get(ctx *aero.Context) string {
|
||||
|
||||
return ctx.HTML(components.SoundTracks(tracks, user))
|
||||
}
|
||||
|
||||
// From renders the soundtracks from the given index.
|
||||
func From(ctx *aero.Context) string {
|
||||
user := utils.GetUser(ctx)
|
||||
index, err := ctx.GetInt("index")
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusBadRequest, "Invalid start index", err)
|
||||
}
|
||||
|
||||
tracks, err := arn.FilterSoundTracks(func(track *arn.SoundTrack) bool {
|
||||
return !track.IsDraft && len(track.Media) > 0
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusInternalServerError, "Error fetching soundtracks", err)
|
||||
}
|
||||
|
||||
if index < 0 || index >= len(tracks) {
|
||||
return ctx.Error(http.StatusBadRequest, "Invalid start index (maximum is "+strconv.Itoa(len(tracks))+")", nil)
|
||||
}
|
||||
|
||||
arn.SortSoundTracksLatestFirst(tracks)
|
||||
|
||||
tracks = tracks[index:]
|
||||
|
||||
if len(tracks) > maxTracks {
|
||||
tracks = tracks[:maxTracks]
|
||||
}
|
||||
|
||||
return ctx.HTML(components.SoundTracksScrollable(tracks, user))
|
||||
}
|
||||
|
@ -12,6 +12,12 @@ component SoundTracks(tracks []*arn.SoundTrack, user *arn.User)
|
||||
Icon("pencil")
|
||||
span Edit draft
|
||||
|
||||
.sound-tracks
|
||||
each track in tracks
|
||||
SoundTrack(track)
|
||||
#load-more-target.sound-tracks
|
||||
SoundTracksScrollable(tracks, user)
|
||||
|
||||
//- .buttons
|
||||
//- LoadMore
|
||||
|
||||
component SoundTracksScrollable(tracks []*arn.SoundTrack, user *arn.User)
|
||||
each track in tracks
|
||||
SoundTrack(track)
|
Reference in New Issue
Block a user