Skip to content

fix : Issue#754 #755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions apps/web/components/ContentSearch.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use client";
import { useEffect, useRef, useState, useDeferredValue } from "react";
import { useEffect, useRef, useState, useDeferredValue, useMemo } from "react";
import Link from "next/link";
import { Cross2Icon, MagnifyingGlassIcon } from "@radix-ui/react-icons";
import { Dialog, DialogClose, DialogContent, Input, Card, CardDescription, CardHeader, CardTitle } from "@repo/ui";
Expand Down Expand Up @@ -45,11 +45,15 @@ export function ContentSearch({ tracks }: { tracks: TrackPros[] }) {
});
setAllTracks(updatedTracks);
}, []);
useEffect(() => {
const fuse = new Fuse(allTracks, {

// Memoize to avoid unnecessary re-computation
const fuse = useMemo(() => {
return new Fuse(allTracks, {
keys: ["payload.problemTitle"],
});
}, [allTracks]);

useEffect(() => {
async function fetchSearchResults() {
if (deferredInput.length > 0) {
/* const data = await getSearchResults(deferredInput); */
Expand All @@ -61,7 +65,7 @@ export function ContentSearch({ tracks }: { tracks: TrackPros[] }) {
}
}
fetchSearchResults();
}, [deferredInput]);
}, [deferredInput , fuse]);

useEffect(() => {
const handleKeyPress = (event: KeyboardEvent) => {
Expand Down
Empty file removed yarn.lock
Empty file.