Skip to content

Commit

Permalink
Update to use sortOrder as main variable throughout
Browse files Browse the repository at this point in the history
  • Loading branch information
kommunarr committed Apr 11, 2024
1 parent b2b77eb commit 10aac78
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/renderer/views/Playlist/Playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ export default defineComponent({
userPlaylistSortOrder: function () {
return this.$store.getters.getUserPlaylistSortOrder
},
sortOrder: function () {
return this.isUserPlaylistRequested ? this.userPlaylistSortOrder : SORT_BY_VALUES.Custom
},
currentLocale: function () {
return this.$i18n.locale.replace('_', '-')
},
Expand Down Expand Up @@ -170,15 +173,15 @@ export default defineComponent({
return Object.values(SORT_BY_VALUES)
},
isSortOrderCustom() {
return this.userPlaylistSortOrder === SORT_BY_VALUES.Custom
return this.sortOrder === SORT_BY_VALUES.Custom
},
sortedPlaylistItems: function () {
if (this.userPlaylistSortOrder === SORT_BY_VALUES.Custom) {
if (this.sortOrder === SORT_BY_VALUES.Custom) {
return this.playlistItems
}

return this.playlistItems.toSorted((a, b) => {
switch (this.userPlaylistSortOrder) {
switch (this.sortOrder) {
case SORT_BY_VALUES.DateAddedNewest:
return b.timeAdded - a.timeAdded
case SORT_BY_VALUES.DateAddedOldest:
Expand All @@ -192,7 +195,7 @@ export default defineComponent({
case SORT_BY_VALUES.AuthorDescending:
return b.author.localeCompare(a.author, this.currentLocale)
default:
console.error(`Unknown sortOrder: ${this.userPlaylistSortOrder}`)
console.error(`Unknown sortOrder: ${this.sortOrder}`)
return 0
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/views/Playlist/Playlist.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<ft-select
v-if="isUserPlaylistRequested"
class="sortSelect"
:value="userPlaylistSortOrder"
:value="sortOrder"
:select-names="sortBySelectNames"
:select-values="sortBySelectValues"
:placeholder="$t('Playlist.Sort By.Sort By')"
Expand Down

0 comments on commit 10aac78

Please sign in to comment.