Updated dashboard
This commit is contained in:
parent
12478854f9
commit
b8ff2e3e2f
@ -24,13 +24,14 @@ func Get(ctx *aero.Context) string {
|
||||
|
||||
// Get dashboard.
|
||||
func Dashboard(ctx *aero.Context) string {
|
||||
var user *arn.User
|
||||
user := utils.GetUser(ctx)
|
||||
var posts []*arn.Post
|
||||
var err error
|
||||
var followIDList []string
|
||||
var userList interface{}
|
||||
var followingList []*arn.User
|
||||
|
||||
flow.Parallel(func() {
|
||||
user = utils.GetUser(ctx)
|
||||
}, func() {
|
||||
posts, err = arn.AllPostsSlice()
|
||||
arn.SortPostsLatestFirst(posts)
|
||||
|
||||
@ -38,21 +39,21 @@ func Dashboard(ctx *aero.Context) string {
|
||||
posts = posts[:maxPosts]
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
followIDList := user.Following
|
||||
userList, err := arn.DB.GetMany("User", followIDList)
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(500, "Error displaying dashboard", err)
|
||||
}
|
||||
|
||||
followingList := userList.([]*arn.User)
|
||||
followingList = arn.SortByLastSeen(followingList)
|
||||
}, func() {
|
||||
followIDList = user.Following
|
||||
userList, err = arn.DB.GetMany("User", followIDList)
|
||||
followingList = userList.([]*arn.User)
|
||||
followingList = arn.SortUsersLastSeen(followingList)
|
||||
|
||||
if len(followingList) > maxFollowing {
|
||||
followingList = followingList[:maxFollowing]
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(500, "Error displaying dashboard", err)
|
||||
}
|
||||
|
||||
return ctx.HTML(components.Dashboard(posts, followingList))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user