Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions apps/web/components/memories-grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ type OgData = {
image?: string
}

const IS_DEV = process.env.NODE_ENV === "development"
const PAGE_SIZE = IS_DEV ? 100 : 100
const PAGE_SIZE = 100
const MAX_TOTAL = 1000

// Discriminated union for masonry items
Expand Down
43 changes: 33 additions & 10 deletions packages/lib/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export const fetchSubscriptionStatus = (
return statusMap
},
queryKey: ["subscription-status"],
refetchInterval: 5000, // Refetch every 5 seconds
staleTime: 4000, // Consider data stale after 4 seconds
refetchInterval: 60 * 1000, // Refetch every 1 minute
staleTime: 55 * 1000, // Consider data stale after 55 seconds
enabled: isEnabled,
})

Expand Down Expand Up @@ -132,18 +132,41 @@ export const useDeleteDocument = (selectedProject: string) => {
["documents-with-memories", selectedProject],
(old: unknown) => {
if (!old || typeof old !== "object") return old
const typedOld = old as {
pages?: Array<{ documents?: DocumentWithMemories[] }>

// Handle Infinite Query structure (TanStack Query v5 uses 'pages')
if (
"pages" in old &&
Array.isArray((old as Record<string, unknown>).pages)
) {
const typedOld = old as {
pages: Array<{ documents?: DocumentWithMemories[] }>
}
return {
...typedOld,
pages: typedOld.pages.map((page) => ({
...page,
documents: page.documents?.filter(
(doc: DocumentWithMemories) => doc.id !== documentId,
),
})),
}
}
return {
...typedOld,
pages: typedOld.pages?.map((page) => ({
...page,
documents: page.documents?.filter(

// Handle Standard Query structure
if (
"documents" in old &&
Array.isArray((old as Record<string, unknown>).documents)
) {
const typedOld = old as { documents: DocumentWithMemories[] }
return {
...typedOld,
documents: typedOld.documents.filter(
(doc: DocumentWithMemories) => doc.id !== documentId,
),
})),
}
}

return old
},
)

Expand Down
Loading