mirror of
https://github.com/wassname/talk.git
synced 2026-08-07 11:29:44 +08:00
fix RespectButton component code
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user