fix: skip rebroadcasting when in flight mode

- Check actual relay connectivity before rebroadcasting
- Skip rebroadcast to all relays if no remote relays connected
- Still allows rebroadcast to local relays in flight mode
- Prevents unnecessary publish attempts to unreachable relays
- Logs: '✈️ Flight mode: skipping rebroadcast to remote relays'

This prevents the app from trying to rebroadcast fetched events to
remote relays when only local relays are connected (flight mode).
This commit is contained in:
Gigi
2025-10-09 14:00:57 +01:00
parent a2041bd14d
commit be86634a65

View File

@@ -27,11 +27,22 @@ export async function rebroadcastEvents(
return // No rebroadcast enabled
}
// Check current relay connectivity - don't rebroadcast in flight mode
const connectedRelays = Array.from(relayPool.relays.values())
const connectedRemoteRelays = connectedRelays.filter(relay => relay.connected && !isLocalRelay(relay.url))
const hasRemoteConnection = connectedRemoteRelays.length > 0
// If we're in flight mode (only local relays connected) and user wants to broadcast to all relays, skip
if (broadcastToAll && !hasRemoteConnection) {
console.log('✈️ Flight mode: skipping rebroadcast to remote relays')
return
}
// Determine target relays based on settings
let targetRelays: string[] = []
if (broadcastToAll) {
// Broadcast to all relays
// Broadcast to all relays (only if we have remote connection)
targetRelays = RELAYS
} else if (useLocalCache) {
// Only broadcast to local relays