nsreed / ouronote

Real-time collaborative whiteboard web app built with Angular, GUN, and paper.js.
17 stars 1 forks source link

Basic offline access. #24

Open ultimape opened 3 years ago

ultimape commented 3 years ago

It would be nice to be able to load the website while offline and use the local data that my browser already knows about. Hypothetically once peers are available on the local network, we ought to be able to disconnect from the internet and still create and pull updates without the /gun peer being available.

It looks like this might be partly done via service workers, and since gun already uses the indexedDB for offline stuff we're like 80% of the way there.

nsreed commented 3 years ago

This will involve service workers for sure. Fortunately, there is well-established support for service workers in angular apps: https://angular.io/guide/service-worker-getting-started which I can hopefully also inject a full gun peer into. Service worker would be the only thing touching indexeddb (possibly fixing the multi-tab performance issues), each tab has an in-memory gun configuration, using the service worker's gun as a peer, which then talks to the relay/webrtc peers when it's available. There are projects with gun implemented in service workers using a similar pattern, though I forget which. Iris and/or Meething, I believe. I'll need to reach out to their discord folks to see if I can get some guidance.