mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-02 22:01:05 +02:00
chore: ran linting
This commit is contained in:
parent
37e1995546
commit
f8b0e946ce
31 changed files with 768 additions and 754 deletions
|
|
@ -47,7 +47,9 @@ export function useComments({ messageId, enabled = true }: UseCommentsOptions) {
|
|||
|
||||
if (_batchInflight && _batchTargetIds.has(messageId)) {
|
||||
await _batchInflight;
|
||||
const cached = queryClient.getQueryData<GetCommentsResponse>(cacheKeys.comments.byMessage(messageId));
|
||||
const cached = queryClient.getQueryData<GetCommentsResponse>(
|
||||
cacheKeys.comments.byMessage(messageId)
|
||||
);
|
||||
if (cached) return cached;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ export function useDocumentsProcessing(searchSpaceId: number | null): boolean {
|
|||
live?: {
|
||||
query: <T>(
|
||||
sql: string,
|
||||
params?: (number | string)[],
|
||||
params?: (number | string)[]
|
||||
) => Promise<{
|
||||
subscribe: (cb: (result: { rows: T[] }) => void) => void;
|
||||
unsubscribe?: () => void;
|
||||
|
|
@ -80,7 +80,7 @@ export function useDocumentsProcessing(searchSpaceId: number | null): boolean {
|
|||
`SELECT COUNT(*) as count FROM documents
|
||||
WHERE search_space_id = $1
|
||||
AND (status->>'state' = 'pending' OR status->>'state' = 'processing')`,
|
||||
[spaceId],
|
||||
[spaceId]
|
||||
);
|
||||
|
||||
if (!mounted) {
|
||||
|
|
|
|||
|
|
@ -356,8 +356,11 @@ export function useDocuments(
|
|||
const prevIds = new Set(prev.map((d) => d.id));
|
||||
|
||||
const newItems = filterNewElectricItems(
|
||||
validItems, liveIds, prevIds,
|
||||
electricBaselineIdsRef, newestApiTimestampRef.current,
|
||||
validItems,
|
||||
liveIds,
|
||||
prevIds,
|
||||
electricBaselineIdsRef,
|
||||
newestApiTimestampRef.current
|
||||
).map(electricToDisplayDoc);
|
||||
|
||||
// Update existing docs (status changes, title edits)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,11 @@ import { notificationsApiService } from "@/lib/apis/notifications-api.service";
|
|||
import { filterNewElectricItems, getNewestTimestamp } from "@/lib/electric/baseline";
|
||||
import { useElectricClient } from "@/lib/electric/context";
|
||||
|
||||
export type { InboxItem, InboxItemTypeEnum, NotificationCategory } from "@/contracts/types/inbox.types";
|
||||
export type {
|
||||
InboxItem,
|
||||
InboxItemTypeEnum,
|
||||
NotificationCategory,
|
||||
} from "@/contracts/types/inbox.types";
|
||||
|
||||
const INITIAL_PAGE_SIZE = 50;
|
||||
const SCROLL_PAGE_SIZE = 30;
|
||||
|
|
@ -14,7 +18,8 @@ const SYNC_WINDOW_DAYS = 4;
|
|||
|
||||
const CATEGORY_TYPE_SQL: Record<NotificationCategory, string> = {
|
||||
comments: "AND type IN ('new_mention', 'comment_reply')",
|
||||
status: "AND type IN ('connector_indexing', 'connector_deletion', 'document_processing', 'page_limit_exceeded')",
|
||||
status:
|
||||
"AND type IN ('connector_indexing', 'connector_deletion', 'document_processing', 'page_limit_exceeded')",
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -52,7 +57,7 @@ function getSyncCutoffDate(): string {
|
|||
export function useInbox(
|
||||
userId: string | null,
|
||||
searchSpaceId: number | null,
|
||||
category: NotificationCategory,
|
||||
category: NotificationCategory
|
||||
) {
|
||||
const electricClient = useElectricClient();
|
||||
|
||||
|
|
@ -119,7 +124,9 @@ export function useInbox(
|
|||
};
|
||||
|
||||
fetchInitialData();
|
||||
return () => { cancelled = true; };
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [userId, searchSpaceId, category]);
|
||||
|
||||
// EFFECT 2: Electric sync (shared shape) + per-instance type-filtered live queries
|
||||
|
|
@ -135,11 +142,19 @@ export function useInbox(
|
|||
async function setupElectricRealtime() {
|
||||
// Clean up previous live queries (NOT the sync shape — it's shared)
|
||||
if (liveQueryRef.current) {
|
||||
try { liveQueryRef.current.unsubscribe?.(); } catch { /* PGlite may be closed */ }
|
||||
try {
|
||||
liveQueryRef.current.unsubscribe?.();
|
||||
} catch {
|
||||
/* PGlite may be closed */
|
||||
}
|
||||
liveQueryRef.current = null;
|
||||
}
|
||||
if (unreadLiveQueryRef.current) {
|
||||
try { unreadLiveQueryRef.current.unsubscribe?.(); } catch { /* PGlite may be closed */ }
|
||||
try {
|
||||
unreadLiveQueryRef.current.unsubscribe?.();
|
||||
} catch {
|
||||
/* PGlite may be closed */
|
||||
}
|
||||
unreadLiveQueryRef.current = null;
|
||||
}
|
||||
|
||||
|
|
@ -207,8 +222,11 @@ export function useInbox(
|
|||
const prevIds = new Set(prev.map((d) => d.id));
|
||||
|
||||
const newItems = filterNewElectricItems(
|
||||
validItems, liveIds, prevIds,
|
||||
electricBaselineIdsRef, newestApiTimestampRef.current,
|
||||
validItems,
|
||||
liveIds,
|
||||
prevIds,
|
||||
electricBaselineIdsRef,
|
||||
newestApiTimestampRef.current
|
||||
);
|
||||
|
||||
let updated = prev.map((item) => {
|
||||
|
|
@ -267,7 +285,10 @@ export function useInbox(
|
|||
AND read = false
|
||||
${typeFilter}`;
|
||||
|
||||
const countLiveQuery = await db.live.query<{ count: number | string }>(countQuery, [uid, spaceId]);
|
||||
const countLiveQuery = await db.live.query<{ count: number | string }>(countQuery, [
|
||||
uid,
|
||||
spaceId,
|
||||
]);
|
||||
|
||||
if (!mounted) {
|
||||
countLiveQuery.unsubscribe?.();
|
||||
|
|
@ -293,11 +314,19 @@ export function useInbox(
|
|||
mounted = false;
|
||||
// Only clean up live queries — sync shape is shared across instances
|
||||
if (liveQueryRef.current) {
|
||||
try { liveQueryRef.current.unsubscribe?.(); } catch { /* PGlite may be closed */ }
|
||||
try {
|
||||
liveQueryRef.current.unsubscribe?.();
|
||||
} catch {
|
||||
/* PGlite may be closed */
|
||||
}
|
||||
liveQueryRef.current = null;
|
||||
}
|
||||
if (unreadLiveQueryRef.current) {
|
||||
try { unreadLiveQueryRef.current.unsubscribe?.(); } catch { /* PGlite may be closed */ }
|
||||
try {
|
||||
unreadLiveQueryRef.current.unsubscribe?.();
|
||||
} catch {
|
||||
/* PGlite may be closed */
|
||||
}
|
||||
unreadLiveQueryRef.current = null;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue