Holy clean code
static checkComment(comment: Comment): void { | |
function resetCompactMode() { // TODO: props mutation is bad | |
comment.compactMode = false; | |
} | |
const parent = comment.compactMode && comment.parent; | |
if (!parent) { return; } | |
if (parent.level === 1 || parent.children.length > 1) { | |
resetCompactMode(); | |
} else { | |
if (!parent.parent) { return; } | |
if (parent.parent.userId !== comment.userId || parent.parent.children.length > 1) { | |
resetCompactMode(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment