Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conflicts in single-player mode #7

Closed
choxi opened this issue May 11, 2017 · 3 comments
Closed

conflicts in single-player mode #7

choxi opened this issue May 11, 2017 · 3 comments

Comments

@choxi
Copy link
Contributor

choxi commented May 11, 2017

I'm somehow creating conflicts even when Trellis and DocInspector are disconnected. To reproduce:

  1. Open Trellis (from conflicts branch)
  2. Disconnect Trellis and DocInspector
  3. Move any card from one column to another on Trellis

The card that was moved now has a _conflicts property that looks like this:

// card._conflicts
{
  "listId": {}
}

So it flags listId as being in conflict, but then the conflicts object is empty. The peer_action created looks like this:

{
  "by": "trellis",
  "clock": {
    "trellis": 19
  },
  "action": "set",
  "target": "cd5649a6-3130-4872-9533-72c0c3bc9a6c",
  "key": "listId",
  "value": 1
}

For some reason, the DocInspector does not create the same conflict even though I'm using the same setter pattern:

// Trellis
updateCard(id, attributes) {
  this.tesseract.root.cards[id].listId = attributes.listId
}

// DocInspector
updateListId(event) {
  let index = parseInt(event.target.name.replace(/[^0-9]/g, ''))
  let newListId = parseInt(event.target.value)

  if (newListId >= 0 && newListId <= 2) {
    this.tesseract.root.cards[index].listId = newListId
    this.setState(this.tesseract.getState())
  }
}

Is it possible that Tesseract is still flagging a conflict with DocInspector even though they're both "paused"?

@ept
Copy link
Member

ept commented May 11, 2017

I think the intention is that

card._conflicts == {listId: {}}

means the same as

card._conflicts == {}

i.e. that there are no conflicts. However, I agree that this is confusing. In the immutable version of Tesseract I wrote it such that it always returns an empty conflicts object if there are no conflicts, but it's possible that the version you're currently using is inconsistent.

We should tidy this up, but in the meantime, can you consider it to be a conflict only if card._conflicts.fieldname is a non-empty object?

@choxi
Copy link
Contributor Author

choxi commented May 11, 2017

Oh I hadn't even considered that, I was expecting the _conflicts object to be empty. No problem though, I can work around that for now!

@ept
Copy link
Member

ept commented Jun 22, 2017

Since immutable tesseract landed, the _conflicts object only contains fields that actually have conflicts, so I'm closing this issue.

@ept ept closed this as completed Jun 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants