diff --git a/pages/dashboard/dashboard.go b/pages/dashboard/dashboard.go index d0ec0cfd..dbf5fbde 100644 --- a/pages/dashboard/dashboard.go +++ b/pages/dashboard/dashboard.go @@ -53,6 +53,7 @@ func Get(ctx *aero.Context) string { } animeList = animeList.Watching() + animeList.Lock() for _, item := range animeList.Items { futureEpisodes := item.Anime().UpcomingEpisodes() @@ -64,6 +65,8 @@ func Get(ctx *aero.Context) string { upcomingEpisodes = append(upcomingEpisodes, futureEpisodes...) } + animeList.Unlock() + sort.Slice(upcomingEpisodes, func(i, j int) bool { return upcomingEpisodes[i].Episode.AiringDate.Start < upcomingEpisodes[j].Episode.AiringDate.Start }) diff --git a/pages/profile/profile.go b/pages/profile/profile.go index e8dda8e0..e8dfc1a7 100644 --- a/pages/profile/profile.go +++ b/pages/profile/profile.go @@ -39,6 +39,9 @@ func Profile(ctx *aero.Context, viewUser *arn.User) string { animeList = viewUser.AnimeList() // Sort by rating + animeList.Lock() + defer animeList.Unlock() + sort.Slice(animeList.Items, func(i, j int) bool { return animeList.Items[i].Rating.Overall > animeList.Items[j].Rating.Overall }) diff --git a/pages/profile/stats.go b/pages/profile/stats.go index 9cdbaf37..43db80f8 100644 --- a/pages/profile/stats.go +++ b/pages/profile/stats.go @@ -33,6 +33,9 @@ func GetStatsByUser(ctx *aero.Context) string { return ctx.Error(http.StatusInternalServerError, "Anime list not found", err) } + animeList.Lock() + defer animeList.Unlock() + for _, item := range animeList.Items { currentWatch := item.Episodes * item.Anime().EpisodeLength reWatch := item.RewatchCount * item.Anime().EpisodeCount * item.Anime().EpisodeLength