peer-pad icon indicating copy to clipboard operation
peer-pad copied to clipboard

multiple tabs

Open pgte opened this issue 8 years ago • 3 comments

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

pgte avatar Oct 03 '17 09:10 pgte

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...

jimpick avatar Jan 12 '19 04:01 jimpick

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 avatar Feb 13 '19 18:02 jimpick

@jimpick That's super! 😍

pgte avatar Feb 14 '19 09:02 pgte