Added number of list items for status tabs

This commit is contained in:
2019-10-26 18:06:14 +09:00
parent af63870850
commit 384f966524
6 changed files with 35 additions and 42 deletions

View File

@ -48,18 +48,19 @@ func AnimeList(ctx aero.Context, user *arn.User, status string, sortBy string) e
return ctx.Error(http.StatusNotFound, "Anime list not found")
}
statusList := animeList.FilterStatus(status)
// Filter private items
if user == nil || user.ID != viewUser.ID {
statusList = statusList.WithoutPrivateItems()
animeList = animeList.WithoutPrivateItems()
}
// Sort the items
statusList.Sort(sortBy)
statusLists := animeList.SplitByStatus()
// Sort the items for the requested status only
animeList = statusLists[status]
animeList.Sort(sortBy)
// These are all anime list items for the given status
allItems := statusList.Items
allItems := statusLists[status].Items
// Slice the part that we need
items := allItems[index:]
@ -102,5 +103,5 @@ func AnimeList(ctx aero.Context, user *arn.User, status string, sortBy string) e
}
// Otherwise, send the full page
return ctx.HTML(components.AnimeListPage(items, nextIndex, viewUser, user, status))
return ctx.HTML(components.AnimeListPage(items, nextIndex, viewUser, user, statusLists))
}

View File

@ -1,9 +1,9 @@
component AnimeListPage(animeListItems []*arn.AnimeListItem, nextIndex int, viewUser *arn.User, user *arn.User, status string)
component AnimeListPage(animeListItems []*arn.AnimeListItem, nextIndex int, viewUser *arn.User, user *arn.User, statusLists map[string]*arn.AnimeList)
h1.page-title= viewUser.Nick + "'s anime list"
if user == nil || user.ID != viewUser.ID
.anime-list-user-avatar
AvatarNoTip(viewUser)
StatusTabs("/+" + viewUser.Nick + "/animelist")
StatusTabs("/+" + viewUser.Nick + "/animelist", statusLists)
AnimeListItems(animeListItems, nextIndex, viewUser, user)