Skip to content
This repository has been archived by the owner on Jul 31, 2020. It is now read-only.

Commit

Permalink
fix discrepancy between Android and Laptop RESOLVED_SYNC_RECORDS
Browse files Browse the repository at this point in the history
browser-laptop sends 'parentFolderObjectId: []' for top-level folders whereas
android sends 'parentFolderObjectId: null'. for consistency, they should just
be normalized to be the same value.

fix #107
  • Loading branch information
diracdeltas committed Jul 6, 2017
1 parent 04fd995 commit 841c258
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
17 changes: 17 additions & 0 deletions client/recordUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,17 @@ const pickFields = (object, fields) => {
}, {})
}

/**
* Converts [] parentFolderObjectIds fields to null in place. Fix #107.
* @param {Object} record
*/
const normalizeBookmark = (record) => {
if (record && record.bookmark && record.bookmark.parentFolderObjectId &&
!record.bookmark.parentFolderObjectId.length) {
record.bookmark.parentFolderObjectId = null
}
}

/**
* Given a SyncRecord and a browser's matching existing object, resolve
* objectData to the final object that should be applied by the browser.
Expand Down Expand Up @@ -262,6 +273,12 @@ const mergeRecords = (recordsAndObjects) => {
*/
module.exports.resolveRecords = (recordsAndExistingObjects) => {
let resolvedRecords = []
recordsAndExistingObjects.forEach((item) => {
if (item) {
normalizeBookmark(item[0])
normalizeBookmark(item[1])
}
})
const merged = mergeRecords(recordsAndExistingObjects)
merged.forEach(([record, existingObject]) => {
const resolved = this.resolve(record, existingObject)
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"standard": {
"ignore": [
"test/crypto.js",
"test/client/data/*.js",
"bundles/*.js",
"client/polyfill/*.js",
"lib/api.proto.js",
Expand Down
2 changes: 2 additions & 0 deletions test/client/fixtures/resolveAndroid.js

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

1 change: 1 addition & 0 deletions test/client/fixtures/resolveLaptop.js

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

Loading

0 comments on commit 841c258

Please sign in to comment.