mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-17 18:35:19 +02:00
Merge remote-tracking branch 'upstream/dev' into fix/docker-dev
This commit is contained in:
commit
4cca366e11
18 changed files with 450 additions and 51 deletions
|
|
@ -19,8 +19,8 @@ import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog";
|
|||
import { Spinner } from "@/components/ui/spinner";
|
||||
import { Tabs, TabsContent } from "@/components/ui/tabs";
|
||||
import type { SearchSourceConnector } from "@/contracts/types/connector.types";
|
||||
import { statusInboxItemsAtom } from "@/atoms/inbox/status-inbox.atom";
|
||||
import { useConnectorsElectric } from "@/hooks/use-connectors-electric";
|
||||
import { useInbox } from "@/hooks/use-inbox";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { ConnectorDialogHeader } from "./connector-popup/components/connector-dialog-header";
|
||||
import { ConnectorConnectView } from "./connector-popup/connector-configs/views/connector-connect-view";
|
||||
|
|
@ -75,12 +75,9 @@ export const ConnectorIndicator = forwardRef<ConnectorIndicatorHandle, Connector
|
|||
const { data: documentTypeCounts, isFetching: documentTypesLoading } =
|
||||
useAtomValue(documentTypeCountsAtom);
|
||||
|
||||
// Fetch status notifications to detect indexing failures
|
||||
const { inboxItems: statusInboxItems = [] } = useInbox(
|
||||
currentUser?.id ?? null,
|
||||
searchSpaceId ? Number(searchSpaceId) : null,
|
||||
"status"
|
||||
);
|
||||
// Read status inbox items from shared atom (populated by LayoutDataProvider)
|
||||
// instead of creating a duplicate useInbox("status") hook.
|
||||
const statusInboxItems = useAtomValue(statusInboxItemsAtom);
|
||||
const inboxItems = useMemo(
|
||||
() => statusInboxItems.filter((item) => item.type === "connector_indexing"),
|
||||
[statusInboxItems]
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import { Fragment, useCallback, useEffect, useMemo, useRef, useState } from "rea
|
|||
import { toast } from "sonner";
|
||||
import { currentThreadAtom, resetCurrentThreadAtom } from "@/atoms/chat/current-thread.atom";
|
||||
import { documentsSidebarOpenAtom } from "@/atoms/documents/ui.atoms";
|
||||
import { statusInboxItemsAtom } from "@/atoms/inbox/status-inbox.atom";
|
||||
import { deleteSearchSpaceMutationAtom } from "@/atoms/search-spaces/search-space-mutation.atoms";
|
||||
import { searchSpacesAtom } from "@/atoms/search-spaces/search-space-query.atoms";
|
||||
import { currentUserAtom } from "@/atoms/user/user-query.atoms";
|
||||
|
|
@ -37,6 +38,7 @@ import { isPageLimitExceededMetadata } from "@/contracts/types/inbox.types";
|
|||
import { useAnnouncements } from "@/hooks/use-announcements";
|
||||
import { useDocumentsProcessing } from "@/hooks/use-documents-processing";
|
||||
import { useInbox } from "@/hooks/use-inbox";
|
||||
import { notificationsApiService } from "@/lib/apis/notifications-api.service";
|
||||
import { searchSpacesApiService } from "@/lib/apis/search-spaces-api.service";
|
||||
import { logout } from "@/lib/auth-utils";
|
||||
import { deleteThread, fetchThreads, updateThread } from "@/lib/chat/thread-persistence";
|
||||
|
|
@ -144,11 +146,39 @@ export function LayoutDataProvider({ searchSpaceId, children }: LayoutDataProvid
|
|||
const userId = user?.id ? String(user.id) : null;
|
||||
const numericSpaceId = Number(searchSpaceId) || null;
|
||||
|
||||
const commentsInbox = useInbox(userId, numericSpaceId, "comments");
|
||||
const statusInbox = useInbox(userId, numericSpaceId, "status");
|
||||
// Batch-fetch unread counts for all categories in a single request
|
||||
// instead of 2 separate /unread-count calls.
|
||||
const { data: batchUnread, isLoading: isBatchUnreadLoading } = useQuery({
|
||||
queryKey: cacheKeys.notifications.batchUnreadCounts(numericSpaceId),
|
||||
queryFn: () => notificationsApiService.getBatchUnreadCounts(numericSpaceId ?? undefined),
|
||||
enabled: !!userId && !!numericSpaceId,
|
||||
staleTime: 30_000,
|
||||
});
|
||||
|
||||
const commentsInbox = useInbox(
|
||||
userId,
|
||||
numericSpaceId,
|
||||
"comments",
|
||||
batchUnread?.comments,
|
||||
!isBatchUnreadLoading
|
||||
);
|
||||
const statusInbox = useInbox(
|
||||
userId,
|
||||
numericSpaceId,
|
||||
"status",
|
||||
batchUnread?.status,
|
||||
!isBatchUnreadLoading
|
||||
);
|
||||
|
||||
const totalUnreadCount = commentsInbox.unreadCount + statusInbox.unreadCount;
|
||||
|
||||
// Sync status inbox items to a shared atom so child components
|
||||
// (e.g. ConnectorPopup) can read them without creating duplicate useInbox hooks.
|
||||
const setStatusInboxItems = useSetAtom(statusInboxItemsAtom);
|
||||
useEffect(() => {
|
||||
setStatusInboxItems(statusInbox.inboxItems);
|
||||
}, [statusInbox.inboxItems, setStatusInboxItems]);
|
||||
|
||||
// Document processing status — drives sidebar status indicator (spinner / check / error)
|
||||
const documentsProcessingStatus = useDocumentsProcessing(numericSpaceId);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue