Almost a month ago, I added posts to the davespace remake. They’re pretty important and the entire site is based on them, getting them right is important. That didn’t stop me from adding bugs though. Take a second to watch this early development footage from when posts were first added:
In the video, I create a post, comment on it, switch accounts, and reply to the comment. All this looks fine in the video, but there’s something hidden that I didn’t notice until after it was uploaded. Upon switching accounts, the username above the post changes into the user I just logged into. Why does this happen? It didn’t happen to the comment so what’s going on? It took me a while to figure this out, but when the server gives the site information about the posts, it’s the sites job to display them for the user. My site has a value called user, some things you need to know about user:
- Stores your username, display name, and profile picture on your device
- Is given to your device by the server upon login
- Stays on your device until logout or cookies are deleted / expired
- So your device doesn’t need to repeatedly ask the server for information
There is also the post value:
- This value stores information on a post
- This includes
- Post id
- Timestamp
- Post content
- Likes
- User info on the poster
Both user, and post.user contain IDENTICAL data structure, but will contain different data unless you’re viewing your own posts.
When creating the posts, I had mistakenly used user.displayName for the name displayed above the post instead of post.user.displayName. This caused it to display the logged in user as the post author no matter what.
In short, I mixed up two VERY similar names and gave myself a headache for a week.
