From ef2adde1dc7839e7232729a11c3b219ad036661e Mon Sep 17 00:00:00 2001 From: Tushar Daiya Date: Sat, 9 Dec 2023 20:24:38 +0530 Subject: [PATCH 1/4] fix: profile page --- src/pages/Profile/index.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/Profile/index.jsx b/src/pages/Profile/index.jsx index 67ed6323d..f53ffa016 100644 --- a/src/pages/Profile/index.jsx +++ b/src/pages/Profile/index.jsx @@ -199,9 +199,9 @@ function Profile() { bio: data.bio ? data.bio : "Hi there! I am using Dummygram.", country: data.country ? data.country : "Global", storyTimestamp: data.storyTimestamp, - Friends: data.Friends.length, + Friends: data?.Friends?.length||data?.friends?.length, }); - setIsFriendAlready(data.Friends.includes(user?.uid)); + setIsFriendAlready(data?.Friends?.includes(user?.uid)||data?.friends?.includes(user?.uid)); } else { setUserExists(false); } From cf2ba74530a6c174df0ab728c28585713b5fa0c7 Mon Sep 17 00:00:00 2001 From: Narayan soni Date: Sat, 9 Dec 2023 22:52:18 +0530 Subject: [PATCH 2/4] fix: add comment --- src/pages/Profile/index.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/Profile/index.jsx b/src/pages/Profile/index.jsx index 79f1f1793..1bb6116b6 100644 --- a/src/pages/Profile/index.jsx +++ b/src/pages/Profile/index.jsx @@ -200,9 +200,9 @@ function Profile() { bio: data.bio ? data.bio : "Hi there! I am using Dummygram.", country: data.country ? data.country : "Global", storyTimestamp: data.storyTimestamp, - Friends: data?.Friends?.length||data?.friends?.length, + Friends: data?.Friends?.length||data?.friends?.length,// same as below }); - setIsFriendAlready(data?.Friends?.includes(user?.uid)||data?.friends?.includes(user?.uid)); + setIsFriendAlready(data?.Friends?.includes(user?.uid)||data?.friends?.includes(user?.uid)); // old accounts have friends attribute and new accounts have Friends attribute } else { setUserExists(false); } From 4ce0ddb16634c63a2e3d68739e0750c1904dfc2f Mon Sep 17 00:00:00 2001 From: Narayan soni Date: Sat, 9 Dec 2023 23:05:10 +0530 Subject: [PATCH 3/4] fix: another case of this error --- src/components/FriendsComponent/index.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/FriendsComponent/index.jsx b/src/components/FriendsComponent/index.jsx index f672ce388..3103e4155 100644 --- a/src/components/FriendsComponent/index.jsx +++ b/src/components/FriendsComponent/index.jsx @@ -62,8 +62,8 @@ const FriendsComponent = () => { } else { const userData = snapshot.docs[0].data(); const fetchedFriends = []; - setName(userData.displayName); - for (const friendUid of userData.Friends) { + setName(userData.name); + for (const friendUid of (userData?.Friends||userData?.friends)) { const friendData = await getFriendData(friendUid); if (friendData) { fetchedFriends.push({ From accf9fe10c05e31f614f973c446e2800d9b38a32 Mon Sep 17 00:00:00 2001 From: Narayan soni Date: Sat, 9 Dec 2023 23:10:06 +0530 Subject: [PATCH 4/4] fix: update evaluation to prevent TypeError --- src/components/FriendsComponent/index.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/FriendsComponent/index.jsx b/src/components/FriendsComponent/index.jsx index 3103e4155..4c0bb2699 100644 --- a/src/components/FriendsComponent/index.jsx +++ b/src/components/FriendsComponent/index.jsx @@ -63,7 +63,7 @@ const FriendsComponent = () => { const userData = snapshot.docs[0].data(); const fetchedFriends = []; setName(userData.name); - for (const friendUid of (userData?.Friends||userData?.friends)) { + for (const friendUid of (userData?.Friends || userData?.friends || [])) { const friendData = await getFriendData(friendUid); if (friendData) { fetchedFriends.push({