mirror of
https://github.com/Myxelium/Bridge-Multi.git
synced 2026-04-15 15:40:35 +00:00
Fixed "download all charts for each song" button
This commit is contained in:
@@ -84,8 +84,8 @@ export class StatusBarComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
downloadAllCharts() {
|
downloadAllCharts() {
|
||||||
const chartGroups = groupBy(this.batchResults, 'chartID')
|
const songChartGroups = groupBy(this.batchResults, 'songID', 'chartID')
|
||||||
for (const chart of chartGroups) {
|
for (const chart of songChartGroups) {
|
||||||
this.searchService.sortChart(chart)
|
this.searchService.sortChart(chart)
|
||||||
const downloadVersion = chart[0]
|
const downloadVersion = chart[0]
|
||||||
const downloadSong = this.selectedResults.find(song => song.id == downloadVersion.songID)
|
const downloadSong = this.selectedResults.find(song => song.id == downloadVersion.songID)
|
||||||
|
|||||||
@@ -35,12 +35,12 @@ export function interpolate(val: number, fromStart: number, fromEnd: number, toS
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns `objectList` split into multiple arrays, where each array contains the objects with matching `key` values.
|
* @returns `objectList` split into multiple groups, where each group contains objects where every one of its values in `keys` matches.
|
||||||
*/
|
*/
|
||||||
export function groupBy<T>(objectList: T[], key: keyof T) {
|
export function groupBy<T>(objectList: T[], ...keys: (keyof T)[]) {
|
||||||
const results: T[][] = []
|
const results: T[][] = []
|
||||||
for (const object of objectList) {
|
for (const object of objectList) {
|
||||||
const matchingGroup = results.find(result => result[0][key] == object[key])
|
const matchingGroup = results.find(result => keys.every(key => result[0][key] == object[key]))
|
||||||
if (matchingGroup != undefined) {
|
if (matchingGroup != undefined) {
|
||||||
matchingGroup.push(object)
|
matchingGroup.push(object)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user