peer-pad
peer-pad copied to clipboard
multiple tabs
When you have multiple tabs open, multiple IPFS nodes with the same id are opened, which causes havoc.
Agreed steps (with @diasdavid) to solve this:
- don't automatically start IPFS on boot
- if IPFS lock file is present, ask user to close tabs if they're opened, and opt to continue
- "continue" will start IPFS
- when closing the browser tab, close IPFS, which removes the file
I found an interesting implementation of a "cross-tab-client" that uses a leader election so that only one tab is managing the storage and web sockets:
https://github.com/logux/client/blob/master/cross-tab-client.js
We might be able to do something similar...
I experimented with wrapping peer-base with logux for use within an iframe (using nanostate for a state machine), and it worked out really, really well for multiple tabs.
https://github.com/jimpick/multiple-tabs-logux-peer-base/blob/master/index.js
Here is a demo that uses it (via the iframe):
https://bafybeid7pdb56figg7hv6uxyt4tnovb4zw54vmtqcu2oc6nkzz2mf6r2s4.lunet.v6z.me/
@jimpick That's super! 😍