Skip to content

Instantly share code, notes, and snippets.

@christopherdro
Created December 11, 2015 06:01
Show Gist options
  • Save christopherdro/be6036d45d9834d400b7 to your computer and use it in GitHub Desktop.
Save christopherdro/be6036d45d9834d400b7 to your computer and use it in GitHub Desktop.
getDashboardCommentList = (comments) => {
return comments.reduce((previousValue, currentValue) => {
let commentDate = moment(currentValue.node.createdAt).startOf('day');
if (previousValue.indexOf(commentDate.toDate().valueOf()) === -1) {
previousValue.push(commentDate.toDate().valueOf());
}
return previousValue;
}, [])
.map((date) => {
return this.commentsForDay(new Date(date));
});;
}
commentsForDay = (day) => {
return this.props.viewer.allAnnotations.edges.filter((comment) => {
let commentDate = new Date(comment.node.createdAt);
return commentDate.getMonth() == day.getMonth() && commentDate.getDay() == day.getDay()
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment