fix: improve offline sync with better tracking and logging

- Track events explicitly when created in offline mode
- Mark highlights as offline-created when isLocalOnly is true
- Add extensive debug logging throughout sync process
- Increase query timeout from 5s to 10s for better reliability
- Add 2-second delay before syncing to allow relays to connect
- Log relay state transitions and event counts
- Log each event received during sync query
- Should help diagnose and fix offline sync issues
This commit is contained in:
Gigi
2025-10-09 13:49:35 +01:00
parent 3330f22f82
commit 4224c989c6
3 changed files with 54 additions and 5 deletions

View File

@@ -48,7 +48,17 @@ export function useOfflineSync({
if (wasLocalOnly && isNowOnline) {
console.log('✈️ Detected transition: Flight Mode → Online')
syncLocalEventsToRemote(relayPool, account)
console.log('📊 Relay state:', {
connectedRelays: connectedRelays.length,
remoteRelays: connectedRelays.filter(r => !isLocalRelay(r.url)).length,
localRelays: connectedRelays.filter(r => isLocalRelay(r.url)).length
})
// Wait a moment for relays to fully establish connections
setTimeout(() => {
console.log('🚀 Starting sync after delay...')
syncLocalEventsToRemote(relayPool, account)
}, 2000)
}
previousStateRef.current.hasRemoteRelays = hasRemoteRelays