t4t5 / nostr-react

React Hooks for Nostr 🦤
MIT License
85 stars 14 forks source link

dynamic management of relays #15

Closed wds4 closed 1 year ago

wds4 commented 1 year ago

Reconnect to any relay that needs it whenever there is a change in relayUrls.

This is similar to this pull request by @aussedatlo except that I have added a check to make sure that we don't try to reconnect to a relay if it is already connected. See this comment for discussion. To do this I create a new array aConnectedRelays which I derive from connectedRelays.

I have also added a check to disconnect from any relay that has been removed from relayUrls. However, that part of the pull request is incomplete. I am able to log to the console the correct url(s) that needs closing but haven't yet gotten the disconnect command (relay.close() ??) to work yet.

This does not address the issue of reconnecting to spontaneously dropped relays, which is addressed by my other PR and can be considered separately.

wds4 commented 1 year ago

I'm closing this pull request, as I think @aussedatlo's pull request up through this commit solves this issue.