diff --git a/app/sync.js b/app/sync.js index 026fd61137d..69496417c71 100644 --- a/app/sync.js +++ b/app/sync.js @@ -176,6 +176,7 @@ module.exports.onSyncReady = (isFirstRun, e) => { } const appState = AppStore.getState() const sites = appState.get('sites') || new Immutable.List() + const seed = appState.get('seed') || new Immutable.List() /** * Sync a bookmark that has not been synced yet, first syncing the parent @@ -187,7 +188,8 @@ module.exports.onSyncReady = (isFirstRun, e) => { */ const folderToObjectId = {} const syncBookmark = (site) => { - if (!site || site.get('objectId') || folderToObjectId[site.get('folderId')] || !syncUtil.isSyncable('bookmark', site)) { + if (!site || (site.get('objectId') && seed.equals(site.get('originalSeed'))) || + folderToObjectId[site.get('folderId')] || !syncUtil.isSyncable('bookmark', site)) { return } diff --git a/docs/state.md b/docs/state.md index c56db050cdd..5c0caf1f89b 100644 --- a/docs/state.md +++ b/docs/state.md @@ -224,6 +224,7 @@ AppStore lastAccessedTime: number, // datetime.getTime() location: string, objectId: Array., + originalSeed: Array., // only set for bookmarks that have been synced before a sync profile reset parentFolderId: number, // set for bookmarks and bookmark folders only partitionNumber: number, // optionally specifies a specific session tags: [string], // empty, 'bookmark', 'bookmark-folder', 'pinned', or 'reader' diff --git a/js/stores/appStore.js b/js/stores/appStore.js index 4e6af56a2b7..4e191e09793 100644 --- a/js/stores/appStore.js +++ b/js/stores/appStore.js @@ -941,14 +941,16 @@ const handleAppAction = (action) => { case appConstants.APP_RESET_SYNC_DATA: const sessionStore = require('../../app/sessionStore') const syncDefault = Immutable.fromJS(sessionStore.defaultAppState().sync) + const originalSeed = appState.getIn(['sync', 'seed']) appState = appState.set('sync', syncDefault) appState.get('sites').forEach((site, key) => { - if (!site.has('objectId')) { return } - appState = appState.setIn(['sites', key], site.delete('objectId')) - }) - appState.get('siteSettings').forEach((site, key) => { - if (!site.has('objectId')) { return } - appState = appState.setIn(['siteSettings', key], site.delete('objectId')) + if (site.has('objectId') && syncUtil.isSyncable('bookmark', site)) { + // Remember which profile this bookmark was originally synced to. + // Since old bookmarks should be synced when a new profile is created, + // we have to keep track of which profile already has these bookmarks + // or else the old profile may have these bookmarks duplicated. #7405 + appState = appState.setIn(['sites', key, 'originalSeed'], originalSeed) + } }) break case appConstants.APP_SHOW_DOWNLOAD_DELETE_CONFIRMATION: