From 09efc05192be3e35dff58f10a185afb52cd5b481 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20Sch=C3=BCrz?= Date: Mon, 6 Jan 2025 14:30:56 +0100 Subject: [PATCH] Filter out non-std maps in search results --- .../src/screens/home/HomeScreen.ts | 48 ++++++++++--------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/packages/beatmap-viewer/src/screens/home/HomeScreen.ts b/packages/beatmap-viewer/src/screens/home/HomeScreen.ts index a83230c3..d1a11bca 100644 --- a/packages/beatmap-viewer/src/screens/home/HomeScreen.ts +++ b/packages/beatmap-viewer/src/screens/home/HomeScreen.ts @@ -69,7 +69,9 @@ export class HomeScreen extends OsucadScreen { #hero!: SearchHero; updateResults(results: BeatmapSetResponse[]) { - this.beatmaps.value = results.map(mapset => this.createMapsetInfo(mapset)); + this.beatmaps.value = results + .map(mapset => this.createMapsetInfo(mapset)) + .filter(it => it.beatmaps.length > 0); this.#hero.minimize(); } @@ -97,27 +99,29 @@ export class HomeScreen extends OsucadScreen { }, }; - carouselMapsetInfo.beatmaps = mapset.beatmaps.map((beatmap) => { - const { id, version, difficulty_rating } = beatmap; - - return { - id: id.toString(), - artist, - title, - audioUrl: '', - authorName: creator, - difficultyName: version, - backgroundPath: async () => null, - lastEdited: null, - loadThumbnailLarge: async () => carouselMapsetInfo.loadThumbnailLarge(), - loadThumbnailSmall: async () => carouselMapsetInfo.loadThumbnailSmall(), - mapset: carouselMapsetInfo, - previewPoint: null, - setId: mapset.id.toString(), - starRating: difficulty_rating, - select: async () => this.openEditor(mapset, beatmap), - }; - }); + carouselMapsetInfo.beatmaps = mapset.beatmaps + .filter(it => it.mode_int === 0) + .map((beatmap) => { + const { id, version, difficulty_rating } = beatmap; + + return { + id: id.toString(), + artist, + title, + audioUrl: '', + authorName: creator, + difficultyName: version, + backgroundPath: async () => null, + lastEdited: null, + loadThumbnailLarge: async () => carouselMapsetInfo.loadThumbnailLarge(), + loadThumbnailSmall: async () => carouselMapsetInfo.loadThumbnailSmall(), + mapset: carouselMapsetInfo, + previewPoint: null, + setId: mapset.id.toString(), + starRating: difficulty_rating, + select: async () => this.openEditor(mapset, beatmap), + }; + }); return carouselMapsetInfo; }