Added groups to user profiles

This commit is contained in:
Eduard Urbach 2019-06-19 18:57:22 +09:00
parent da878290fa
commit 2d825739ca
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
3 changed files with 46 additions and 1 deletions

View File

@ -16,6 +16,7 @@ const (
maxCharacters = 6
maxFriends = 7
maxStudios = 4
maxGroups = 5
)
// Get user profile page.
@ -155,6 +156,30 @@ func Profile(ctx aero.Context, viewUser *arn.User) error {
dayToActivityCount[days+dayOffset]++
}
// Groups
groups := []*arn.Group{}
for group := range arn.StreamGroups() {
if group.HasMember(viewUser.ID) {
groups = append(groups, group)
}
}
sort.Slice(groups, func(i, j int) bool {
aMembers := len(groups[i].Members)
bMembers := len(groups[j].Members)
if aMembers == bMembers {
return groups[i].Name < groups[j].Name
}
return aMembers > bMembers
})
if len(groups) > maxGroups {
groups = groups[:maxGroups]
}
// Characters
characters := []*arn.Character{}
@ -188,6 +213,7 @@ func Profile(ctx aero.Context, viewUser *arn.User) error {
animeList,
completedList,
characters,
groups,
friends,
topGenres,
topStudios,

View File

@ -1,4 +1,4 @@
component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList, completedList *arn.AnimeList, characters []*arn.Character, friends []*arn.User, topGenres []string, topStudios []*arn.Company, animeWatchingTime time.Duration, dayToActivityCount map[int]int, uri string)
component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList, completedList *arn.AnimeList, characters []*arn.Character, groups []*arn.Group, friends []*arn.User, topGenres []string, topStudios []*arn.Company, animeWatchingTime time.Duration, dayToActivityCount map[int]int, uri string)
.profile
ProfileHeader(viewUser, animeList, user, uri)
@ -29,6 +29,18 @@ component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList,
each character in characters
.mountable(data-mountable-type="character")
CharacterSmall(character, user)
//- Groups
.profile-section
h3.profile-column-header.mountable(data-mountable-type="favorites") Groups
if len(groups) == 0
p.no-data.mountable(data-mountable-type="favorites") Nothing here yet.
else
.profile-groups.mountable(data-mountable-type="favorites")
each group in groups
a.profile-group.tip.mountable(href=group.Link(), aria-label=group.Name, data-mountable-type="group")
img.group-image.lazy(data-src=group.ImageLink("small"), data-webp=true, alt=group.Name)
//- //- People
//- .profile-section

View File

@ -84,6 +84,13 @@ const profile-image-size = 280px
grid-gap 0.5rem
justify-content space-evenly
.profile-groups
display grid
grid-template-columns repeat(auto-fill, 70px)
grid-template-rows repeat(auto-fill, 70px)
grid-gap 0.5rem
justify-content space-evenly
.profile-introduction
a
color white