Browse Source

quiet the console

imwald
Silberengel 5 months ago
parent
commit
b09c5dd75a
  1. 2
      src/components/NoteList/index.tsx
  2. 14
      src/components/TrendingNotes/index.tsx
  3. 9
      src/pages/primary/DiscussionsPage/CreateThreadDialog.tsx
  4. 10
      src/pages/primary/DiscussionsPage/index.tsx

2
src/components/NoteList/index.tsx

@ -34,7 +34,7 @@ import { toast } from 'sonner' @@ -34,7 +34,7 @@ import { toast } from 'sonner'
import NoteCard, { NoteCardLoadingSkeleton } from '../NoteCard'
const LIMIT = 200
const ALGO_LIMIT = 200
const ALGO_LIMIT = 500
const SHOW_COUNT = 10
const NoteList = forwardRef(

14
src/components/TrendingNotes/index.tsx

@ -120,7 +120,7 @@ export default function TrendingNotes() { @@ -120,7 +120,7 @@ export default function TrendingNotes() {
}
return eventIds
} catch (error) {
console.error(`Error fetching bookmarks for ${followPubkey}:`, error)
logger.error(`[TrendingNotes] Error fetching bookmarks for ${followPubkey}:`, error)
return []
}
})
@ -254,7 +254,7 @@ export default function TrendingNotes() { @@ -254,7 +254,7 @@ export default function TrendingNotes() {
isInitializing = true
setCacheLoading(true)
const relays = getRelays // This is already a value from useMemo
const relays = getRelays // Get current relays value
// Set a timeout to prevent infinite loading
const timeoutId = setTimeout(() => {
@ -322,7 +322,7 @@ export default function TrendingNotes() { @@ -322,7 +322,7 @@ export default function TrendingNotes() {
})
allEvents.push(...bookmarkPinEvents)
} catch (error) {
console.warn('[TrendingNotes] Error fetching bookmark/pin events:', error)
logger.warn('[TrendingNotes] Error fetching bookmark/pin events:', error)
}
}
@ -343,12 +343,12 @@ export default function TrendingNotes() { @@ -343,12 +343,12 @@ export default function TrendingNotes() {
})
allEvents.push(...pinEvents)
} catch (error) {
console.warn('[TrendingNotes] Error fetching pin events:', error)
logger.warn('[TrendingNotes] Error fetching pin events:', error)
}
}
}
} catch (error) {
console.error('[TrendingNotes] Error fetching pin list:', error)
logger.error('[TrendingNotes] Error fetching pin list:', error)
}
}
@ -467,8 +467,8 @@ export default function TrendingNotes() { @@ -467,8 +467,8 @@ export default function TrendingNotes() {
}
initializeCache()
// Only run when getRelays changes (which happens when login status changes)
}, [getRelays])
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []) // Only run once on mount to prevent infinite loop
const filteredEvents = useMemo(() => {
const idSet = new Set<string>()

9
src/pages/primary/DiscussionsPage/CreateThreadDialog.tsx

@ -24,6 +24,7 @@ import dayjs from 'dayjs' @@ -24,6 +24,7 @@ import dayjs from 'dayjs'
import { extractHashtagsFromContent, normalizeTopic } from '@/lib/discussion-topics'
import DiscussionContent from '@/components/Note/DiscussionContent'
import RelayIcon from '@/components/RelayIcon'
import logger from '@/lib/logger'
// Utility functions for thread creation
function extractImagesFromContent(content: string): string[] {
@ -134,7 +135,7 @@ export default function CreateThreadDialog({ @@ -134,7 +135,7 @@ export default function CreateThreadDialog({
setSelectableRelays(result.selectableRelays)
setSelectedRelayUrls(result.selectedRelays)
} catch (error) {
console.error('Failed to initialize relays:', error)
logger.error('[CreateThreadDialog] Failed to initialize relays:', error)
// Fallback to availableRelays
setSelectableRelays(availableRelays)
setSelectedRelayUrls(availableRelays)
@ -272,7 +273,7 @@ export default function CreateThreadDialog({ @@ -272,7 +273,7 @@ export default function CreateThreadDialog({
}
// Debug: Log the event before publishing
console.log('About to publish thread event:', {
logger.debug('[CreateThreadDialog] About to publish thread event:', {
kind: threadEvent.kind,
content: threadEvent.content,
tags: threadEvent.tags,
@ -296,8 +297,8 @@ export default function CreateThreadDialog({ @@ -296,8 +297,8 @@ export default function CreateThreadDialog({
throw new Error(t('Failed to publish thread'))
}
} catch (error) {
console.error('Error creating thread:', error)
console.error('Error details:', {
logger.error('[CreateThreadDialog] Error creating thread:', error)
logger.error('[CreateThreadDialog] Error details:', {
name: error instanceof Error ? error.name : 'Unknown',
message: error instanceof Error ? error.message : String(error),
stack: error instanceof Error ? error.stack : undefined

10
src/pages/primary/DiscussionsPage/index.tsx

@ -73,7 +73,7 @@ function countVotesForThread(threadId: string, reactions: NostrEvent[], threadAu @@ -73,7 +73,7 @@ function countVotesForThread(threadId: string, reactions: NostrEvent[], threadAu
// Only keep the newest vote from each user
if (!existingVote || reaction.created_at > existingVote.created_at) {
userVotes.set(reaction.pubkey, { type: normalizedReaction, created_at: reaction.created_at })
console.log('[DiscussionsPage] Added vote:', normalizedReaction, 'from', reaction.pubkey.substring(0, 8))
logger.debug('[DiscussionsPage] Added vote:', normalizedReaction, 'from', reaction.pubkey.substring(0, 8))
}
}
}
@ -168,7 +168,7 @@ const DiscussionsPage = forwardRef(() => { @@ -168,7 +168,7 @@ const DiscussionsPage = forwardRef(() => {
!blockedRelays.some(blocked => relay.includes(blocked))
)
console.log('[DiscussionsPage] Using', finalRelays.length, 'comprehensive relays')
logger.debug('[DiscussionsPage] Using', finalRelays.length, 'comprehensive relays')
return Array.from(new Set(finalRelays))
}, []) // Remove dependencies to prevent infinite loop
@ -179,7 +179,7 @@ const DiscussionsPage = forwardRef(() => { @@ -179,7 +179,7 @@ const DiscussionsPage = forwardRef(() => {
setIsRefreshing(true)
try {
console.log('[DiscussionsPage] Fetching all discussion threads...')
logger.debug('[DiscussionsPage] Fetching all discussion threads...')
// Get comprehensive relay list
const allRelays = await buildComprehensiveRelayList()
@ -214,11 +214,11 @@ const DiscussionsPage = forwardRef(() => { @@ -214,11 +214,11 @@ const DiscussionsPage = forwardRef(() => {
]) : Promise.resolve([])
])
console.log('[DiscussionsPage] Fetched', comments.length, 'comments and', reactions.length, 'reactions')
logger.debug('[DiscussionsPage] Fetched', comments.length, 'comments and', reactions.length, 'reactions')
// Debug: Log some reaction details
if (reactions.length > 0) {
console.log('[DiscussionsPage] Sample reactions:', reactions.slice(0, 3).map(r => ({
logger.debug('[DiscussionsPage] Sample reactions:', reactions.slice(0, 3).map(r => ({
id: r.id.substring(0, 8),
content: r.content,
pubkey: r.pubkey.substring(0, 8),

Loading…
Cancel
Save