Added joined groups page
This commit is contained in:
31
pages/groups/joined.go
Normal file
31
pages/groups/joined.go
Normal file
@ -0,0 +1,31 @@
|
||||
package groups
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"sort"
|
||||
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
)
|
||||
|
||||
// Joined shows the most popular joined groups.
|
||||
func Joined(ctx *aero.Context) string {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
if user == nil {
|
||||
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||
}
|
||||
|
||||
groups := fetchGroups(user.ID)
|
||||
|
||||
// Sort by join date
|
||||
sort.Slice(groups, func(i, j int) bool {
|
||||
aMember := groups[i].FindMember(user.ID)
|
||||
bMember := groups[j].FindMember(user.ID)
|
||||
|
||||
return aMember.Joined > bMember.Joined
|
||||
})
|
||||
|
||||
return render(ctx, groups)
|
||||
}
|
Reference in New Issue
Block a user