added multiple methods to retrieve the 'track' from a file, set default sorting on the song lists

This commit is contained in:
alex-phillips 2016-03-23 10:07:50 -04:00
parent e5778d1896
commit e3277f14ad
2 changed files with 11 additions and 4 deletions

View file

@ -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' => '',

View file

@ -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: {},
};