Skip to content

Commit

Permalink
fix(watchtime): handle null data
Browse files Browse the repository at this point in the history
  • Loading branch information
veryCrunchy committed May 19, 2024
1 parent 51fe578 commit 8cc2831
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/gql/resolvers/watchtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,18 @@ const watchtimeResolver: Resolvers["Query"] = {
display_name: string;
profile_image_url: string;
}[];
return times.map(entry => {
const data = userData.find(user => user.id === entry.id);
return {
displayName: data!.display_name,
time: entry.time ?? 0,
avatar: data!.profile_image_url,
};
});
return times
.map(entry => {
const data = userData.find(user => user.id === entry.id);
if (!data) return null;

return {
displayName: data.display_name,
time: entry.time ?? 0,
avatar: data.profile_image_url,
};
})
.filter(e => e !== null);
},
};
export default watchtimeResolver;

0 comments on commit 8cc2831

Please sign in to comment.