lint fix wip
This commit is contained in:
parent
c1442886cf
commit
b08070d984
@ -37,6 +37,7 @@ export function SyncProgressBar(): React.ReactElement | null {
|
|||||||
// Check connection state
|
// Check connection state
|
||||||
const checkConnection = (): void => {
|
const checkConnection = (): void => {
|
||||||
const state = nostrAuthService.getState()
|
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 })
|
setConnectionState({ connected: state.connected ?? false, pubkey: state.pubkey ?? null })
|
||||||
setIsInitialized(true)
|
setIsInitialized(true)
|
||||||
}
|
}
|
||||||
@ -46,6 +47,7 @@ export function SyncProgressBar(): React.ReactElement | null {
|
|||||||
|
|
||||||
// Listen to connection changes
|
// Listen to connection changes
|
||||||
const unsubscribe = nostrAuthService.subscribe((state) => {
|
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 })
|
setConnectionState({ connected: state.connected ?? false, pubkey: state.pubkey ?? null })
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -55,11 +57,25 @@ export function SyncProgressBar(): React.ReactElement | null {
|
|||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
void (async () => {
|
void (async () => {
|
||||||
|
console.log('[SyncProgressBar] Starting sync check...')
|
||||||
await loadSyncStatus()
|
await loadSyncStatus()
|
||||||
|
|
||||||
// Auto-start sync if not recently synced
|
// Auto-start sync if not recently synced
|
||||||
@ -67,8 +83,11 @@ export function SyncProgressBar(): React.ReactElement | null {
|
|||||||
const currentTimestamp = getCurrentTimestamp()
|
const currentTimestamp = getCurrentTimestamp()
|
||||||
const isRecentlySynced = storedLastSyncDate >= currentTimestamp - 3600
|
const isRecentlySynced = storedLastSyncDate >= currentTimestamp - 3600
|
||||||
|
|
||||||
|
console.log('[SyncProgressBar] Sync status:', { storedLastSyncDate, currentTimestamp, isRecentlySynced, isSyncing })
|
||||||
|
|
||||||
// Only auto-start if not recently synced
|
// Only auto-start if not recently synced
|
||||||
if (!isRecentlySynced && !isSyncing && connectionState.pubkey) {
|
if (!isRecentlySynced && !isSyncing && connectionState.pubkey) {
|
||||||
|
console.log('[SyncProgressBar] Starting auto-sync...')
|
||||||
setIsSyncing(true)
|
setIsSyncing(true)
|
||||||
setSyncProgress({ currentStep: 0, totalSteps: 6, completed: false })
|
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)
|
// Check if sync completed successfully (if it didn't, isSyncing should still be false)
|
||||||
setIsSyncing(false)
|
setIsSyncing(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error during auto-sync:', error)
|
console.error('[SyncProgressBar] Error during auto-sync:', error)
|
||||||
setIsSyncing(false)
|
setIsSyncing(false)
|
||||||
setError(error instanceof Error ? error.message : 'Erreur de synchronisation')
|
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> {
|
async function resynchronize(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
@ -136,9 +157,12 @@ export function SyncProgressBar(): React.ReactElement | null {
|
|||||||
|
|
||||||
// Don't show if not initialized or not connected
|
// Don't show if not initialized or not connected
|
||||||
if (!isInitialized || !connectionState.connected || !connectionState.pubkey) {
|
if (!isInitialized || !connectionState.connected || !connectionState.pubkey) {
|
||||||
|
console.log('[SyncProgressBar] Not rendering:', { isInitialized, connected: connectionState.connected, pubkey: connectionState.pubkey })
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('[SyncProgressBar] Rendering component')
|
||||||
|
|
||||||
// Check if sync is recently completed (within last hour)
|
// Check if sync is recently completed (within last hour)
|
||||||
const isRecentlySynced = lastSyncDate !== null && lastSyncDate >= getCurrentTimestamp() - 3600
|
const isRecentlySynced = lastSyncDate !== null && lastSyncDate >= getCurrentTimestamp() - 3600
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { useState, useEffect } from 'react'
|
import { useState, useEffect, useCallback } from 'react'
|
||||||
import { getLocale } from '@/lib/i18n'
|
import { getLocale } from '@/lib/i18n'
|
||||||
|
|
||||||
export type DocSection = 'user-guide' | 'faq' | 'publishing' | 'payment' | 'fees-and-contributions'
|
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 [docContent, setDocContent] = useState<string>('')
|
||||||
const [loading, setLoading] = useState(false)
|
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)
|
const doc = docs.find((d) => d.id === docId)
|
||||||
if (!doc) {return}
|
if (!doc) {return}
|
||||||
|
|
||||||
@ -45,12 +45,11 @@ export function useDocs(docs: DocLink[]): {
|
|||||||
} finally {
|
} finally {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
}
|
}, [docs])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadDoc('user-guide')
|
loadDoc('user-guide')
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
}, [loadDoc])
|
||||||
}, [])
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
selectedDoc,
|
selectedDoc,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user