Skip to content

Commit

Permalink
fix: return empty array when no followers or following
Browse files Browse the repository at this point in the history
  • Loading branch information
maui-r committed Nov 21, 2022
1 parent 736ac28 commit dbd8309
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/subgraph/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ export const getAllFollowing = async (ethereumAddress: string): Promise<string[]
throw new Error('No result data')
}

if (!result.data.account?.following) {
// Address is not following anyone
return []
}

for (let followRelation of result.data.account.following) {
following.push(followRelation.profile.id)
lastId = followRelation.id
Expand Down Expand Up @@ -67,5 +72,10 @@ export const getFollowers = async ({ profileId, first, skip = 0 }: { profileId:
throw new Error('No result data')
}

if (!result.data.profile?.followers) {
// Profile has no followers
return []
}

return result.data.profile.followers.map((f: { account: { id: string } }) => (f.account.id))
}

0 comments on commit dbd8309

Please sign in to comment.