Skip to content

Commit

Permalink
Fix: Intersection breaking with more than 2 collections selected
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotrekol committed Apr 16, 2021
1 parent e4dadd7 commit 1155afc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion App/CollectionEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void EditCollection(CollectionEditArgs e)
if (e.Collections.Count < 2)
return;

var newCollection = new Collection(_mapCacher) { Name = GetValidCollectionName(e.Collections[0].Name) };
var newCollection = new Collection(_mapCacher) { Name = GetValidCollectionName(e.NewName) };
e.Collections.Add(newCollection);
}
else if (e.Action == CollectionEdit.Duplicate)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,15 @@ private void EditCollection(CollectionEditArgs args, bool suspendRefresh = false
args.Collections.RemoveAt(args.Collections.Count - 1);
var mainCollection = args.Collections[0];
args.Collections.RemoveAt(0);

var beatmaps = mainCollection.AllBeatmaps().ToList();
foreach (var collection in args.Collections)
{
foreach (var beatmap in mainCollection.AllBeatmaps().Intersect(collection.AllBeatmaps(), new CollectionBeatmapComparer()))
{
targetCollection.AddBeatmap(beatmap);
}
beatmaps = beatmaps.Intersect(collection.AllBeatmaps(), new CollectionBeatmapComparer()).ToList();
}

foreach (var beatmap in beatmaps)
{
targetCollection.AddBeatmap(beatmap);
}

EditCollection(CollectionEditArgs.AddCollections(new Collections() { targetCollection }), true);
Expand Down

0 comments on commit 1155afc

Please sign in to comment.