ataverascrespo / RecordRack

Digital music collections and social platform
https://recordrack.ca
GNU General Public License v3.0
1 stars 1 forks source link

Followers/following on user profile needs some TLC #14

Closed ataverascrespo closed 9 months ago

ataverascrespo commented 9 months ago

The followers/following stuff was implemented pretty quick which means I made some questionable choices, and there are some minor bugs.

A bug I noticed is that, for some reason, the following and follower lists for a user seem to reverse if you unfollow then follow that user. On top of that I don't need to reload the entire page state when a user is followed/unfollowed, so i can save on some API endpoint calls there as well

ataverascrespo commented 9 months ago

For the bug - when I made the big changes last week to abstract database logic out of the service classes, I made one small mistake when translating logic.

For the followers count, I accidentally returned the count where the userID = followerID. That means, in the UserFollowing object (with columns followerID and targetID), the user was the FOLLOWER, not the target (the followed). That means that the follower count was returning all instances where the user was following someone else. The same goes for following count. That simple change should fix that list reversal error.

As for the state changes, I abstracted the React Mobx observer for followers/followings to rely on a seperate field of the user, as opposed to the overall user. That way, when that field changes, the entire user does not reload.