mirror of
https://github.com/dergigi/boris.git
synced 2025-12-17 14:44:26 +01:00
refactor: remove eslint-disable comments by typing publish, fixing unused-vars, and updating effect deps
This commit is contained in:
14
src/App.tsx
14
src/App.tsx
@@ -8,6 +8,7 @@ import { AccountManager, Accounts } from 'applesauce-accounts'
|
|||||||
import { registerCommonAccountTypes } from 'applesauce-accounts/accounts'
|
import { registerCommonAccountTypes } from 'applesauce-accounts/accounts'
|
||||||
import { RelayPool } from 'applesauce-relay'
|
import { RelayPool } from 'applesauce-relay'
|
||||||
import { NostrConnectSigner } from 'applesauce-signers'
|
import { NostrConnectSigner } from 'applesauce-signers'
|
||||||
|
import type { NostrEvent } from 'nostr-tools'
|
||||||
import { getDefaultBunkerPermissions } from './services/nostrConnect'
|
import { getDefaultBunkerPermissions } from './services/nostrConnect'
|
||||||
import { createAddressLoader } from 'applesauce-loaders/loaders'
|
import { createAddressLoader } from 'applesauce-loaders/loaders'
|
||||||
import Debug from './components/Debug'
|
import Debug from './components/Debug'
|
||||||
@@ -386,16 +387,9 @@ function App() {
|
|||||||
// Wire the signer to use this pool; make publish non-blocking so callers don't
|
// Wire the signer to use this pool; make publish non-blocking so callers don't
|
||||||
// wait for every relay send to finish. Responses still resolve the pending request.
|
// wait for every relay send to finish. Responses still resolve the pending request.
|
||||||
NostrConnectSigner.subscriptionMethod = pool.subscription.bind(pool)
|
NostrConnectSigner.subscriptionMethod = pool.subscription.bind(pool)
|
||||||
NostrConnectSigner.publishMethod = (relays: string[], event: unknown) => {
|
NostrConnectSigner.publishMethod = (relays: string[], event: NostrEvent) => {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// Fire-and-forget publish; do not block callers
|
||||||
const result: any = pool.publish(relays, event as any)
|
pool.publish(relays, event).catch(() => { /* ignore errors */ })
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
if (result && typeof (result as any).subscribe === 'function') {
|
|
||||||
// Subscribe to the observable but ignore completion/errors (fire-and-forget)
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
try { (result as any).subscribe({ complete: () => { /* noop */ }, error: () => { /* noop */ } }) } catch { /* ignore */ }
|
|
||||||
}
|
|
||||||
// Return an already-resolved promise so upstream await finishes immediately
|
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -145,8 +145,20 @@ export const BookmarkItem: React.FC<BookmarkItemProps> = ({ bookmark, index, onS
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (viewMode === 'compact') {
|
if (viewMode === 'compact') {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
|
const compactProps = {
|
||||||
const { articleImage, ...compactProps } = sharedProps
|
bookmark,
|
||||||
|
index,
|
||||||
|
hasUrls,
|
||||||
|
extractedUrls,
|
||||||
|
onSelectUrl,
|
||||||
|
authorNpub,
|
||||||
|
eventNevent,
|
||||||
|
getAuthorDisplayName,
|
||||||
|
handleReadNow,
|
||||||
|
articleSummary,
|
||||||
|
contentTypeIcon: getContentTypeIcon(),
|
||||||
|
readingProgress
|
||||||
|
}
|
||||||
return <CompactView {...compactProps} />
|
return <CompactView {...compactProps} />
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -434,11 +434,7 @@ const Debug: React.FC<DebugProps> = ({
|
|||||||
|
|
||||||
const elapsed = Math.round(performance.now() - start)
|
const elapsed = Math.round(performance.now() - start)
|
||||||
setTLoadHighlights(elapsed)
|
setTLoadHighlights(elapsed)
|
||||||
setLiveTiming(prev => {
|
setLiveTiming(prev => ({ ...prev, loadHighlights: undefined }))
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
|
|
||||||
const { loadHighlights, ...rest } = prev
|
|
||||||
return rest
|
|
||||||
})
|
|
||||||
|
|
||||||
DebugBus.info('debug', `Loaded ${events.length} highlight events in ${elapsed}ms`)
|
DebugBus.info('debug', `Loaded ${events.length} highlight events in ${elapsed}ms`)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -798,11 +794,7 @@ const Debug: React.FC<DebugProps> = ({
|
|||||||
|
|
||||||
const elapsed = Math.round(performance.now() - start)
|
const elapsed = Math.round(performance.now() - start)
|
||||||
setTLoadReadingProgress(elapsed)
|
setTLoadReadingProgress(elapsed)
|
||||||
setLiveTiming(prev => {
|
setLiveTiming(prev => ({ ...prev, loadReadingProgress: undefined }))
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
|
|
||||||
const { loadReadingProgress, ...rest } = prev
|
|
||||||
return rest
|
|
||||||
})
|
|
||||||
|
|
||||||
const finalMap = readingProgressController.getProgressMap()
|
const finalMap = readingProgressController.getProgressMap()
|
||||||
DebugBus.info('debug', `Loaded ${rawEvents.length} raw events, deduplicated to ${finalMap.size} articles in ${elapsed}ms`)
|
DebugBus.info('debug', `Loaded ${rawEvents.length} raw events, deduplicated to ${finalMap.size} articles in ${elapsed}ms`)
|
||||||
@@ -871,11 +863,7 @@ const Debug: React.FC<DebugProps> = ({
|
|||||||
const totalEvents = kind7Events.length + kind17Events.length
|
const totalEvents = kind7Events.length + kind17Events.length
|
||||||
const elapsed = Math.round(performance.now() - start)
|
const elapsed = Math.round(performance.now() - start)
|
||||||
setTLoadMarkAsRead(elapsed)
|
setTLoadMarkAsRead(elapsed)
|
||||||
setLiveTiming(prev => {
|
setLiveTiming(prev => ({ ...prev, loadMarkAsRead: undefined }))
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
|
|
||||||
const { loadMarkAsRead, ...rest } = prev
|
|
||||||
return rest
|
|
||||||
})
|
|
||||||
|
|
||||||
DebugBus.info('debug', `Loaded ${totalEvents} mark-as-read reactions in ${elapsed}ms`)
|
DebugBus.info('debug', `Loaded ${totalEvents} mark-as-read reactions in ${elapsed}ms`)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -929,11 +917,7 @@ const Debug: React.FC<DebugProps> = ({
|
|||||||
|
|
||||||
const elapsed = Math.round(performance.now() - start)
|
const elapsed = Math.round(performance.now() - start)
|
||||||
setTLoadRelayList(elapsed)
|
setTLoadRelayList(elapsed)
|
||||||
setLiveTiming(prev => {
|
setLiveTiming(prev => ({ ...prev, loadRelayList: undefined }))
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
|
|
||||||
const { loadRelayList, ...rest } = prev
|
|
||||||
return rest
|
|
||||||
})
|
|
||||||
|
|
||||||
DebugBus.info('debug', `Loaded ${events.length} relay list events in ${elapsed}ms`)
|
DebugBus.info('debug', `Loaded ${events.length} relay list events in ${elapsed}ms`)
|
||||||
|
|
||||||
|
|||||||
@@ -120,7 +120,18 @@ export function useArticleLoader({
|
|||||||
return () => {
|
return () => {
|
||||||
mountedRef.current = false
|
mountedRef.current = false
|
||||||
}
|
}
|
||||||
// Intentionally excluding setter functions from dependencies to prevent race conditions
|
}, [
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
naddr,
|
||||||
}, [naddr, relayPool, settings])
|
relayPool,
|
||||||
|
settings,
|
||||||
|
setSelectedUrl,
|
||||||
|
setReaderContent,
|
||||||
|
setReaderLoading,
|
||||||
|
setIsCollapsed,
|
||||||
|
setHighlights,
|
||||||
|
setHighlightsLoading,
|
||||||
|
setCurrentArticleCoordinate,
|
||||||
|
setCurrentArticleEventId,
|
||||||
|
setCurrentArticle
|
||||||
|
])
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,9 +154,17 @@ export function useExternalUrlLoader({
|
|||||||
return () => {
|
return () => {
|
||||||
mountedRef.current = false
|
mountedRef.current = false
|
||||||
}
|
}
|
||||||
// Intentionally excluding setter functions from dependencies to prevent race conditions
|
}, [
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
url,
|
||||||
}, [url, relayPool, eventStore, cachedUrlHighlights])
|
relayPool,
|
||||||
|
eventStore,
|
||||||
|
cachedUrlHighlights,
|
||||||
|
setReaderContent,
|
||||||
|
setReaderLoading,
|
||||||
|
setIsCollapsed,
|
||||||
|
setSelectedUrl,
|
||||||
|
setHighlights
|
||||||
|
])
|
||||||
|
|
||||||
// Keep UI highlights synced with cached store updates without reloading content
|
// Keep UI highlights synced with cached store updates without reloading content
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -169,8 +177,6 @@ export function useExternalUrlLoader({
|
|||||||
const next = [...additions, ...prev]
|
const next = [...additions, ...prev]
|
||||||
return next.sort((a, b) => b.created_at - a.created_at)
|
return next.sort((a, b) => b.created_at - a.created_at)
|
||||||
})
|
})
|
||||||
// setHighlights is intentionally excluded from dependencies - it's stable
|
}, [cachedUrlHighlights, url, setHighlights])
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, [cachedUrlHighlights, url])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user