Skip to content

Commit

Permalink
send update contact requests one-by-one to prevent 412 etag conflicts
Browse files Browse the repository at this point in the history
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
  • Loading branch information
georgehrke committed Jan 24, 2019
1 parent f0380b8 commit eae3c15
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 40 deletions.
51 changes: 16 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"test:watch": "mocha-webpack -w --webpack-config webpack.test.js --interactive false --require tests/setup.js \"tests/js/**/*.spec.js\""
},
"dependencies": {
"asap": "^2.0.6",
"cdav-library": "github:nextcloud/cdav-library",
"debounce": "^1.2.0",
"downloadjs": "^1.4.7",
Expand All @@ -44,6 +43,7 @@
"nextcloud-server": "^0.15.9",
"nextcloud-vue": "^0.5.1",
"p-limit": "^2.1.0",
"p-queue": "^3.0.0",
"uuid": "^3.3.2",
"v-tooltip": "^2.0.0-rc.33",
"vue": "^2.5.22",
Expand Down
10 changes: 6 additions & 4 deletions src/components/ContactDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
<!-- using contact.key in the key and index as key to avoid conflicts between similar data and exact key -->
<contact-property v-for="(property, index) in sortedProperties" :key="`${index}-${contact.key}-${property.name}`" :index="index"
:sorted-properties="sortedProperties" :property="property" :contact="contact"
@updatedcontact="updateContact" />
@updatedcontact="debounceUpdateContact" />

<!-- addressbook change select - no last property because class is not applied here,
empty property because this is a required prop on regular property-select. But since
Expand All @@ -119,7 +119,7 @@

<script>
import debounce from 'debounce'
import asap from 'asap'
import PQueue from 'p-queue'

import rfcProps from 'Models/rfcProps'

Expand All @@ -129,6 +129,8 @@ import PropertySelect from './Properties/PropertySelect'
import PropertyGroups from './Properties/PropertyGroups'
import ContactAvatar from './ContactDetails/ContactDetailsAvatar'

const updateQueue = new PQueue({ concurrency: 1 })

export default {
name: 'ContactDetails',

Expand Down Expand Up @@ -309,7 +311,7 @@ export default {
},
set: function(data) {
this.contact.groups = data
this.updateContact()
this.debounceUpdateContact()
}
},

Expand Down Expand Up @@ -369,7 +371,7 @@ export default {
* photo, fn, org, title
*/
debounceUpdateContact: debounce(function(e) {
asap(this.updateContact())
updateQueue.add(this.updateContact)
}, 500),

// menu handling
Expand Down

2 comments on commit eae3c15

@binaryhq
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

conflict still exists on update of some fields.

<?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
  <s:exception>Sabre\DAV\Exception\PreconditionFailed</s:exception>
  <s:message>An If-Match header was specified, but none of the specified the ETags matched.</s:message>
  <s:header>If-Match</s:header>
</d:error>

@skjnldsv

This comment was marked as off-topic.

Please sign in to comment.