mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-25 00:36:31 +02:00
fix: Docs & Chats in other search spaces
This commit is contained in:
parent
73623aa37e
commit
2008b07304
6 changed files with 32 additions and 21 deletions
|
|
@ -7,12 +7,15 @@ interface PageProps {
|
|||
};
|
||||
}
|
||||
|
||||
export default function ChatsPage({ params }: PageProps) {
|
||||
export default async function ChatsPage({ params }: PageProps) {
|
||||
// Await params to properly access dynamic route parameters
|
||||
const searchSpaceId = params.search_space_id;
|
||||
|
||||
return (
|
||||
<Suspense fallback={<div className="flex items-center justify-center h-[60vh]">
|
||||
<div className="h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"></div>
|
||||
</div>}>
|
||||
<ChatsPageClient searchSpaceId={params.search_space_id} />
|
||||
<ChatsPageClient searchSpaceId={searchSpaceId} />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
|
|
@ -118,8 +118,8 @@ export function AppSidebarProvider({
|
|||
if (typeof window === 'undefined') return;
|
||||
|
||||
try {
|
||||
// Use the API client instead of direct fetch
|
||||
const chats: Chat[] = await apiClient.get<Chat[]>('api/v1/chats/?limit=5&skip=0');
|
||||
// Use the API client instead of direct fetch - filter by current search space ID
|
||||
const chats: Chat[] = await apiClient.get<Chat[]>(`api/v1/chats/?limit=5&skip=0&search_space_id=${searchSpaceId}`);
|
||||
|
||||
// Transform API response to the format expected by AppSidebar
|
||||
const formattedChats = chats.map(chat => ({
|
||||
|
|
@ -170,7 +170,7 @@ export function AppSidebarProvider({
|
|||
|
||||
// Clean up interval on component unmount
|
||||
return () => clearInterval(intervalId);
|
||||
}, []);
|
||||
}, [searchSpaceId]);
|
||||
|
||||
// Handle delete chat
|
||||
const handleDeleteChat = async () => {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ export function useDocuments(searchSpaceId: number) {
|
|||
try {
|
||||
setLoading(true);
|
||||
const response = await fetch(
|
||||
`${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/api/v1/documents`,
|
||||
`${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/api/v1/documents?search_space_id=${searchSpaceId}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${localStorage.getItem('surfsense_bearer_token')}`,
|
||||
|
|
@ -57,7 +57,7 @@ export function useDocuments(searchSpaceId: number) {
|
|||
setLoading(true);
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/api/v1/documents`,
|
||||
`${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/api/v1/documents?search_space_id=${searchSpaceId}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${localStorage.getItem('surfsense_bearer_token')}`,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue