@@ -207,26 +207,40 @@ export class BanchoClient extends BaseClient {
207207 }
208208
209209 let { beatmapsets } = result . data ;
210- let additionalBeatmapsets : BanchoBeatmapset [ ] = [ ] ;
211210
212211 if ( ctx . limit && ctx . limit <= BEATMAPS_SEARCH_MAX_RESULTS_LIMIT ) {
213212 if ( ctx . limit < BANCHO_SEARCH_PAGE_SIZE ) {
214213 beatmapsets = beatmapsets . slice ( 0 , ctx . limit ) ;
215214 }
216215
217216 if ( ctx . limit > BANCHO_SEARCH_PAGE_SIZE && page < BANCHO_SEARCH_PAGES_LIMIT ) {
218- additionalBeatmapsets = await this . searchBeatmapsets ( {
219- ...ctx ,
220- limit : ctx . limit - beatmapsets . length ,
221- offset : ( ctx . offset ?? 0 ) + beatmapsets . length ,
222- } ) . then ( result => result . result ?? [ ] ) ;
217+ const resultForAdditionalBeatmaps = await this . api . get < BanchoBeatmapsetSearchResult > ( `api/v2/beatmapsets/search` , {
218+ config : {
219+ headers : {
220+ Authorization : `Bearer ${ await this . osuApiKey } ` ,
221+ } ,
222+ params : {
223+ q : ctx . query ,
224+ page : page + 1 ,
225+ s : ctx . status ? ctx . status . map ( status => this . mapStatusToRankStatus ( status ) . toString ( ) ) : undefined ,
226+ m : ctx . mode ,
227+ nsfw : true , // TODO: Maybe make this configurable?
228+ } ,
229+ paramsSerializer : params =>
230+ qs . stringify ( params , { indices : false } ) ,
231+ } ,
232+ } ) ;
233+
234+ if ( resultForAdditionalBeatmaps && resultForAdditionalBeatmaps . status === 200 && resultForAdditionalBeatmaps . data ) {
235+ beatmapsets = beatmapsets . concat ( resultForAdditionalBeatmaps . data . beatmapsets . slice ( 0 , ctx . limit - BANCHO_SEARCH_PAGE_SIZE ) ) ;
236+ }
223237 }
224238 }
225239
226240 return {
227- result : [ ... additionalBeatmapsets , ... ( beatmapsets . map ( ( b : BanchoBeatmapset ) =>
241+ result : beatmapsets . map ( ( b : BanchoBeatmapset ) =>
228242 this . convertService . convertBeatmapset ( b ) ,
229- ) ) ] ,
243+ ) ,
230244 status : result . status ,
231245 } ;
232246 }
0 commit comments