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