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

fix discrepancy between Android and Laptop RESOLVED_SYNC_RECORDS #126

Merged
merged 1 commit into from
Jul 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Contributor

Choose a reason for hiding this comment

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

is the item truthiness check necessary? in mergeRecords() we do a similar forEach() while assuming the values of item[0] and item[1].

Copy link
Member Author

Choose a reason for hiding this comment

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

maybe not necessary at the moment but better to be safe here since resolveRecords is an exported function

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/fixtures/*.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