fix RespectButton component code

This commit is contained in:
Riley Davis
2017-04-19 22:02:57 -06:00
parent 59fbff3caf
commit ffdec225c7
2 changed files with 30 additions and 19 deletions
+15 -7
View File
@@ -3,18 +3,16 @@ export const getTotalActionCount = (type, comment) => {
return 0;
}
return comment.action_summaries.reduce((total, summary) => {
if (summary.__typename === type) {
return comment.action_summaries
.filter(s => s.__typename === type)
.reduce((total, summary) => {
return total + summary.count;
} else {
return total;
}
}, 0);
}, 0);
};
export const iPerformedThisAction = (type, comment) => {
if (!comment.action_summaries) {
return 0;
return false;
}
// if there is a current_user on any of the ActionSummary(s), the user performed this action
@@ -23,6 +21,16 @@ export const iPerformedThisAction = (type, comment) => {
.some(a => a.current_user);
};
export const getMyActionSummary = (type, comment) => {
if (!comment.action_summaries) {
return null;
}
return comment.action_summaries
.filter(a => a.__typename === type)
.find(a => a.current_user);
};
/**
* getActionSummary
* retrieves the action summaries based on the type and the comment