Skip to content

Commit

Permalink
Fixed Profile Page (#1306)
Browse files Browse the repository at this point in the history
* fix: profile page

* fix: add comment

* fix: another case of this error

* fix: update evaluation to prevent TypeError

---------

Co-authored-by: Narayan soni <narayansoni854@gmail.com>
  • Loading branch information
tushar-daiya and narayan954 authored Dec 9, 2023
1 parent 11e7824 commit 0183e74
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/components/FriendsComponent/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Profile/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 0183e74

Please sign in to comment.