Skip to content

Commit

Permalink
feat: check for inNaN moved to helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoverth committed Sep 19, 2024
1 parent ef910f3 commit 57f251d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/renderer/helpers/playlists.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,16 @@ function compareTwoPlaylistItems(a, b, sortOrder, collator) {
return collator.compare(a.author, b.author)
case SORT_BY_VALUES.AuthorDescending:
return collator.compare(b.author, a.author)
case SORT_BY_VALUES.VideoLengthAscending:
return a.lengthSeconds - b.lengthSeconds
case SORT_BY_VALUES.VideoLengthDescending:
return b.lengthSeconds - a.lengthSeconds
case SORT_BY_VALUES.VideoLengthAscending: {
const aLengthForSort = (isNaN(a.lengthSeconds) || a.lengthSeconds === 0) ? 0 : a.lengthSeconds
const bLengthForSort = (isNaN(b.lengthSeconds) || b.lengthSeconds === 0) ? 0 : b.lengthSeconds
return aLengthForSort - bLengthForSort
}
case SORT_BY_VALUES.VideoLengthDescending: {
const aLengthForSort = (isNaN(a.lengthSeconds) || a.lengthSeconds === 0) ? 0 : a.lengthSeconds
const bLengthForSort = (isNaN(b.lengthSeconds) || b.lengthSeconds === 0) ? 0 : b.lengthSeconds
return bLengthForSort - aLengthForSort
}
default:
console.error(`Unknown sortOrder: ${sortOrder}`)
return 0
Expand Down

0 comments on commit 57f251d

Please sign in to comment.