fix: replace any types with proper NostrEvent types

- Replace any type with NostrEvent | undefined in Bookmarks component
- Replace any type with NostrEvent in useArticleLoader hook
- Remove incorrect bookmark-to-article assignment
- All linter warnings resolved
- Type checks passing
This commit is contained in:
Gigi
2025-10-05 23:16:05 +01:00
parent 2f2e19fdf9
commit a6ea97b731
2 changed files with 6 additions and 6 deletions

View File

@@ -21,6 +21,7 @@ import { HighlightVisibility } from './HighlightsPanel'
import { HighlightButton, HighlightButtonRef } from './HighlightButton' import { HighlightButton, HighlightButtonRef } from './HighlightButton'
import { createHighlight } from '../services/highlightCreationService' import { createHighlight } from '../services/highlightCreationService'
import { useRef, useCallback } from 'react' import { useRef, useCallback } from 'react'
import { NostrEvent } from 'nostr-tools'
export type ViewMode = 'compact' | 'cards' | 'large' export type ViewMode = 'compact' | 'cards' | 'large'
interface BookmarksProps { interface BookmarksProps {
@@ -45,7 +46,7 @@ const Bookmarks: React.FC<BookmarksProps> = ({ relayPool, onLogout }) => {
const [showSettings, setShowSettings] = useState(false) const [showSettings, setShowSettings] = useState(false)
const [currentArticleCoordinate, setCurrentArticleCoordinate] = useState<string | undefined>(undefined) const [currentArticleCoordinate, setCurrentArticleCoordinate] = useState<string | undefined>(undefined)
const [currentArticleEventId, setCurrentArticleEventId] = useState<string | undefined>(undefined) const [currentArticleEventId, setCurrentArticleEventId] = useState<string | undefined>(undefined)
const [currentArticle, setCurrentArticle] = useState<any>(undefined) // Store the current article event const [currentArticle, setCurrentArticle] = useState<NostrEvent | undefined>(undefined) // Store the current article event
const [highlightVisibility, setHighlightVisibility] = useState<HighlightVisibility>({ const [highlightVisibility, setHighlightVisibility] = useState<HighlightVisibility>({
nostrverse: true, nostrverse: true,
friends: true, friends: true,
@@ -191,10 +192,8 @@ const Bookmarks: React.FC<BookmarksProps> = ({ relayPool, onLogout }) => {
const content = await loadContent(url, relayPool, bookmark) const content = await loadContent(url, relayPool, bookmark)
setReaderContent(content) setReaderContent(content)
// If this is a Nostr article (kind:30023), we need to get the event for highlight creation // Note: currentArticle is set by useArticleLoader when loading Nostr articles
if (bookmark && bookmark.kind === 30023) { // For web bookmarks, there's no article event to set
setCurrentArticle(bookmark)
}
} catch (err) { } catch (err) {
console.warn('Failed to fetch content:', err) console.warn('Failed to fetch content:', err)
} finally { } finally {

View File

@@ -4,6 +4,7 @@ import { fetchArticleByNaddr } from '../services/articleService'
import { fetchHighlightsForArticle } from '../services/highlightService' import { fetchHighlightsForArticle } from '../services/highlightService'
import { ReadableContent } from '../services/readerService' import { ReadableContent } from '../services/readerService'
import { Highlight } from '../types/highlights' import { Highlight } from '../types/highlights'
import { NostrEvent } from 'nostr-tools'
interface UseArticleLoaderProps { interface UseArticleLoaderProps {
naddr: string | undefined naddr: string | undefined
@@ -16,7 +17,7 @@ interface UseArticleLoaderProps {
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
setCurrentArticle?: (article: any) => void setCurrentArticle?: (article: NostrEvent) => void
} }
export function useArticleLoader({ export function useArticleLoader({