mirror of
https://github.com/Myxelium/Bridge-Multi.git
synced 2026-04-09 05:09:39 +00:00
Fixed "download all charts for each song" button
This commit is contained in:
@@ -84,8 +84,8 @@ export class StatusBarComponent {
|
||||
}
|
||||
|
||||
downloadAllCharts() {
|
||||
const chartGroups = groupBy(this.batchResults, 'chartID')
|
||||
for (const chart of chartGroups) {
|
||||
const songChartGroups = groupBy(this.batchResults, 'songID', 'chartID')
|
||||
for (const chart of songChartGroups) {
|
||||
this.searchService.sortChart(chart)
|
||||
const downloadVersion = chart[0]
|
||||
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[][] = []
|
||||
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) {
|
||||
matchingGroup.push(object)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user