Migrate to new follows storage
This commit is contained in:
@ -21,14 +21,8 @@ func Followed(ctx aero.Context) error {
|
||||
|
||||
// fetchActivities filters the activities by the given filters.
|
||||
func fetchActivities(user *arn.User, followedOnly bool) []arn.Activity {
|
||||
var followedUserIDs []string
|
||||
|
||||
if followedOnly && user != nil {
|
||||
followedUserIDs = user.Follows().Items
|
||||
}
|
||||
|
||||
activities := arn.FilterActivityCreates(func(activity arn.Activity) bool {
|
||||
if followedOnly && !arn.Contains(followedUserIDs, activity.GetCreatedBy()) {
|
||||
if followedOnly && user != nil && !user.IsFollowing(activity.GetCreatedBy()) {
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ func Get(ctx aero.Context) error {
|
||||
episodeToFriends := map[int][]*arn.User{}
|
||||
|
||||
if user != nil {
|
||||
friends = user.Follows().Users()
|
||||
friends = user.Follows()
|
||||
deleted := 0
|
||||
|
||||
if animeListItem != nil {
|
||||
|
@ -23,7 +23,7 @@ func Episodes(ctx aero.Context) error {
|
||||
episodeToFriends[ownListItem.Episodes] = append(episodeToFriends[ownListItem.Episodes], user)
|
||||
}
|
||||
|
||||
for _, friend := range user.Follows().Users() {
|
||||
for _, friend := range user.Follows() {
|
||||
friendAnimeList := friend.AnimeList()
|
||||
friendAnimeListItem := friendAnimeList.Find(anime.ID)
|
||||
|
||||
|
@ -126,7 +126,7 @@ func Get(ctx aero.Context) error {
|
||||
var friends []*arn.User
|
||||
|
||||
if user != nil {
|
||||
friendIDs := utils.Intersection(character.Likes, user.Follows().Items)
|
||||
friendIDs := utils.Intersection(character.Likes, user.FollowIDs)
|
||||
friendObjects := arn.DB.GetMany("User", friendIDs)
|
||||
|
||||
for _, obj := range friendObjects {
|
||||
|
@ -120,7 +120,7 @@ func Profile(ctx aero.Context, viewUser *arn.User) error {
|
||||
}
|
||||
|
||||
// Friends
|
||||
friends := viewUser.Follows().UsersWhoFollowBack()
|
||||
friends := viewUser.Friends()
|
||||
|
||||
arn.SortUsersFollowers(friends)
|
||||
|
||||
|
@ -141,12 +141,12 @@ component ProfileHead(viewUser *arn.User, animeList *arn.AnimeList, user *arn.Us
|
||||
|
||||
.profile-actions
|
||||
if user != nil && user.ID != viewUser.ID
|
||||
if !user.Follows().Contains(viewUser.ID)
|
||||
button.profile-action.action.mountable.never-unmount(data-action="followUser", data-trigger="click", data-api="/api/userfollows/" + user.ID + "/add/" + viewUser.ID)
|
||||
if !user.IsFollowing(viewUser.ID)
|
||||
button.profile-action.action.mountable.never-unmount(data-action="followUser", data-trigger="click", data-api="/api/user/" + user.ID + "/follow/" + viewUser.ID)
|
||||
Icon("user-plus")
|
||||
span Follow
|
||||
else
|
||||
button.profile-action.action.mountable.never-unmount(data-action="unfollowUser", data-trigger="click", data-api="/api/userfollows/" + user.ID + "/remove/" + viewUser.ID)
|
||||
button.profile-action.action.mountable.never-unmount(data-action="unfollowUser", data-trigger="click", data-api="/api/user/" + user.ID + "/unfollow/" + viewUser.ID)
|
||||
Icon("user-times")
|
||||
span Unfollow
|
||||
|
||||
|
Reference in New Issue
Block a user