fix(nostr-client): restore subscriptions and availability on relay reconnect
When a relay reconnects after a disconnect, all active subscriptions (including Lightning.Pub RPC listener) are now re-established on the new relay instance. Previously subscriptions were lost permanently. Also publishes availability broadcast immediately on reconnect instead of waiting up to 5 minutes for the next heartbeat. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ea72623cde
commit
b6521c4788
2 changed files with 41 additions and 0 deletions
|
|
@ -116,6 +116,12 @@ export function useAvailabilityBroadcast(options: UseAvailabilityBroadcastOption
|
|||
// Publish immediately on setup
|
||||
publish(computeSnapshot())
|
||||
|
||||
// Re-publish immediately when relay reconnects (don't wait for next heartbeat)
|
||||
nostrClient.on('connect', () => {
|
||||
console.log('[Availability] Relay reconnected, publishing immediately')
|
||||
publish(computeSnapshot())
|
||||
})
|
||||
|
||||
function stop() {
|
||||
clearInterval(heartbeatInterval)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue