Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #8409 from brave/fix/bookmarks-sync-once-only
Browse files Browse the repository at this point in the history
Don't reupload bookmarks to Sync every load
  • Loading branch information
ayumi authored Apr 20, 2017
2 parents 268b6ca + 6821af5 commit f4d52d1
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions app/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,18 @@ module.exports.onSyncReady = (isFirstRun, e) => {
* @param {Immutable.Map} site
*/
const folderToObjectId = {}
const syncBookmark = (site) => {
if (!site || (site.get('objectId') && seed.equals(site.get('originalSeed'))) ||
folderToObjectId[site.get('folderId')] || !syncUtil.isSyncable('bookmark', site)) {
return
const shouldSyncBookmark = (site) => {
if (!site) { return false }
// originalSeed is set on reset to prevent synced bookmarks on a device
// from being re-synced.
const originalSeed = site.get('originalSeed')
if (site.get('objectId') && (!originalSeed || seed.equals(originalSeed))) {
return false
}

if (folderToObjectId[site.get('folderId')]) { return false }
return syncUtil.isSyncable('bookmark', site)
}
const syncBookmark = (site) => {
const siteJS = site.toJS()

const parentFolderId = site.get('parentFolderId')
Expand All @@ -218,7 +224,8 @@ module.exports.onSyncReady = (isFirstRun, e) => {
}

// Sync bookmarks that have not been synced yet.
siteUtil.getBookmarks(sites).sortBy(site => site.get('order'))
siteUtil.getBookmarks(sites).filter(site => shouldSyncBookmark(site))
.sortBy(site => site.get('order'))
.forEach(syncBookmark)

// Sync site settings that have not been synced yet
Expand Down

0 comments on commit f4d52d1

Please sign in to comment.