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