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

useProfile seems to use the most recently received event, rather than the most recently created event. #17

Open
michaelhall923 opened this issue Feb 10, 2023 · 1 comment

Comments

@michaelhall923
Copy link

I noticed this behavior when trying to create a profile page with my picture on it.

export default function Profile() {
  const router = useRouter();
  const { pubkey } = router.query;

  const { data: userData } = useProfile({
    pubkey,
  });

  return (
    <>
      <Avatar
        src={userData?.picture}
        alt={userData?.name}
        size={42}
        radius="50%"
      />
      <Text size="lg" color="white">
        {userData?.display_name
          ? userData.display_name
          : `@${pubkey.substring(0, 5)}...`}
      </Text>
    </>
  );
}

The picture would initially load as my current picture, then after a few seconds switch to an old profile pic I used. This can be resolved by always setting userData to the event with the most recent created_at time.

@wds4
Copy link
Contributor

wds4 commented Feb 10, 2023

Perhaps in useProfile, before executing setFetchedProfiles, we need to check whether fetchedProfiles[pubkey] already exists; if so, look at created_at to decide whether to update it or not.

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

No branches or pull requests

2 participants