Minor fixes

This commit is contained in:
Eduard Urbach 2018-03-14 16:33:42 +01:00
parent 30080861c4
commit d736505dd1
3 changed files with 21 additions and 4 deletions

View File

@ -8,7 +8,7 @@ import (
)
const maxPosts = 5
const maxTracks = 3
const maxTracks = 12
// Get user profile page.
func Get(ctx *aero.Context) string {

View File

@ -23,7 +23,7 @@ func GetSoundTracksByUser(ctx *aero.Context) string {
index, _ := ctx.GetInt("index")
// Fetch all eligible tracks
allTracks := fetchAllByUser(viewUser.ID)
allTracks := fetchAllTracksByUser(viewUser.ID)
// Sort the tracks by publication date
arn.SortSoundTracksLatestFirst(allTracks)
@ -61,7 +61,7 @@ func GetSoundTracksLikedByUser(ctx *aero.Context) string {
index, _ := ctx.GetInt("index")
// Fetch all eligible tracks
allTracks := fetchAllLikedByUser(viewUser.ID)
allTracks := fetchAllTracksLikedByUser(viewUser.ID)
// Sort the tracks by publication date
arn.SortSoundTracksLatestFirst(allTracks)
@ -84,3 +84,17 @@ func GetSoundTracksLikedByUser(ctx *aero.Context) string {
// Otherwise, send the full page
return ctx.HTML(components.TrackList(tracks, viewUser, nextIndex, user, ctx.URI()))
}
// fetchAllTracksByUser returns all soundtracks that the user with userID published
func fetchAllTracksByUser(userID string) []*arn.SoundTrack {
return arn.FilterSoundTracks(func(track *arn.SoundTrack) bool {
return !track.IsDraft && len(track.Media) > 0 && track.CreatedBy == userID
})
}
// fetchAllTracksLikedByUser returns all soundtracks that the user with userID liked
func fetchAllTracksLikedByUser(userID string) []*arn.SoundTrack {
return arn.FilterSoundTracks(func(track *arn.SoundTrack) bool {
return !track.IsDraft && len(track.Media) > 0 && track.LikedBy(userID)
})
}

View File

@ -7,7 +7,10 @@ component TrackList(tracks []*arn.SoundTrack, viewUser *arn.User, nextIndex int,
h1.page-title= "Tracks liked by " + viewUser.Nick
if len(tracks) == 0
p.no-data.mountable= viewUser.Nick + " hasn't added any tracks yet."
if strings.Contains(uri, "/added")
p.no-data.mountable= viewUser.Nick + " hasn't added any tracks yet."
else
p.no-data.mountable= viewUser.Nick + " hasn't liked any tracks yet."
else
#load-more-target.soundtracks
SoundTracksScrollable(tracks, user)