refactor if into switch case
This commit is contained in:
parent
ced7b887d2
commit
747bc943a9
1 changed files with 22 additions and 18 deletions
|
@ -853,24 +853,28 @@ export function commentsToFlatNodes(comments: CommentView[]): CommentNodeI[] {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function convertCommentSortType(sort: SortType): CommentSortType {
|
export function convertCommentSortType(sort: SortType): CommentSortType {
|
||||||
if (
|
switch(sort) {
|
||||||
sort == "TopAll" ||
|
case "TopAll":
|
||||||
sort == "TopHour" ||
|
case "TopHour":
|
||||||
sort == "TopSixHour" ||
|
case "TopSixHour":
|
||||||
sort == "TopTwelveHour" ||
|
case "TopTwelveHour":
|
||||||
sort == "TopDay" ||
|
case "TopDay":
|
||||||
sort == "TopWeek" ||
|
case "TopWeek":
|
||||||
sort == "TopMonth" ||
|
case "TopMonth":
|
||||||
sort == "TopYear"
|
case "TopYear": {
|
||||||
) {
|
return "Top";
|
||||||
return "Top";
|
}
|
||||||
} else if (sort == "New") {
|
case "New": {
|
||||||
return "New";
|
return "New";
|
||||||
} else if (sort == "Hot" || sort == "Active") {
|
}
|
||||||
return "Hot";
|
case "Hot":
|
||||||
} else {
|
case "Active": {
|
||||||
return "Hot";
|
return "Hot";
|
||||||
}
|
}
|
||||||
|
default: {
|
||||||
|
return "Hot";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function buildCommentsTree(
|
export function buildCommentsTree(
|
||||||
|
|
Loading…
Reference in a new issue