From 6821af5e541d1d092e6d448d1c6c5a1b8107d727 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EF=BD=81=EF=BD=99=EF=BD=95=EF=BD=8D=EF=BD=89=C2=A0=20?= =?UTF-8?q?=EF=BD=99=EF=BD=95?= Date: Thu, 20 Apr 2017 02:14:18 +0000 Subject: [PATCH] Don't reupload bookmarks to Sync every load Fix #8408 Auditors: @diracdeltas @bbondy Test Plan: 1. Open Brave and enable Sync. 2. Visit archive.org and bookmark it. Terminal should show that it synced. 3. Close archive.org tab. 4. Restart Brave. 5. Examine terminal. Bookmark shouldn't be re-synced. --- app/sync.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/app/sync.js b/app/sync.js index 0fdd551aa2d..fdb8c0eeea0 100644 --- a/app/sync.js +++ b/app/sync.js @@ -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') @@ -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