Fix bug with current user staying offline after login

This commit is contained in:
Alex Erdei 2025-05-04 10:25:24 +01:00
parent 7800452089
commit 29345a8a53
1 changed files with 9 additions and 1 deletions

View File

@ -309,6 +309,10 @@ function openSocket() {
const parseMsg = (raw) => (typeof raw === "string" ? JSON.parse(raw) : raw); const parseMsg = (raw) => (typeof raw === "string" ? JSON.parse(raw) : raw);
/* helper does the row belong to me? */
const isMe = (row) => row && row.user_id === localStorage.getItem(LS_USER_ID);
/* 1⃣ Start first … */ /* 1⃣ Start first … */
hub hub
@ -326,7 +330,11 @@ function openSocket() {
}); });
hub.on("fakebook.users.put", (raw) => { hub.on("fakebook.users.put", (raw) => {
store.dispatch(usersUpdated([parseMsg(raw)])); const row = parseMsg(raw);
store.dispatch(usersUpdated([row]));
if (isMe(row)) store.dispatch(currentUserUpdated(row));
}); });
hub.on("fakebook.posts.post", (raw) => { hub.on("fakebook.posts.post", (raw) => {