diff --git a/client/src/app/pages/dashboard/import/BeatorajaIRPage.tsx b/client/src/app/pages/dashboard/import/BeatorajaIRPage.tsx index 9bedc3b9d..78fff2125 100644 --- a/client/src/app/pages/dashboard/import/BeatorajaIRPage.tsx +++ b/client/src/app/pages/dashboard/import/BeatorajaIRPage.tsx @@ -15,8 +15,10 @@ popd const LINUX_SH = ` #!/bin/bash -export _JAVA_OPTIONS='-Dsun.java2d.opengl=true -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel -Dfile.encoding="UTF-8"' -java -Xms1g -Xmx4g -cp 'beatoraja.jar;ir/*' bms.player.beatoraja.MainLoader +export _JAVA_OPTIONS='-Dsun.java2d.opengl=true -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel' +cd "$(dirname "$0")" +exec java -Xms1g -Xmx4g -cp beatoraja.jar:ir/* bms.player.beatoraja.MainLoader + `; export default function BeatorajaIRPage() { diff --git a/client/src/components/layout/header/SearchBar.tsx b/client/src/components/layout/header/SearchBar.tsx index f09033145..c7f1bb4be 100644 --- a/client/src/components/layout/header/SearchBar.tsx +++ b/client/src/components/layout/header/SearchBar.tsx @@ -1,8 +1,9 @@ import Divider from "components/util/Divider"; import Icon from "components/util/Icon"; import Loading from "components/util/Loading"; +import { UserContext } from "context/UserContext"; import { TachiConfig } from "lib/config"; -import React, { useEffect, useMemo, useRef, useState } from "react"; +import React, { useContext, useEffect, useMemo, useRef, useState } from "react"; import { Link, useLocation } from "react-router-dom"; import { Game, GetGameConfig, integer, PublicUserDocument, SongDocument } from "tachi-common"; import { GamePT, JustChildren } from "types/react"; @@ -12,7 +13,7 @@ import { ConditionalLeadingSpace, PREVENT_DEFAULT } from "util/misc"; import QuickTooltip from "../misc/QuickTooltip"; interface SearchReturns { - users: PublicUserDocument[]; + users?: PublicUserDocument[]; songs: (SongDocument & { __textScore: number; game: Game })[]; } @@ -68,7 +69,7 @@ function GPTSearchResult({ } function SearchResults({ results }: { results: SearchReturns }) { - if (!results.users.length && !results.songs.length) { + if (!results.users?.length && !results.songs.length) { return (
Found nothing :( @@ -80,13 +81,17 @@ function SearchResults({ results }: { results: SearchReturns }) { // here's a hack. const params = useLocation<{ game?: Game; playtype?: Playtype }>(); - const { game, playtype } = useMemo(() => { + const { game, playtype, user } = useMemo(() => { const regexp = `/games/(${TachiConfig.games.join("|")})/[^/]*/?`; if (params.pathname.match(new RegExp(regexp, "u"))) { const hack = params.pathname.split("/games/")[1].split("/"); - return { game: hack[0] as Game, playtype: hack[1] as Playtype }; + return { + game: hack[0] as Game, + playtype: hack[1] as Playtype, + user: params.pathname.match(/\/dashboard\/users\/(.*?)\//u)?.[1], + }; } return { game: null, playtype: null }; @@ -94,14 +99,14 @@ function SearchResults({ results }: { results: SearchReturns }) { return (
- {results?.users.length ? ( + {results?.users?.length ? ( <>
Users
{results.users.map(u => - game && playtype ? ( + game && playtype && user ? ( { - APIFetchV1(`/search?search=${encodeURIComponent(closureSearch)}`).then( - r => { - if (r.success === false) { - console.error(r); + const searches = []; + + searches.push( + APIFetchV1(`/search?search=${encodeURIComponent(closureSearch)}`) + ); + + if (TachiConfig.type !== "ktchi") { + searches.push( + APIFetchV1( + `/search/chart-hash?search=${encodeURIComponent(closureSearch)}` + ) + ); + } + + Promise.all(searches).then(results => { + const setValue: SearchReturns = { + users: [], + songs: [], + }; + + for (const result of results) { + if (result.success === false) { + console.error(result); return; } - setResults(r.body); + setValue.songs.push(...result.body.songs); + setValue.users!.push(...(result.body.users ?? [])); } - ); + + setResults(setValue); + }); }, 250); setLastTimeout(handle);