Last active
November 23, 2017 10:44
-
-
Save sdwvit/eec96b9b31160ff1a0c828465a764093 to your computer and use it in GitHub Desktop.
Holy clean code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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