arj03 / ssb-browser-demo

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

Fix the 'Get msg' buttons #36

Closed KyleMaas closed 3 years ago

KyleMaas commented 3 years ago

If you load a thread containing messages which are outside of your graph, the thread view will show those messages with little "Get msg" links. If you clicked these, they would not work. This fixes that so they do work.

KyleMaas commented 3 years ago

No, that was needed to get the "Get msg" buttons working, because the ssb-msg template's getOOO calls SSB.getOOO, which tries to call SSB.connected. That fails because SSB.connected didn't exist, so I had to build an SSB.connected function based on inferring from SSB.getOOO what it was supposed to do.

arj03 commented 3 years ago

Thanks for opening this PR. I fixed it a bit differently so gonna close this.

KyleMaas commented 3 years ago

That actually doesn't fix one of the issues I ran into. I initially tried just getting rid of SSB.connected, like you did here:

https://github.com/arj03/ssb-browser-demo/commit/ca194bba462e094cce1093ba9fa6ffac49800f6a#diff-51b24f5be697ccf3d2198c3c57eb757a95ca3c20553f3edf0160af38a5287b5a

But I found that without that, if you clicked "Get msg" before it had actually connected to something (room, pub, etc.), then SSB.net and/or SSB.net.ooo would not exist, and you'd get an exception. Rebuilding SSB.connected like that resulted in it not only not trying to use those before they exist, but also made the request asynchronous. I figured that was how it was originally built to work and seemed like a good way to do it, and it worked very well for me.