mirror of
https://github.com/MODSetter/SurfSense
synced 2026-06-21 13:44:09 +00:00
remove searchSpacesAtom from quick-ask, forward params via dashboard
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
import { useAtomValue } from "jotai";
|
||||
import { AlertCircle, Plus, Search } from "lucide-react";
|
||||
import { motion } from "motion/react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useEffect, useState } from "react";
|
||||
import { searchSpacesAtom } from "@/atoms/search-spaces/search-space-query.atoms";
|
||||
@@ -89,6 +89,7 @@ function EmptyState({ onCreateClick }: { onCreateClick: () => void }) {
|
||||
|
||||
export default function DashboardPage() {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const [showCreateDialog, setShowCreateDialog] = useState(false);
|
||||
|
||||
const t = useTranslations("dashboard");
|
||||
@@ -98,9 +99,11 @@ export default function DashboardPage() {
|
||||
if (isLoading) return;
|
||||
|
||||
if (searchSpaces.length > 0) {
|
||||
router.replace(`/dashboard/${searchSpaces[0].id}/new-chat`);
|
||||
const params = searchParams.toString();
|
||||
const query = params ? `?${params}` : "";
|
||||
router.replace(`/dashboard/${searchSpaces[0].id}/new-chat${query}`);
|
||||
}
|
||||
}, [isLoading, searchSpaces, router]);
|
||||
}, [isLoading, searchSpaces, router, searchParams]);
|
||||
|
||||
// Show loading while fetching or while we have spaces and are about to redirect
|
||||
const shouldShowLoading = isLoading || searchSpaces.length > 0;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
"use client";
|
||||
|
||||
import { useAtomValue } from "jotai";
|
||||
import {
|
||||
BookOpen,
|
||||
Check,
|
||||
@@ -13,7 +12,6 @@ import {
|
||||
Search,
|
||||
} from "lucide-react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { searchSpacesAtom } from "@/atoms/search-spaces/search-space-query.atoms";
|
||||
import { DEFAULT_ACTIONS } from "./actions";
|
||||
|
||||
const ICONS: Record<string, React.ReactNode> = {
|
||||
@@ -28,7 +26,6 @@ const ICONS: Record<string, React.ReactNode> = {
|
||||
};
|
||||
|
||||
export default function QuickAskPage() {
|
||||
const { data: searchSpaces = [], isLoading } = useAtomValue(searchSpacesAtom);
|
||||
const [clipboardText, setClipboardText] = useState("");
|
||||
|
||||
useEffect(() => {
|
||||
@@ -38,10 +35,8 @@ export default function QuickAskPage() {
|
||||
}, []);
|
||||
|
||||
const navigateToChat = (prompt: string, mode: string) => {
|
||||
if (!searchSpaces.length || !clipboardText) return;
|
||||
const spaceId = searchSpaces[0].id;
|
||||
const encoded = encodeURIComponent(prompt);
|
||||
window.location.href = `/dashboard/${spaceId}/new-chat?quickAskPrompt=${encoded}&quickAskMode=${mode}`;
|
||||
window.location.href = `/dashboard?quickAskPrompt=${encoded}&quickAskMode=${mode}`;
|
||||
};
|
||||
|
||||
const handleAction = (actionId: string) => {
|
||||
@@ -55,15 +50,13 @@ export default function QuickAskPage() {
|
||||
const exploreActions = DEFAULT_ACTIONS.filter((a) => a.group === "explore");
|
||||
const knowledgeActions = DEFAULT_ACTIONS.filter((a) => a.group === "knowledge");
|
||||
|
||||
const ready = !isLoading && clipboardText;
|
||||
|
||||
return (
|
||||
<div className="flex h-screen flex-col bg-background">
|
||||
<div className="flex-1 overflow-y-auto">
|
||||
{!ready && (
|
||||
{!clipboardText && (
|
||||
<div className="p-4 text-center text-sm text-muted-foreground">Loading...</div>
|
||||
)}
|
||||
{ready && (
|
||||
{clipboardText && (
|
||||
<div className="py-1">
|
||||
<div className="px-3 py-1.5 text-xs font-medium text-muted-foreground">Transform</div>
|
||||
{transformActions.map((action) => (
|
||||
|
||||
Reference in New Issue
Block a user