refactor: reduce complexity

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

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

Loading…
Cancel
Save