Skip to content

Commit

Permalink
fix: suspense fallback and query param on initial visit
Browse files Browse the repository at this point in the history
  • Loading branch information
CahidArda committed Jan 6, 2025
1 parent 5c6aa32 commit db97e26
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
14 changes: 11 additions & 3 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from "@/components/primitive/tabs";
import Container from "@/components/container";
import { BorderBox } from "@/components/border-box";
import { IconBrandOpenai } from "@tabler/icons-react";
import { IconBrandOpenai, IconLoader2 } from "@tabler/icons-react";

export default function Page() {
const [tab, setTab] = useState<"chat" | "search">("search");
Expand Down Expand Up @@ -66,9 +66,17 @@ export default function Page() {

<TabsContent value="search" className="">
<div className="py-6 sm:py-8">
<Suspense fallback="Loadings...">
<Suspense
fallback={
<IconLoader2
className="animate-spin flex w-full justify-center text-emerald-400"
role="status"
/>
}
>
<SearchTab />
</Suspense>
</Suspense>{" "}
*/
</div>
</TabsContent>
<TabsContent value="chat">
Expand Down
7 changes: 3 additions & 4 deletions src/components/search/search-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@ export const SearchTab = () => {
if (!isInitial) return;
setIsInitial(false);
if (searchParam.query) {
console.log("in");
setSearch(searchParam.query);
} else {
console.log("out", searchParam);

const query = "Who are the founders of internet?";
setSearchParam({
query: "Who are the founders of internet?",
query,
leftModel: "MXBAI (Dense)",
rightModel: "MXBAI / BM25 (Hybrid)",
});
setSearch(query);
}
}, [searchParam, isInitial]);

Expand Down

0 comments on commit db97e26

Please sign in to comment.