From e3277f14ad7e01db2730978aaf38d01489de19fe Mon Sep 17 00:00:00 2001 From: alex-phillips Date: Wed, 23 Mar 2016 10:07:50 -0400 Subject: [PATCH] added multiple methods to retrieve the 'track' from a file, set default sorting on the song lists --- app/Models/File.php | 13 ++++++++++--- resources/assets/js/components/shared/song-list.vue | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/Models/File.php b/app/Models/File.php index 8f8821b6..0f3952a6 100644 --- a/app/Models/File.php +++ b/app/Models/File.php @@ -98,12 +98,19 @@ class File return; } - $track = array_get($info, 'comments.track_number', [0])[0]; + $track = 0; + $trackIndices = [ + 'comments.track', + 'comments.tracknumber', + 'comments.track_number', + ]; + for ($i = 0; $i < count($trackIndices) && $track === 0; $i++) { + $track = array_get($info, $trackIndices[$i], [0])[0]; + } if (preg_match('#(\d+)/#', $track, $matches)) { $track = $matches[1]; - } elseif ((int) $track) { - $track = (int) $track; } + $track = (int) $track; $props = [ 'artist' => '', diff --git a/resources/assets/js/components/shared/song-list.vue b/resources/assets/js/components/shared/song-list.vue index 65885589..5d7ae37a 100644 --- a/resources/assets/js/components/shared/song-list.vue +++ b/resources/assets/js/components/shared/song-list.vue @@ -82,7 +82,7 @@ return { lastSelectedRow: null, q: '', // The filter query - sortKey: this.type === 'top-songs' ? 'playCount' : '', + sortKey: this.type === 'top-songs' ? 'playCount' : ['album.artist.name', 'album.name', 'track'], order: this.type === 'top-songs' ? -1 : 1, componentCache: {}, };