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

View file

@ -38,7 +38,7 @@
</ScreenHeader> </ScreenHeader>
<SongListSkeleton v-if="loading"/> <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"> <section v-if="!loading && useLastfm && showingInfo" class="info-wrapper">
<CloseModalBtn class="close-modal" @click="showingInfo = false"/> <CloseModalBtn class="close-modal" @click="showingInfo = false"/>
@ -82,6 +82,7 @@ const {
showingControls, showingControls,
isPhone, isPhone,
duration, duration,
sort,
onPressEnter, onPressEnter,
playAll, playAll,
playSelected, playSelected,

View file

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