lint fix wip

This commit is contained in:
Nicolas Cantu 2026-01-06 17:48:29 +01:00
parent c1442886cf
commit b08070d984
2 changed files with 31 additions and 8 deletions

View File

@ -37,6 +37,7 @@ export function SyncProgressBar(): React.ReactElement | null {
// Check connection state
const checkConnection = (): void => {
const state = nostrAuthService.getState()
console.log('[SyncProgressBar] Initial connection check:', { connected: state.connected, pubkey: state.pubkey })
setConnectionState({ connected: state.connected ?? false, pubkey: state.pubkey ?? null })
setIsInitialized(true)
}
@ -46,6 +47,7 @@ export function SyncProgressBar(): React.ReactElement | null {
// Listen to connection changes
const unsubscribe = nostrAuthService.subscribe((state) => {
console.log('[SyncProgressBar] Connection state changed:', { connected: state.connected, pubkey: state.pubkey })
setConnectionState({ connected: state.connected ?? false, pubkey: state.pubkey ?? null })
})
@ -55,11 +57,25 @@ export function SyncProgressBar(): React.ReactElement | null {
}, [])
useEffect(() => {
if (!isInitialized || !connectionState.connected || !connectionState.pubkey) {
console.log('[SyncProgressBar] Effect triggered:', { isInitialized, connected: connectionState.connected, pubkey: connectionState.pubkey, isSyncing })
if (!isInitialized) {
console.log('[SyncProgressBar] Not initialized yet')
return
}
if (!connectionState.connected) {
console.log('[SyncProgressBar] Not connected')
return
}
if (!connectionState.pubkey) {
console.log('[SyncProgressBar] No pubkey')
return
}
void (async () => {
console.log('[SyncProgressBar] Starting sync check...')
await loadSyncStatus()
// Auto-start sync if not recently synced
@ -67,8 +83,11 @@ export function SyncProgressBar(): React.ReactElement | null {
const currentTimestamp = getCurrentTimestamp()
const isRecentlySynced = storedLastSyncDate >= currentTimestamp - 3600
console.log('[SyncProgressBar] Sync status:', { storedLastSyncDate, currentTimestamp, isRecentlySynced, isSyncing })
// Only auto-start if not recently synced
if (!isRecentlySynced && !isSyncing && connectionState.pubkey) {
console.log('[SyncProgressBar] Starting auto-sync...')
setIsSyncing(true)
setSyncProgress({ currentStep: 0, totalSteps: 6, completed: false })
@ -83,13 +102,15 @@ export function SyncProgressBar(): React.ReactElement | null {
// Check if sync completed successfully (if it didn't, isSyncing should still be false)
setIsSyncing(false)
} catch (error) {
console.error('Error during auto-sync:', error)
console.error('[SyncProgressBar] Error during auto-sync:', error)
setIsSyncing(false)
setError(error instanceof Error ? error.message : 'Erreur de synchronisation')
}
} else {
console.log('[SyncProgressBar] Skipping auto-sync:', { isRecentlySynced, isSyncing, hasPubkey: Boolean(connectionState.pubkey) })
}
})()
}, [isInitialized, connectionState.connected, connectionState.pubkey])
}, [isInitialized, connectionState.connected, connectionState.pubkey, isSyncing])
async function resynchronize(): Promise<void> {
try {
@ -136,9 +157,12 @@ export function SyncProgressBar(): React.ReactElement | null {
// Don't show if not initialized or not connected
if (!isInitialized || !connectionState.connected || !connectionState.pubkey) {
console.log('[SyncProgressBar] Not rendering:', { isInitialized, connected: connectionState.connected, pubkey: connectionState.pubkey })
return null
}
console.log('[SyncProgressBar] Rendering component')
// Check if sync is recently completed (within last hour)
const isRecentlySynced = lastSyncDate !== null && lastSyncDate >= getCurrentTimestamp() - 3600

View File

@ -1,4 +1,4 @@
import { useState, useEffect } from 'react'
import { useState, useEffect, useCallback } from 'react'
import { getLocale } from '@/lib/i18n'
export type DocSection = 'user-guide' | 'faq' | 'publishing' | 'payment' | 'fees-and-contributions'
@ -19,7 +19,7 @@ export function useDocs(docs: DocLink[]): {
const [docContent, setDocContent] = useState<string>('')
const [loading, setLoading] = useState(false)
const loadDoc = async (docId: DocSection): Promise<void> => {
const loadDoc = useCallback(async (docId: DocSection): Promise<void> => {
const doc = docs.find((d) => d.id === docId)
if (!doc) {return}
@ -45,12 +45,11 @@ export function useDocs(docs: DocLink[]): {
} finally {
setLoading(false)
}
}
}, [docs])
useEffect(() => {
loadDoc('user-guide')
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
}, [loadDoc])
return {
selectedDoc,