Skip to content

Commit

Permalink
fix(Post): e6/e9 getting score: NaN when total === 0, minor type fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AtoraSuunva committed Aug 3, 2022
1 parent 1ed9a97 commit 7216e1a
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/structures/Post.ts
Expand Up @@ -75,7 +75,7 @@ function getTags(data: any): string[] {
tags = Object.values<string>(data.tags).reduce(
(acc: string[], v) => (acc = acc.concat(v)),
[],
)
) as string[]
} else if (typeof data.tags === 'string') {
tags = fromTagString(data.tags)
} else if (typeof data.tag_string === 'string') {
Expand Down Expand Up @@ -229,9 +229,7 @@ export default class Post {
this.id = data.id ? data.id.toString() : 'No ID available'
this.tags = getTags(data)

// Too long for conditional
// eslint-disable-next-line
if (data.score && data.score.total) {
if (data.score && data.score.total !== undefined) {
this.score = data.score.total
} else {
this.score = data.score ? parseInt(data.score, 10) : data.score
Expand Down

0 comments on commit 7216e1a

Please sign in to comment.