From 0183e74d475bdfc55e44ec661ffa6cb2bc354ac5 Mon Sep 17 00:00:00 2001 From: Tushar Daiya Date: Sat, 9 Dec 2023 23:11:03 +0530 Subject: [PATCH] Fixed Profile Page (#1306) * fix: profile page * fix: add comment * fix: another case of this error * fix: update evaluation to prevent TypeError --------- Co-authored-by: Narayan soni --- src/components/FriendsComponent/index.jsx | 4 ++-- src/pages/Profile/index.jsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/FriendsComponent/index.jsx b/src/components/FriendsComponent/index.jsx index f672ce388..4c0bb2699 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({ diff --git a/src/pages/Profile/index.jsx b/src/pages/Profile/index.jsx index cd69856e6..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, + Friends: data?.Friends?.length||data?.friends?.length,// same as below }); - setIsFriendAlready(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); }