Skip to content

Commit

Permalink
♻️ Add more null checks
Browse files Browse the repository at this point in the history
  • Loading branch information
zivavu committed May 11, 2024
1 parent 8f12862 commit e6f9064
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/common/friendsManage/getAcceptedFriends.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ export default function getAcceptedFriends(userData: IUser) {
const acceptedFriends =
Object.values(userData.friends)
.filter((friend) => friend.status === 'accepted')
.sort((a, b) => b.acceptedAt.seconds - a.acceptedAt.seconds) || [];
.sort((a, b) => b.acceptedAt?.seconds - a.acceptedAt?.seconds) || [];
return acceptedFriends;
}
2 changes: 1 addition & 1 deletion src/common/friendsManage/useGetMutualFriends.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ export default function useGetMutualFriends(friendId: string) {
.filter((friend) => {
return userFriends[friend.id];
})
.sort((b, a) => b.acceptedAt.seconds - a.acceptedAt.seconds) || [];
.sort((b, a) => b?.acceptedAt?.seconds - a?.acceptedAt?.seconds) || [];
return mutualFriends;
}
2 changes: 1 addition & 1 deletion src/components/molecules/ContactsSidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function ContactsSidebar({ sx, ...rootProps }: BoxProps) {
const friendData = everyUserBasicInfo[friend.id];
return { basicInfo: friendData, ...friend } as IFriendWithBasicInfo;
})
.sort((a, b) => b.acceptedAt.seconds - a.acceptedAt.seconds);
.sort((a, b) => b?.acceptedAt?.seconds - a?.acceptedAt?.seconds);
setFriends(friendsWithBasicInfo);
}
}, [loggedUser, everyUserBasicInfo]);
Expand Down

0 comments on commit e6f9064

Please sign in to comment.