mirror of
https://github.com/osukey/osukey.git
synced 2025-08-08 09:03:50 +09:00
Clean up cancellation logic
This commit is contained in:
@ -122,6 +122,7 @@ namespace osu.Game.Overlays.BeatmapListing
|
|||||||
{
|
{
|
||||||
if (beatmapListingPager == null || !beatmapListingPager.CanFetchNextPage)
|
if (beatmapListingPager == null || !beatmapListingPager.CanFetchNextPage)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (queryPagingDebounce != null)
|
if (queryPagingDebounce != null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -132,14 +133,15 @@ namespace osu.Game.Overlays.BeatmapListing
|
|||||||
{
|
{
|
||||||
SearchStarted?.Invoke();
|
SearchStarted?.Invoke();
|
||||||
|
|
||||||
beatmapListingPager?.Reset();
|
cancelSearch();
|
||||||
|
|
||||||
queryChangedDebounce?.Cancel();
|
|
||||||
queryChangedDebounce = Scheduler.AddDelayed(updateSearch, queryTextChanged ? 500 : 100);
|
queryChangedDebounce = Scheduler.AddDelayed(updateSearch, queryTextChanged ? 500 : 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSearch()
|
private void updateSearch()
|
||||||
{
|
{
|
||||||
|
cancelSearch();
|
||||||
|
|
||||||
beatmapListingPager = new BeatmapListingPager(
|
beatmapListingPager = new BeatmapListingPager(
|
||||||
api,
|
api,
|
||||||
rulesets,
|
rulesets,
|
||||||
@ -150,13 +152,20 @@ namespace osu.Game.Overlays.BeatmapListing
|
|||||||
sortControl.SortDirection.Value
|
sortControl.SortDirection.Value
|
||||||
);
|
);
|
||||||
|
|
||||||
queryPagingDebounce?.Cancel();
|
|
||||||
queryPagingDebounce = null;
|
|
||||||
beatmapListingPager.PageFetched += onSearchFinished;
|
beatmapListingPager.PageFetched += onSearchFinished;
|
||||||
|
|
||||||
ShowMore();
|
ShowMore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void cancelSearch()
|
||||||
|
{
|
||||||
|
beatmapListingPager?.Reset();
|
||||||
|
queryChangedDebounce?.Cancel();
|
||||||
|
|
||||||
|
queryPagingDebounce?.Cancel();
|
||||||
|
queryPagingDebounce = null;
|
||||||
|
}
|
||||||
|
|
||||||
private void onSearchFinished(List<BeatmapSetInfo> beatmaps)
|
private void onSearchFinished(List<BeatmapSetInfo> beatmaps)
|
||||||
{
|
{
|
||||||
queryPagingDebounce = Scheduler.AddDelayed(() => queryPagingDebounce = null, 1000);
|
queryPagingDebounce = Scheduler.AddDelayed(() => queryPagingDebounce = null, 1000);
|
||||||
@ -171,9 +180,7 @@ namespace osu.Game.Overlays.BeatmapListing
|
|||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
beatmapListingPager?.Reset();
|
cancelSearch();
|
||||||
queryChangedDebounce?.Cancel();
|
|
||||||
queryPagingDebounce?.Cancel();
|
|
||||||
|
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user