Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not show when a profile follows itself #3685

Merged
merged 2 commits into from Sep 4, 2023

Conversation

foolo
Copy link
Contributor

@foolo foolo commented Sep 1, 2023

What does this PR do?

If the signed-in user, appears in another user's (or in rare cases, their own) Following or Followers list, then hide the follow/unfollow button next to the signed-in user.

sceenshot

Screenshot_2023-09-01_18-12-21

🤖 Generated by Copilot at 91f0502

This pull request fixes a bug where the user could see and follow themselves on their own profile page. It modifies the Followers.tsx and Following.tsx components to exclude the user from the lists and actions.

Related issues

Fixes #3683

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Enhancement (non-breaking small changes to existing functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Explanation of the changes

🤖 Generated by Copilot at 91f0502

  • Filter out the current profile from the lists of followers and followings in Followers.tsx and Following.tsx to prevent the user from seeing themselves as a follower or following of their own profile (link, link)
  • Hide the follow and unfollow buttons for the current profile in Followers.tsx and Following.tsx to prevent the user from following or unfollowing themselves (link, link)
  • Import and use the useAppStore hook in Following.tsx to get the current profile from the app state (link, link)

Emoji

🚫🛠️🗃️

@foolo foolo requested a review from bigint as a code owner September 1, 2023 16:07
@foolo foolo linked an issue Sep 1, 2023 that may be closed by this pull request
@vercel
Copy link

vercel bot commented Sep 1, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
prerender ✅ Ready (Inspect) Visit Preview Sep 1, 2023 6:09pm
web ✅ Ready (Inspect) Visit Preview Sep 1, 2023 6:09pm

@bigint bigint changed the title do not show when a profile follows itself fix: do not show when a profile follows itself Sep 1, 2023
@foolo
Copy link
Contributor Author

foolo commented Sep 1, 2023

@bigint, Updated according to feedback.

Comment on lines 94 to +99
showFollow={
currentProfile?.id !== follower?.wallet?.defaultProfile?.id
}
showUnfollow={
currentProfile?.id !== follower?.wallet?.defaultProfile?.id
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can make a common props for both 🙇🏼

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point! i'll update it

Copy link
Contributor Author

@foolo foolo Sep 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bigint Just want to double check. If we replace showFollow and showUnfollow with a common prop, (let's say showFollowUnfollow), then it would also change the behavior a bit in other places where UserProfile is used. We would show an Unfollow button in more places.

Example: I am following TeaParty. With this change I would see Unfollow button in the circle in the screenshot below. Is this desired? I think it would be an improvement.

Screenshot_2023-09-02_11-56-37

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are for current account only right? how it will hide for other account which is not owned by you 🤔

Copy link
Contributor Author

@foolo foolo Sep 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit hard to explain, but i'll try 🙂
First, yes, this is about when currentProfile sees a another persons profile in in a list or somewhere else at the site.
Also, this is just a small change that I wanted to mention, about the consequence of using a common boolean prop for showFollow and showUnfollow. No big change, but a slight change in behavior, as follows:

If we replace, showFollow and showUnfollow with a common prop, "showFollowUnfollow", when we will show the unfollow button in more places, for example in the circle in the screenshot. Because before, in many uses of UserProfile, we only passed showFollow as a prop (and not showUnfollow). But if we replace these with a common boolean, the logic will be the same for follow and unfollow, and thus, we will show Unfollow button on all places where we only showed Follow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addition: I hope this answers your question. If not, maybe we should instead try to write test cases first, before implementing the logic? Then the expected behavior will be clear from the beginning.

Also one need to keep in mind that there are three parties involved in the logic. A: The current account, B: The account who owns the Following/Followers list, and C. The account of each profile displayed in the list. And in each case A, B and C may or may not be the same account.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh i got you what you mean 🙌🏼 makes sense 🚀

@bigint bigint merged commit 3627c9e into main Sep 4, 2023
8 checks passed
@bigint bigint deleted the 3683-do-not-show-when-a-profile-follows-itself branch September 4, 2023 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Do not show when a profile follows itself
2 participants