private void performRequest() { getSetsRequest = new SearchBeatmapSetsRequest( searchControl.Query.Value, searchControl.Ruleset.Value, lastResponse?.Cursor, searchControl.Category.Value, sortControl.Current.Value, sortControl.SortDirection.Value); getSetsRequest.Success += response => { var sets = response.BeatmapSets.Select(responseJson => responseJson.ToBeatmapSet(rulesets)).ToList(); if (sets.Count == 0) { noMoreResults = true; } lastResponse = response; getSetsRequest = null; SearchFinished?.Invoke(sets); }; api.Queue(getSetsRequest); }
private void recreatePanels(SearchBeatmapSetsResponse response) { if (response.Total == 0) { searchSection.BeatmapSet = null; LoadComponentAsync(new NotFoundDrawable(), addContentToPlaceholder); return; } var beatmaps = response.BeatmapSets.Select(r => r.ToBeatmapSet(rulesets)).ToList(); var newPanels = new FillFlowContainer <DirectPanel> { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Spacing = new Vector2(10), Alpha = 0, Margin = new MarginPadding { Vertical = 15 }, ChildrenEnumerable = beatmaps.Select <BeatmapSetInfo, DirectPanel>(b => new DirectGridPanel(b) { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, }) }; LoadComponentAsync(newPanels, loaded => { addContentToPlaceholder(loaded); searchSection.BeatmapSet = beatmaps.First(); }); }
private void onSearchFinished(SearchBeatmapSetsResponse response) { var beatmaps = response.BeatmapSets.Select(r => r.ToBeatmapSet(rulesets)).ToList(); searchControl.BeatmapSet = response.Total == 0 ? null : beatmaps.First(); SearchFinished?.Invoke(beatmaps); }
private void resetSearch() { noMoreResults = false; CurrentPage = 0; lastResponse = null; getSetsRequest?.Cancel(); getSetsRequest = null; queryChangedDebounce?.Cancel(); }
private void performRequest() { getSetsRequest = new SearchBeatmapSetsRequest( searchControl.Query.Value, searchControl.Ruleset.Value, lastResponse?.Cursor, searchControl.General, searchControl.Category.Value, sortControl.Current.Value, sortControl.SortDirection.Value, searchControl.Genre.Value, searchControl.Language.Value, searchControl.Extra, searchControl.Ranks, searchControl.Played.Value, searchControl.ExplicitContent.Value); getSetsRequest.Success += response => { var sets = response.BeatmapSets.Select(responseJson => responseJson.ToBeatmapSet(rulesets)).ToList(); if (sets.Count == 0) { noMoreResults = true; } if (CurrentPage == 0) { searchControl.BeatmapSet = sets.FirstOrDefault(); } lastResponse = response; getSetsRequest = null; SearchFinished?.Invoke(sets); }; api.Queue(getSetsRequest); }
private void performRequest() { getSetsRequest = new SearchBeatmapSetsRequest( searchControl.Query.Value, searchControl.Ruleset.Value, lastResponse?.Cursor, searchControl.General, searchControl.Category.Value, sortControl.Current.Value, sortControl.SortDirection.Value, searchControl.Genre.Value, searchControl.Language.Value, searchControl.Extra, searchControl.Ranks, searchControl.Played.Value, searchControl.ExplicitContent.Value); getSetsRequest.Success += response => { var sets = response.BeatmapSets.ToList(); // If the previous request returned a null cursor, the API is indicating we can't paginate further (maybe there are no more beatmaps left). if (sets.Count == 0 || response.Cursor == null) { noMoreResults = true; } if (CurrentPage == 0) { searchControl.BeatmapSet = sets.FirstOrDefault(); } lastResponse = response; getSetsRequest = null; // check if a non-supporter used supporter-only filters if (!api.LocalUser.Value.IsSupporter) { List <LocalisableString> filters = new List <LocalisableString>(); if (searchControl.Played.Value != SearchPlayed.Any) { filters.Add(BeatmapsStrings.ListingSearchFiltersPlayed); } if (searchControl.Ranks.Any()) { filters.Add(BeatmapsStrings.ListingSearchFiltersRank); } if (filters.Any()) { SearchFinished?.Invoke(SearchResult.SupporterOnlyFilters(filters)); return; } } SearchFinished?.Invoke(SearchResult.ResultsReturned(sets)); }; api.Queue(getSetsRequest); }