fix: properly sort album/artist songs (closes #1486)

This commit is contained in:
Phan An 2022-09-16 19:10:09 +07:00
parent f0d792c65f
commit 25c9da4c82
No known key found for this signature in database
GPG key ID: A81E4477F0BB6FDC
3 changed files with 9 additions and 5 deletions

View file

@ -38,7 +38,7 @@
</ScreenHeader>
<SongListSkeleton v-if="loading"/>
<SongList v-else ref="songList" @press:enter="onPressEnter" @scroll-breakpoint="onScrollBreakpoint"/>
<SongList v-else ref="songList" @sort="sort" @press:enter="onPressEnter" @scroll-breakpoint="onScrollBreakpoint"/>
<section v-if="!loading && useLastfm && showingInfo" class="info-wrapper">
<CloseModalBtn class="close-modal" @click="showingInfo = false"/>
@ -85,6 +85,7 @@ const {
showingControls,
isPhone,
duration,
sort,
onPressEnter,
playAll,
playSelected,
@ -110,6 +111,8 @@ onMounted(async () => {
albumStore.resolve(id.value),
songStore.fetchForAlbum(id.value)
])
sort('track')
} catch (e) {
logger.error(e)
dialog.value.error('Failed to load album. Please try again.')

View file

@ -38,7 +38,7 @@
</ScreenHeader>
<SongListSkeleton v-if="loading"/>
<SongList v-else ref="songList" @press:enter="onPressEnter" @scroll-breakpoint="onScrollBreakpoint"/>
<SongList v-else ref="songList" @sort="sort" @press:enter="onPressEnter" @scroll-breakpoint="onScrollBreakpoint"/>
<section v-if="!loading && useLastfm && showingInfo" class="info-wrapper">
<CloseModalBtn class="close-modal" @click="showingInfo = false"/>
@ -82,6 +82,7 @@ const {
showingControls,
isPhone,
duration,
sort,
onPressEnter,
playAll,
playSelected,

View file

@ -81,11 +81,11 @@ export const useSongList = (songs: Ref<Song[]>, type: SongListType, config: Part
let sortFields: SongListSortField[] = [by]
if (by === 'track') {
sortFields.push('disc', 'title')
sortFields = ['disc', 'track', 'title']
} else if (by === 'album_name') {
sortFields.push('artist_name', 'track', 'disc', 'title')
sortFields.push('artist_name', 'disc', 'track', 'title')
} else if (by === 'artist_name') {
sortFields.push('album_name', 'track', 'disc', 'title')
sortFields.push('album_name', 'disc', 'track', 'title')
}
songs.value = orderBy(songs.value, sortFields, order)