From 994ef95f3be9fa00de586b85ee9b00976e0d51d4 Mon Sep 17 00:00:00 2001 From: zkldi <20380519+zkldi@users.noreply.github.com> Date: Tue, 31 Jan 2023 15:14:55 +0000 Subject: [PATCH] fix: goal infinite loading --- .../targets/AddNewGoalForQuestModal.tsx | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/client/src/components/targets/AddNewGoalForQuestModal.tsx b/client/src/components/targets/AddNewGoalForQuestModal.tsx index 65bcb6b8b..204f4c5f3 100644 --- a/client/src/components/targets/AddNewGoalForQuestModal.tsx +++ b/client/src/components/targets/AddNewGoalForQuestModal.tsx @@ -7,11 +7,15 @@ import Select from "components/util/Select"; import React, { useEffect, useState } from "react"; import { Button, Col, Form, InputGroup, Modal, Row } from "react-bootstrap"; import { + ChartDocument, FolderDocument, FormatChart, + GPTString, + GetGPTString, GetGamePTConfig, GetScoreMetricConf, GoalDocument, + SongDocument, } from "tachi-common"; import { SongChartsSearch } from "types/api-returns"; import { GamePT, SetState } from "types/react"; @@ -324,17 +328,25 @@ function ChartSelect({ `/games/${game}/${playtype}/charts?search=${encodeURIComponent(input)}` ); - const res2 = await APIFetchV1( - `/search/chart-hash?search=${encodeURIComponent(input)}` - ); + const res2 = await APIFetchV1<{ + charts: Record< + GPTString, + { + chart: ChartDocument; + song: SongDocument; + }[] + >; + }>(`/search/chart-hash?search=${encodeURIComponent(input)}`); if (!res.success || !res2.success) { throw new Error(res.description); } - const songMap = CreateSongMap([...res.body.songs, ...res2.body.songs]); + const res2Data = res2.body.charts[GetGPTString(game, playtype)] ?? []; - const options = [...res.body.charts, ...res2.body.charts].map((e) => ({ + const songMap = CreateSongMap([...res.body.songs, ...res2Data.map((e) => e.song)]); + + const options = [...res.body.charts, ...res2Data.map((e) => e.chart)].map((e) => ({ value: e.chartID, label: FormatChart(game, songMap.get(e.songID)!, e), }));