-
+
-
{{charterPlural}} {{selectedVersion?.charters}}
-
Tags: {{selectedVersion.tags}}
-
Audio Length: {{getSongLength()}}
+
{{charterPlural}} {{selectedVersion.charters}}
+
Tags: {{selectedVersion.tags}}
+
Audio Length: {{songLength}}
\ No newline at end of file
diff --git a/src/app/components/browse/chart-sidebar/chart-sidebar.component.ts b/src/app/components/browse/chart-sidebar/chart-sidebar.component.ts
index 7ba4826..454156d 100644
--- a/src/app/components/browse/chart-sidebar/chart-sidebar.component.ts
+++ b/src/app/components/browse/chart-sidebar/chart-sidebar.component.ts
@@ -15,38 +15,43 @@ export class ChartSidebarComponent {
private songResult: SongResult
selectedVersion: VersionResult
- charterPlural: string
- albumArtBuffer: Buffer
-
charts: VersionResult[][]
constructor(private electronService: ElectronService, private albumArtService: AlbumArtService, private downloadService: DownloadService) { }
+ /**
+ * Displays the information for the selected song.
+ */
async onRowClicked(result: SongResult) {
- this.songResult = result
- const albumArt = this.albumArtService.getImage(result.id)
- const results = await this.electronService.invoke('song-details', result.id)
+ if (this.songResult == undefined || result.id != this.songResult.id) { // Clicking the same row again will not reload
+ this.songResult = result
+ 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.charts.forEach(chart => chart.sort((v1, v2) => v2.lastModified - v1.lastModified))
+ await this.selectChart(0)
+ this.initChartDropdown()
- this.charts = groupBy(results, 'chartID')
- this.initChartDropdown()
-
- this.albumArtBuffer = await albumArt
+ this.updateAlbumArtSrc(await albumArt)
+ }
}
- getAlbumArtSrc() {
- if (this.albumArtBuffer) {
- return 'data:image/jpg;base64,' + this.albumArtBuffer.toString('base64')
+ albumArtSrc = ''
+ /**
+ * Updates the sidebar to display the album art.
+ */
+ updateAlbumArtSrc(albumArtBuffer?: Buffer) {
+ if (albumArtBuffer) {
+ this.albumArtSrc = 'data:image/jpg;base64,' + albumArtBuffer.toString('base64')
} else {
- return ''
+ this.albumArtSrc = ''
}
}
/**
- * Initializes the chart dropdown from