Apologies
You must be signed in to watch this lesson.
Share Posts with Followers
Fullstack Social iOS NodeJS REST
In addition to creating a FeedItem for ourselves when we make a post, we're also required to fill the feed of users in the system that are following the logged in user. To easily accomplish this task, we'll first fetch all of our followers and create a FeedItem for each one of them that will represent our new post object.

Comments (2)
AlfieLBTA
3 years ago
Hey Brain: in order for the right screen to auto refresh when another user creates a post, do you need to implement sockets ? or is there a kind of timer running on the background that checks for new items and if there is any it reloads?
gerkov77
3 years ago
Hey Brian! Is it normal that at this point my logged in user still cannot see his or her own post in the feed, only the posts of those they are following? Only their newly created posts are showing up in the feed during the session, but after logging out and back in, they are gone from the feed. (they show up in the other users feed if they are following this user) They exist only in the profile section. Is it meant to be like that?
gerkov77
3 years ago
I mean Arnold Schwarzenegger logs in - he has like 5 posts in the profile section, his feed does not show them. It shows only Tim Cook's and Elon Musk's posts, because he is following them. Now if Arnold posts something, it appears in the feed, but next time he logs in, he can see it only on his profile page's photo stream.
Brian Voong
3 years ago
gerkov77
3 years ago
Looks like it's the unfollow method that destroys feeditems not only for the req.session.user, but for the postOwner too! So once some user unfollowed Arnold, Arnold himself loses his posts from his feed too. (He still has them on his profile page as post objects.) Not sure yet how to avoid this though. Until no user has touched the unfollow button, everything seemed to work fine.
gerkov77
3 years ago
What I don't understand, that by unfollowing feeditems got distroyed for the unfollower user and the postowner, but no one else. The unfollower can get those feeditems back by following again, but the postowner cannot get his posts back on his feed, because the onfollower user have destroyed them for him :( Is anyone experiencing the same bug?
gerkov77
3 years ago
I seemed to solve the problem by adding a new criteria to the method call responsible for deleting the feeditems. The method call now looks like this: await Feeditem.destroy({postOwner: userIdToUnfollow, user: currentUserId }) Like this it's gonna destroy feeditems of given postOwner only for the currently logged in user, and does not touch those on the postOwner's feed.
HELP & SUPPORT