Browse Source

feat: add lastSync field instead of timestamp

lastSync is the last sync-succeeded timestamp,
while timestamp is the last modified timestamp.
Gerald 9 years ago
parent
commit
68456d9f9c
2 changed files with 4 additions and 3 deletions
  1. 3 2
      src/background/sync/index.js
  2. 1 1
      src/options/views/sync-service.js

+ 3 - 2
src/background/sync/index.js

@@ -107,7 +107,7 @@ var sync = function () {
         displayName: service.displayName,
         authState: service.authState.get(),
         syncState: service.syncState.get(),
-        timestamp: service.config.get('meta', {}).timestamp,
+        lastSync: service.config.get('meta', {}).lastSync,
       };
     });
   }
@@ -435,8 +435,9 @@ var sync = function () {
           }
           if (!local.meta.timestamp || getRemote.length || delLocal.length || remoteChanged || outdated) {
             local.meta.timestamp = remote.meta.timestamp;
-            _this.config.set('meta', local.meta);
           }
+          local.meta.lastSync = Date.now();
+          _this.config.set('meta', local.meta);
           return Promise.all(promises);
         }));
         return Promise.all(promises.map(function (promise) {

+ 1 - 1
src/options/views/sync-service.js

@@ -8,7 +8,7 @@ var SyncServiceView = BaseView.extend({
     var it = this.model.toJSON();
     it.enabled = _.options.get(it.name + 'Enabled');
     it.syncing = it.syncState === 'syncing';
-    it.lastSync = it.timestamp && new Date(it.timestamp).toLocaleString();
+    if (it.lastSync) it.lastSync = new Date(it.lastSync).toLocaleString();
     this.$el.html(this.templateFn(it));
   },
   retry: function () {