Improved version selection with chart packs

This commit is contained in:
Geomitron
2020-05-18 18:10:51 -04:00
parent 819c0ebff8
commit ebe22a39e9
3 changed files with 49 additions and 11 deletions

View File

@@ -43,8 +43,7 @@ export class ChartSidebarComponent implements OnInit {
const albumArt = this.albumArtService.getImage(result.id)
const results = await this.electronService.invoke('song-details', result.id)
this.charts = groupBy(results, 'chartID').sort((v1, v2) => v1[0].avTagName.length - v2[0].avTagName.length)
// This sorting is very inefficient, but there's rarely more than two or three in this list, so it's fine
this.charts.forEach(chart => chart.sort((v1, v2) => new Date(v2.lastModified).getTime() - new Date(v1.lastModified).getTime()))
this.sortCharts()
await this.selectChart(0)
this.initChartDropdown()
@@ -52,6 +51,19 @@ export class ChartSidebarComponent implements OnInit {
}
}
/**
* Sorts `this.charts` and its subarrays in the correct order.
* The chart dropdown should display in a random order, but verified charters are prioritized.
* The version dropdown should be ordered by lastModified date.
* (but prefer the non-pack version if it's only a few days older)
*/
private sortCharts() {
for (const chart of this.charts) {
// TODO: sort by verified charter
this.searchService.sortChart(chart)
}
}
albumArtSrc: SafeUrl = ''
/**
* Updates the sidebar to display the album art.