automerge / mpl

a p2p document synchronization system for automerge
MIT License
281 stars 20 forks source link

interface for updating peer name #6

Open choxi opened 7 years ago

choxi commented 7 years ago

In Trellis, we're doing this to update our user's peer name:

  updatePeerName(value) {
    aMPL.config.name = value
    localStorage.setItem("peerName", value)

    // Force network reconnect
    this.props.store.dispatch({
      type: "OPEN_DOCUMENT",
      file: this.props.store.save()
    })
  }

It sets the shared config on aMPL, and then re-opens the current document as a hacky way of getting the network to reconnect and update all of our listeners in the omniview sidebar. It works for now, but something breaks if you change your peer name too many times too quickly.