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); }