fix(types): correct setHighlights type to accept setState updater functions

This commit is contained in:
Gigi
2025-10-20 13:19:39 +02:00
parent 6f9c0a35e2
commit 31e203825d

View File

@@ -14,7 +14,7 @@ interface UseArticleLoaderProps {
setReaderContent: (content: ReadableContent | undefined) => void setReaderContent: (content: ReadableContent | undefined) => void
setReaderLoading: (loading: boolean) => void setReaderLoading: (loading: boolean) => void
setIsCollapsed: (collapsed: boolean) => void setIsCollapsed: (collapsed: boolean) => void
setHighlights: (highlights: Highlight[]) => void setHighlights: React.Dispatch<React.SetStateAction<Highlight[]>>
setHighlightsLoading: (loading: boolean) => void setHighlightsLoading: (loading: boolean) => void
setCurrentArticleCoordinate: (coord: string | undefined) => void setCurrentArticleCoordinate: (coord: string | undefined) => void
setCurrentArticleEventId: (id: string | undefined) => void setCurrentArticleEventId: (id: string | undefined) => void
@@ -81,8 +81,8 @@ export function useArticleLoader({
article.event.id, article.event.id,
(highlight) => { (highlight) => {
// Merge streaming results with existing UI state to preserve locally created highlights // Merge streaming results with existing UI state to preserve locally created highlights
setHighlights((prev) => { setHighlights((prev: Highlight[]) => {
if (prev.some(h => h.id === highlight.id)) return prev if (prev.some((h: Highlight) => h.id === highlight.id)) return prev
const next = [highlight, ...prev] const next = [highlight, ...prev]
return next.sort((a, b) => b.created_at - a.created_at) return next.sort((a, b) => b.created_at - a.created_at)
}) })