mirror of
https://github.com/dergigi/boris.git
synced 2025-12-22 00:54:21 +01:00
fix: determine isLocalOnly before publishing, not after
- Move connection status check before publishEvent call - Set isLocalOnly based on actual connection state at creation time - This ensures airplane icon shows correctly in flight mode - Previous logic was checking after publishing, which was too late
This commit is contained in:
@@ -118,10 +118,7 @@ export async function createHighlight(
|
|||||||
// Sign the event
|
// Sign the event
|
||||||
const signedEvent = await factory.sign(highlightEvent)
|
const signedEvent = await factory.sign(highlightEvent)
|
||||||
|
|
||||||
// Use unified write service to store and publish
|
// Check current connection status BEFORE publishing
|
||||||
await publishEvent(relayPool, eventStore, signedEvent)
|
|
||||||
|
|
||||||
// Check current connection status for UI feedback
|
|
||||||
const connectedRelays = Array.from(relayPool.relays.values())
|
const connectedRelays = Array.from(relayPool.relays.values())
|
||||||
.filter(relay => relay.connected)
|
.filter(relay => relay.connected)
|
||||||
.map(relay => relay.url)
|
.map(relay => relay.url)
|
||||||
@@ -129,10 +126,10 @@ export async function createHighlight(
|
|||||||
const hasRemoteConnection = connectedRelays.some(url => !isLocalRelay(url))
|
const hasRemoteConnection = connectedRelays.some(url => !isLocalRelay(url))
|
||||||
const hasLocalConnection = connectedRelays.some(url => isLocalRelay(url))
|
const hasLocalConnection = connectedRelays.some(url => isLocalRelay(url))
|
||||||
|
|
||||||
// Determine which relays we actually published to
|
// Determine which relays we should publish to
|
||||||
const expectedSuccessRelays = hasRemoteConnection
|
const targetRelays = hasRemoteConnection
|
||||||
? RELAYS // Published to all relays (local + remote)
|
? RELAYS // Publish to all relays (local + remote)
|
||||||
: RELAYS.filter(isLocalRelay) // Only published to local relays
|
: RELAYS.filter(isLocalRelay) // Only publish to local relays
|
||||||
|
|
||||||
// isLocalOnly is true if we only have local connections (flight mode)
|
// isLocalOnly is true if we only have local connections (flight mode)
|
||||||
const isLocalOnly = hasLocalConnection && !hasRemoteConnection
|
const isLocalOnly = hasLocalConnection && !hasRemoteConnection
|
||||||
@@ -141,13 +138,16 @@ export async function createHighlight(
|
|||||||
connectedRelays,
|
connectedRelays,
|
||||||
hasRemoteConnection,
|
hasRemoteConnection,
|
||||||
hasLocalConnection,
|
hasLocalConnection,
|
||||||
expectedSuccessRelays,
|
targetRelays,
|
||||||
isLocalOnly
|
isLocalOnly
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Use unified write service to store and publish
|
||||||
|
await publishEvent(relayPool, eventStore, signedEvent)
|
||||||
|
|
||||||
// Convert to Highlight with relay tracking info and return IMMEDIATELY
|
// Convert to Highlight with relay tracking info and return IMMEDIATELY
|
||||||
const highlight = eventToHighlight(signedEvent)
|
const highlight = eventToHighlight(signedEvent)
|
||||||
highlight.publishedRelays = expectedSuccessRelays
|
highlight.publishedRelays = targetRelays
|
||||||
highlight.isLocalOnly = isLocalOnly
|
highlight.isLocalOnly = isLocalOnly
|
||||||
|
|
||||||
return highlight
|
return highlight
|
||||||
|
|||||||
Reference in New Issue
Block a user