Archive prompts for the 20th commit
This commit is contained in:
parent
db1e65b3fa
commit
36398127ec
|
@ -0,0 +1,64 @@
|
||||||
|
Our previous conversation revolved around improving the Fakebook application, a Facebook clone with a React-Redux
|
||||||
|
frontend and a Magic backend. We addressed several critical bugs and implemented improvements across different
|
||||||
|
components:
|
||||||
|
|
||||||
|
1.We fixed the current user's profile display by ensuring that the Redux slice receives a fully mapped user
|
||||||
|
object immediately after login or session restoration.
|
||||||
|
|
||||||
|
2.We modified the post creation mechanism to work with the Magic backend, ensuring that posts are correctly sent
|
||||||
|
to the server and handled by SignalR updates.
|
||||||
|
|
||||||
|
3.We resolved an issue with the Profile component where the user profile could not be rendered if the users were
|
||||||
|
still loading or the username was invalid. We implemented a more robust method of resolving and displaying user
|
||||||
|
profiles using useMemo and adding proper fallback rendering.
|
||||||
|
|
||||||
|
4.We added missing handler functions for photo selection and upload modals to ensure smooth user interactions
|
||||||
|
when changing profile and cover pictures.
|
||||||
|
|
||||||
|
Throughout the process, we focused on maintaining the existing code structure, minimizing changes, and ensuring that
|
||||||
|
the modifications were surgical and targeted. The goal was to improve the application's reliability, user experience,
|
||||||
|
and compatibility with the Magic backend without introducing unnecessary complexity.
|
||||||
|
++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
|
It's working but I have a bug. Can you please save the context and start a new chat?
|
||||||
|
|
||||||
|
The profile component does not show the photos and the posts of the current user for the first loading of the app.
|
||||||
|
When I refresh the browser these are visible again. The problem is just with the current user.
|
||||||
|
|
||||||
|
We do not use Redux thunk for the requests. Here is the backend.js file:
|
||||||
|
// src/backend/backend.js
|
||||||
|
Here are the two important Redux slices:
|
||||||
|
// src/features/currentUser/currentUserSlice.js
|
||||||
|
// src/features/users/usersSlice.js
|
||||||
|
|
||||||
|
Can I get just the beginning of the code to copy in?
|
||||||
|
|
||||||
|
Can I get the rest of it too?
|
||||||
|
|
||||||
|
There are too many details in the code, what would make it stop working if we tried. Can instead give me a step by
|
||||||
|
step debugging instruction to identify the cause?
|
||||||
|
|
||||||
|
I solved the issue with the Redux dev tools. The users state contains everything apart from the posts and photos of
|
||||||
|
the current user. The reason is that this is getting updated by the usersUpdated slice when it already contains
|
||||||
|
partial information about the current user. This reducer did not contain the lines, which update photos and posts
|
||||||
|
fields.
|
||||||
|
|
||||||
|
Not exactly. Do you want to see the code?
|
||||||
|
|
||||||
|
// src/features/usersSlice/usersSlice.js
|
||||||
|
// src/utils/mapRestUser.js
|
||||||
|
|
||||||
|
The simplest solution is removing the openSocket() call from the setAuth function. I needed to put in two places
|
||||||
|
right after the bootstrapSession call in both signInUser and subscribeAuth function. In this case no other
|
||||||
|
modification is needed and everything works.
|
||||||
|
|
||||||
|
Interestingly if I move the openSocket() call at the end of the bootstrapSession, current user stays offline in the
|
||||||
|
UI if the user logs in.
|
||||||
|
|
||||||
|
It's not working this way. If I have just loaded in the site and I log in, I will stay offline.
|
||||||
|
|
||||||
|
The simpler second solution is perfect.
|
||||||
|
|
||||||
|
// The code was still buggy and I decided to add the two extra lines to the usersUpdated reducer to update photos
|
||||||
|
// and posts too.
|
||||||
|
|
Loading…
Reference in New Issue