@@ -125,8 +125,15 @@ const appStoreChangeCallback = function (diffs) {
125
125
const entryJS = entry . toJS ( )
126
126
entryJS . objectId = entryJS . objectId || syncUtil . newObjectId ( statePath )
127
127
128
- sendSyncRecords ( backgroundSender , action ,
129
- [ isSite ? syncUtil . createSiteData ( entryJS ) : syncUtil . createSiteSettingsData ( statePath [ 1 ] , entryJS ) ] )
128
+ let record = null
129
+ if ( type === STATE_SITES . BOOKMARKS || type === STATE_SITES . BOOKMARK_FOLDERS ) {
130
+ record = syncUtil . createBookmarkData ( entryJS )
131
+ } else if ( type === STATE_SITES . HISTORY_SITES ) {
132
+ record = syncUtil . createHistorySiteData ( entryJS )
133
+ } else {
134
+ record = syncUtil . createSiteSettingsData ( statePath [ 1 ] , entryJS )
135
+ }
136
+ sendSyncRecords ( backgroundSender , action , [ record ] )
130
137
}
131
138
}
132
139
} )
@@ -212,9 +219,10 @@ const dispatcherCallback = (action) => {
212
219
return
213
220
}
214
221
switch ( action . actionType ) {
222
+ // Currently triggered only by bookmarksState and bookmarkFoldersState.
215
223
case syncConstants . SYNC_REMOVE_SITE :
216
224
sendSyncRecords ( backgroundSender , writeActions . DELETE ,
217
- [ syncUtil . createSiteData ( action . item . toJS ( ) ) ] )
225
+ [ syncUtil . createBookmarkData ( action . item . toJS ( ) ) ] )
218
226
break
219
227
case syncConstants . SYNC_CLEAR_HISTORY :
220
228
backgroundSender . send ( syncMessages . DELETE_SYNC_CATEGORY , CATEGORY_MAP . historySite . categoryName )
@@ -273,7 +281,7 @@ module.exports.onSyncReady = (isFirstRun, e) => {
273
281
* Sync a bookmark that has not been synced yet, first syncing the parent
274
282
* folder if needed. For folders, set and memoize folderId to ensure
275
283
* consistent parentFolderObjectIds.
276
- * Otherwise siteUtil.createSiteData () will generate new objectIds every
284
+ * Otherwise syncUtil.createBookmarkData () will generate new objectIds every
277
285
* call; there's not enough time to dispatch id updates to appStore.sites.
278
286
* @param {Immutable.Map } site
279
287
*/
@@ -300,13 +308,13 @@ module.exports.onSyncReady = (isFirstRun, e) => {
300
308
if ( ! folderToObjectId [ parentFolderId ] ) {
301
309
const folderResult = bookmarkFoldersState . getFolder ( appState , parentFolderId )
302
310
if ( ! folderResult . isEmpty ( ) ) {
303
- syncBookmark ( folderResult [ 1 ] , appState )
311
+ syncBookmark ( folderResult , appState )
304
312
}
305
313
}
306
314
bookmarkJS . parentFolderObjectId = folderToObjectId [ parentFolderId ]
307
315
}
308
316
309
- const record = syncUtil . createSiteData ( bookmarkJS , appState )
317
+ const record = syncUtil . createBookmarkData ( bookmarkJS , appState )
310
318
const folderId = bookmark . get ( 'folderId' )
311
319
if ( typeof folderId === 'number' ) {
312
320
folderToObjectId [ folderId ] = record . objectId
@@ -338,7 +346,7 @@ module.exports.onSyncReady = (isFirstRun, e) => {
338
346
// might not be synced.
339
347
const siteSettings =
340
348
appState . get ( 'siteSettings' ) . filter ( ( value , key ) => {
341
- return ! value . get ( 'objectId' ) && syncUtil . isSyncable ( 'siteSetting' , value )
349
+ return ! value . get ( 'objectId' ) && syncUtil . isSyncableSiteSetting ( value )
342
350
} ) . toJS ( )
343
351
if ( siteSettings ) {
344
352
const siteSettingsData = Object . keys ( siteSettings ) . map ( ( item ) => {
0 commit comments