mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-09 05:39:12 +00:00
Add uploaded files in the conversation file filter for a new convo
This commit is contained in:
@@ -30,6 +30,7 @@ import { useRouter, useSearchParams } from "next/navigation";
|
|||||||
import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area";
|
import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area";
|
||||||
import { AgentCard } from "@/app/components/agentCard/agentCard";
|
import { AgentCard } from "@/app/components/agentCard/agentCard";
|
||||||
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
|
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
|
||||||
|
import { modifyFileFilterForConversation } from "./common/chatFunctions";
|
||||||
|
|
||||||
interface ChatBodyDataProps {
|
interface ChatBodyDataProps {
|
||||||
chatOptionsData: ChatOptions | null;
|
chatOptionsData: ChatOptions | null;
|
||||||
@@ -150,12 +151,26 @@ function ChatBodyData(props: ChatBodyDataProps) {
|
|||||||
setProcessingMessage(true);
|
setProcessingMessage(true);
|
||||||
try {
|
try {
|
||||||
const newConversationId = await createNewConversation(selectedAgent || "khoj");
|
const newConversationId = await createNewConversation(selectedAgent || "khoj");
|
||||||
|
const uploadedFiles = localStorage.getItem("uploadedFiles");
|
||||||
onConversationIdChange?.(newConversationId);
|
onConversationIdChange?.(newConversationId);
|
||||||
localStorage.setItem("message", message);
|
localStorage.setItem("message", message);
|
||||||
if (images.length > 0) {
|
if (images.length > 0) {
|
||||||
localStorage.setItem("images", JSON.stringify(images));
|
localStorage.setItem("images", JSON.stringify(images));
|
||||||
}
|
}
|
||||||
window.location.href = `/chat?conversationId=${newConversationId}`;
|
|
||||||
|
if (uploadedFiles) {
|
||||||
|
modifyFileFilterForConversation(
|
||||||
|
newConversationId,
|
||||||
|
JSON.parse(uploadedFiles),
|
||||||
|
() => {
|
||||||
|
window.location.href = `/chat?conversationId=${newConversationId}`;
|
||||||
|
},
|
||||||
|
"add",
|
||||||
|
);
|
||||||
|
localStorage.removeItem("uploadedFiles");
|
||||||
|
} else {
|
||||||
|
window.location.href = `/chat?conversationId=${newConversationId}`;
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error creating new conversation:", error);
|
console.error("Error creating new conversation:", error);
|
||||||
setProcessingMessage(false);
|
setProcessingMessage(false);
|
||||||
@@ -417,6 +432,10 @@ export default function Home() {
|
|||||||
setUserConfig(initialUserConfig);
|
setUserConfig(initialUserConfig);
|
||||||
}, [initialUserConfig]);
|
}, [initialUserConfig]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
localStorage.setItem("uploadedFiles", JSON.stringify(uploadedFiles));
|
||||||
|
}, [uploadedFiles]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetch("/api/chat/options")
|
fetch("/api/chat/options")
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
|
|||||||
Reference in New Issue
Block a user