Improved forum activity in dashboard

This commit is contained in:
Eduard Urbach 2017-06-29 18:39:42 +02:00
parent 3a1a8ad19b
commit f4703fdd5f
2 changed files with 22 additions and 7 deletions

View File

@ -29,7 +29,8 @@ func Get(ctx *aero.Context) string {
// Render the dashboard. // Render the dashboard.
func dashboard(ctx *aero.Context) string { func dashboard(ctx *aero.Context) string {
var posts []*arn.Post var forumPosts []arn.Postable
var forumThreads []arn.Postable
var userList interface{} var userList interface{}
var followingList []*arn.User var followingList []*arn.User
var soundTracks []*arn.SoundTrack var soundTracks []*arn.SoundTrack
@ -38,15 +39,21 @@ func dashboard(ctx *aero.Context) string {
user := utils.GetUser(ctx) user := utils.GetUser(ctx)
flow.Parallel(func() { flow.Parallel(func() {
var err error posts, err := arn.AllPosts()
posts, err = arn.AllPosts()
if err != nil { if err != nil {
return return
} }
arn.SortPostsLatestFirst(posts) forumPosts = arn.ToPostables(posts)
posts = arn.FilterPostsWithUniqueThreads(posts, maxPosts) }, func() {
threads, err := arn.AllThreads()
if err != nil {
return
}
forumThreads = arn.ToPostables(threads)
}, func() { }, func() {
animeList, err := arn.GetAnimeList(user) animeList, err := arn.GetAnimeList(user)
@ -114,5 +121,13 @@ func dashboard(ctx *aero.Context) string {
} }
}) })
return ctx.HTML(components.Dashboard(upcomingEpisodes, posts, soundTracks, followingList)) forumActivity := append(forumPosts, forumThreads...)
sort.Slice(forumActivity, func(i, j int) bool {
return forumActivity[i].Created() > forumActivity[j].Created()
})
forumActivity = arn.FilterPostablesWithUniqueThreads(forumActivity, maxPosts)
return ctx.HTML(components.Dashboard(upcomingEpisodes, forumActivity, soundTracks, followingList))
} }

View File

@ -1,4 +1,4 @@
component Dashboard(schedule []*arn.UpcomingEpisode, posts []*arn.Post, soundTracks []*arn.SoundTrack, following []*arn.User) component Dashboard(schedule []*arn.UpcomingEpisode, posts []arn.Postable, soundTracks []*arn.SoundTrack, following []*arn.User)
h2.page-title Dash h2.page-title Dash
.widgets .widgets