t3dotgg / chirp

https://xn--uo8h.t3.gg/
394 stars 62 forks source link

author.username returns null #30

Open 1moein opened 1 year ago

1moein commented 1 year ago

When @t3dotgg added the username to the posts, I followed along but I would get null values for usernames. As a replacement, I used a portion of the author.id string and kept the author.username in there to fix later. I can no longer sweep this issue under the rug and need to fix it. Any suggestions would be appreciated. I am using github login, btw. Here's how the username looks for me right now and the code is shown below.

image
const PostView = (props: PostWithUser) => {
  const { post, author } = props;
  //const displayname = `@user..${author.id.slice(-5)}.${author.username}`;
  return (
    <div key={post.id} className="flex border-b border-slate-400 p-8">
      <Image
        src={author.profileImageUrl}
        className="h-14 w-14 rounded-full"
        //alt={`${displayname}'s profile picture`}
        alt="profile picture"
        width={56}
        height={56}
      />
      <div className="flex flex-col">
        <div className="flex gap-1 font-bold text-slate-300">
          <span>{`@user..${author.id.slice(-5)}.${author.username}`}</span>
          <span className="font-thin">{`· ${dayjs(
            post.createdAt
          ).fromNow()}`}</span>
        </div>
        <span className="text-2xl">{post.content}</span>
      </div>
    </div>
  );
};

A bit more details: image

1moein commented 1 year ago

Update: turns out github username is actually pulled in and shown. The username that shows as null is a Gmail account since I had enabled both github and Google logins. I just need to assign a username for those using Google to log in.