feat: search checksums in editablequest

This commit is contained in:
zkldi
2022-12-22 14:42:54 +00:00
parent 2cd8112c78
commit 1e83d6426f
2 changed files with 10 additions and 6 deletions
@@ -312,16 +312,20 @@ function ChartSelect({
// debounce this query to only run after 300ms of no more user input.
lastTimeout = window.setTimeout(async () => {
const res = await APIFetchV1<SongChartsSearch>(
`/games/${game}/${playtype}/charts?search=${input}`
`/games/${game}/${playtype}/charts?search=${encodeURIComponent(input)}`
);
if (!res.success) {
const res2 = await APIFetchV1<SongChartsSearch>(
`/search/chart-hash?search=${encodeURIComponent(input)}`
);
if (!res.success || !res2.success) {
throw new Error(res.description);
}
const songMap = CreateSongMap(res.body.songs);
const songMap = CreateSongMap([...res.body.songs, ...res2.body.songs]);
const options = res.body.charts.map((e) => ({
const options = [...res.body.charts, ...res2.body.charts].map((e) => ({
value: e.chartID,
label: FormatChart(game, songMap.get(e.songID)!, e),
}));
@@ -95,7 +95,7 @@ router.get("/", async (req, res) => {
*
* @note This matches MD5 and SHA256 for BMS/PMS, and SHA1 for USC.
*/
router.get("/chart-hash", RequireBokutachi, async (req, res) => {
router.get("/chart-hash", async (req, res) => {
if (!IsString(req.query.search)) {
return res.status(400).json({
success: false,
@@ -107,7 +107,7 @@ router.get("/chart-hash", RequireBokutachi, async (req, res) => {
return res.status(200).json({
success: true,
description: `Searched BMS, PMS and USC for ${req.query.search}.`,
description: `Searched for chart hash ${req.query.search}.`,
body: {
songs,
charts,