arj03 / ssb-browser-demo

A secure scuttlebutt client interface running in the browser
Other
58 stars 11 forks source link

Implement SSB.connected() using events #57

Closed KyleMaas closed 3 years ago

KyleMaas commented 3 years ago

Implements the missing SSB.connected() function and adds it back into the path for SSB.getOOO(). This actually seems to work quite well - tested by loading a thread with a message outside of my graph, refreshing the page, and clicking "Get msg" before it connected. It dutifully waited for the connection and then loaded the message.

Fixes #38.

KyleMaas commented 3 years ago

There. Reference counting for both SSB.connected() as well as the ui/connected.js indicator. Additionally, this fixes another use case:

  1. Peer 1 connects.
  2. SSB.connected() is called to register a callback. Since isConnected == false at this point, events are registered but callback is not run until another peer is connected.

For cases of one peer, the callback would never be run in this case. So, this fixes that as well.

arj03 commented 3 years ago

Glorious!