Skip to content

Instantly share code, notes, and snippets.

@sdwvit

sdwvit/cc.ts

Last active Nov 23, 2017
Embed
What would you like to do?
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