mirror of
https://github.com/ppy/osu.git
synced 2026-06-03 13:44:34 +08:00
Merge pull request #33049 from peppy/carousel-manifest-filters
Ensure carousel filters are manifested to lists at each step
This commit is contained in:
@@ -265,7 +265,7 @@ namespace osu.Game.Graphics.Carousel
|
||||
|
||||
// Copy must be performed on update thread for now (see ConfigureAwait above).
|
||||
// Could potentially be optimised in the future if it becomes an issue.
|
||||
IEnumerable<CarouselItem> items = new List<CarouselItem>(Items.Select(m => new CarouselItem(m)));
|
||||
List<CarouselItem> items = new List<CarouselItem>(Items.Select(m => new CarouselItem(m)));
|
||||
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
@@ -275,6 +275,11 @@ namespace osu.Game.Graphics.Carousel
|
||||
{
|
||||
log($"Performing {filter.GetType().ReadableName()}");
|
||||
items = await filter.Run(items, cts.Token).ConfigureAwait(false);
|
||||
|
||||
// To avoid shooting ourselves in the foot, ensure that we manifest a list after each filter.
|
||||
//
|
||||
// A future improvement may be passing a reference list through each filter rather than copying each time,
|
||||
// but this is the safest approach.
|
||||
}
|
||||
|
||||
log("Updating Y positions");
|
||||
@@ -292,7 +297,7 @@ namespace osu.Game.Graphics.Carousel
|
||||
Schedule(() =>
|
||||
{
|
||||
log("Items ready for display");
|
||||
carouselItems = items.ToList();
|
||||
carouselItems = items;
|
||||
displayedRange = null;
|
||||
|
||||
// Need to call this to ensure correct post-selection logic is handled on the new items list.
|
||||
|
||||
@@ -18,6 +18,6 @@ namespace osu.Game.Graphics.Carousel
|
||||
/// <param name="items">The items to be filtered.</param>
|
||||
/// <param name="cancellationToken">A cancellation token.</param>
|
||||
/// <returns>The post-filtered items.</returns>
|
||||
Task<IEnumerable<CarouselItem>> Run(IEnumerable<CarouselItem> items, CancellationToken cancellationToken);
|
||||
Task<List<CarouselItem>> Run(IEnumerable<CarouselItem> items, CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace osu.Game.Screens.SelectV2
|
||||
this.getCriteria = getCriteria;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<CarouselItem>> Run(IEnumerable<CarouselItem> items, CancellationToken cancellationToken)
|
||||
public async Task<List<CarouselItem>> Run(IEnumerable<CarouselItem> items, CancellationToken cancellationToken)
|
||||
{
|
||||
return await Task.Run(() =>
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace osu.Game.Screens.SelectV2
|
||||
this.getCriteria = getCriteria;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<CarouselItem>> Run(IEnumerable<CarouselItem> items, CancellationToken cancellationToken) => await Task.Run(() =>
|
||||
public async Task<List<CarouselItem>> Run(IEnumerable<CarouselItem> items, CancellationToken cancellationToken) => await Task.Run(() =>
|
||||
{
|
||||
var criteria = getCriteria();
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace osu.Game.Screens.SelectV2
|
||||
}
|
||||
|
||||
return comparison;
|
||||
}));
|
||||
})).ToList();
|
||||
}, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user