Skip to content

Commit

Permalink
Merge branch 'main' of github.com:hydralauncher/hydra into feat/addin…
Browse files Browse the repository at this point in the history
…g-game-to-library-without-downloading
  • Loading branch information
thegrannychaseroperation committed Apr 16, 2024
2 parents c4a71e8 + 3246f3c commit d126b5c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
6 changes: 5 additions & 1 deletion src/renderer/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ export function App() {
return;
}

navigate(`/search/${query}`, {
const searchParams = new URLSearchParams({
query,
});

navigate(`/search?${searchParams.toString()}`, {
replace: location.pathname.startsWith("/search"),
});
},
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const router = createHashRouter([
Component: GameDetails,
},
{
path: "/search/:query",
path: "/search",
Component: SearchResults,
},
{
Expand Down
12 changes: 6 additions & 6 deletions src/renderer/pages/catalogue/search-results.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import { useAppDispatch } from "@renderer/hooks";
import { vars } from "@renderer/theme.css";
import { useEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import { useNavigate, useParams } from "react-router-dom";
import { useNavigate, useSearchParams } from "react-router-dom";
import * as styles from "./catalogue.css";

export function SearchResults() {
const dispatch = useAppDispatch();

const { t } = useTranslation("catalogue");
const { query } = useParams();
const [searchParams] = useSearchParams();

const [searchResults, setSearchResults] = useState<CatalogueEntry[]>([]);
const [isLoading, setIsLoading] = useState(false);
Expand All @@ -39,7 +39,7 @@ export function SearchResults() {

debouncedFunc.current = debounce(() => {
window.electron
.searchGames(query)
.searchGames(searchParams.get("query"))
.then((results) => {
setSearchResults(results);
})
Expand All @@ -49,11 +49,11 @@ export function SearchResults() {
}, 300);

debouncedFunc.current();
}, [query, dispatch]);
}, [searchParams, dispatch]);

return (
<SkeletonTheme baseColor={vars.color.background} highlightColor="#444">
<main className={styles.content}>
<section className={styles.content}>
<section className={styles.cards({ searching: false })}>
{isLoading &&
Array.from({ length: 12 }).map((_, index) => (
Expand Down Expand Up @@ -81,7 +81,7 @@ export function SearchResults() {
<p>{t("no_results")}</p>
</div>
)}
</main>
</section>
</SkeletonTheme>
);
}

0 comments on commit d126b5c

Please sign in to comment.