Check for null in friends mapping

This commit is contained in:
Rogerio Chaves 2020-04-13 12:38:18 +02:00
parent 1855ca5649
commit d4901a8ebf
No known key found for this signature in database
GPG Key ID: E6AF5440509B1D94
1 changed files with 2 additions and 2 deletions

View File

@ -184,14 +184,14 @@ const getFriends = async (ssbServer, profile) => {
let connections = {};
for (let key in graph) {
let isFollowing = graph[profile.id][key] > 0;
let isFollowing = graph[profile.id] && graph[profile.id][key] > 0;
let isFollowingBack = graph[key] && graph[key][profile.id] > 0;
if (isFollowing && isFollowingBack) {
connections[key] = "friends";
} else if (isFollowing && !isFollowingBack) {
connections[key] = "requestsSent";
} else if (!isFollowing && isFollowingBack) {
if (graph[profile.id][key] === undefined)
if (!graph[profile.id] || graph[profile.id][key] === undefined)
connections[key] = "requestsReceived";
}
}