refactor: reduce complexity

fix/workaround/#26
SukkaW 7 years ago
parent 28ae122eff
commit bec6c16ebe

@ -374,9 +374,8 @@
*/
let parseCommentData = (data) => {
let topLevelComments = [],
childComments = [];
let commentJSON = (comment) => {
childComments = [],
commentJSON = (comment) => {
return {
comment,
author: comment.author.name,
@ -384,7 +383,7 @@
isPrimary: (disqusjs.config.admin ? (comment.author.username === disqusjs.config.admin) : false),
children: getChildren(+comment.id)
}
}
};
let getChildren = (id) => {
// 如果没有子评论,就不需要解析子评论了
@ -399,11 +398,7 @@
}
}
if (list.length) {
return list;
} else {
return null;
}
return (list.length) ? list : null
}
data.forEach((comment) => {

Loading…
Cancel
Save