scorelab / Codelabz

Codelabz
Apache License 2.0
144 stars 410 forks source link

[ Feat : The "Add" and "Remove" following options implemented ] #1181

Open rohitPandey469 opened 7 months ago

rohitPandey469 commented 7 months ago

Description

The isUserFollower and addUserFollower and removeUserFollower which was already present as redux actions, I used it as onClick's function in the fixedData of HomePage ( contributors and who to follow section), and as these functions take two params currentProfile in which the logged in user i.e. Codelabz profile is sent here and the 'profile to follow' in which for the time being I have sent a fixed data of another codelabz account of saogatariju.

Related Issue

Fixes #1177

Motivation and Context

To make things work and smooth like butter.

How Has This Been Tested?

Tested Locally on my machine.

Workings explained:

In first video, Here the follower count and following count for the two users in actions is not updated but just creating or updating the user_followers collection so there is no re render of page as the profileData in HomePage is not updating.

https://github.com/scorelab/Codelabz/assets/123815256/4d8c2c8e-e83e-4d92-9011-92987524b785

While, in second video, the follower count and following count in profile actions is updated i.e. profileData is getting changed and the normal react comparison is so shallow that it's treating them differently causing the page re render and to avoid it I will be doing memoization in another issue or PR - just for the sake of clean code. And, I would like to think it's changing because of props comparison and if not then memo won't work, so will make a different issue for it.

https://github.com/scorelab/Codelabz/assets/123815256/23a13ace-fd73-40a7-a7d1-10042330fd7b

Here every user is getting changed on one user click because I have sent the same profile data for each one of them and i.e. of saogatariju uid. Check the code

Types of changes

Checklist:

Additional:

If want to see the first video changes then just comment out the update doc part in addUserFollower and removeUserFollower actions.