Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #34160 from weilonge/seanlee/DataSync/master/Bug12…
Browse files Browse the repository at this point in the history
…56227

Bug 1256227 - Add last_modified property into Tabs sync record. r=michielbdejong
  • Loading branch information
weilonge committed Mar 15, 2016
2 parents 19d23ce + f6906d6 commit 3c8d637
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 7 additions & 4 deletions apps/sync/js/adapters/tabs.js
Expand Up @@ -316,15 +316,18 @@ DataAdapters.tabs = {
}
**/

_updateTab(payload, userid) {
_updateDeviceTabsList(payload, last_modified, userid) {
if (!payload.clientName || typeof payload.clientName !== 'string' ||
!payload.id || typeof payload.id !== 'string' ||
!payload.tabs || !Array.isArray(payload.tabs)) {
console.warn('Incorrect payload?', payload);
return Promise.resolve();
}

return TabsHelper.addTab(payload, userid);
var record = payload;
record.timestamp = last_modified;

return TabsHelper.addTab(record, userid);
},

_next(remoteRecords, lastModifiedTime, userid, cursor) {
Expand All @@ -339,8 +342,8 @@ DataAdapters.tabs = {
return Promise.resolve();
}

return this._updateTab(remoteRecords[cursor].payload, userid)
.then(() => {
return this._updateDeviceTabsList(remoteRecords[cursor].payload,
remoteRecords[cursor].last_modified, userid).then(() => {
return this._next(remoteRecords, lastModifiedTime, userid, cursor + 1);
});
},
Expand Down
2 changes: 2 additions & 0 deletions apps/sync/test/unit/adapters/tabs_test.js
Expand Up @@ -44,6 +44,8 @@ suite('sync/adapters/tabs >', function() {

function verifyTabs(remoteItem, localItem) {
assert.deepEqual(remoteItem.payload, localItem);
assert.isNumber(localItem.timestamp);
assert.equal(remoteItem.last_modified, localItem.timestamp);
}

function testDataGenerator(initIndex, initDate, count) {
Expand Down

0 comments on commit 3c8d637

Please sign in to comment.