From d9b42dbbc496fdf5670a467c424ff43c974e832d Mon Sep 17 00:00:00 2001 From: Xuesong Wang Date: Wed, 9 Sep 2015 18:43:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=20incrSync=20=E5=86=85=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E6=9C=AC=E5=9C=B0=E8=B4=A6=E6=88=B7=E7=9A=84=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/node_modules/sync.js | 4 ++++ src/node_modules/user.js | 11 +++++++---- src/public/js/app/page.js | 8 ++++---- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/node_modules/sync.js b/src/node_modules/sync.js index 7ab8cfc0..29f2574a 100644 --- a/src/node_modules/sync.js +++ b/src/node_modules/sync.js @@ -612,6 +612,10 @@ var Sync = { me.incrSyncStart = false; }, incrSync: function(again) { + if (User.isLocal()) { + console.log('no sync for local account'); + return; + } var me = this; me._stop = false; me._initSyncInfo(); diff --git a/src/node_modules/user.js b/src/node_modules/user.js index f7200f24..6f86d89d 100644 --- a/src/node_modules/user.js +++ b/src/node_modules/user.js @@ -28,7 +28,7 @@ User = { LastSyncTime: null, // add local account support flag // see https://github.com/leanote/desktop-app/issues/36 - isLocal: null, + local: null, // 登录后保存当前 setCurUser: function(user) { var me = this; @@ -38,7 +38,7 @@ User = { this.email = user.Email; this.username = user.Username; this.host = user.Host; // http://leanote.com, http://localhost - this.isLocal = user.IsLocal; + this.local = user.IsLocal; // 保存到数据库中 this.saveCurUser(user); @@ -133,7 +133,7 @@ User = { me.LastSyncUsn = user.LastSyncUsn; me.LastSyncTime = user.LastSyncTime; me.host = user.Host; - me.isLocal = user.IsLocal; + me.local = user.IsLocal; Evt.setHost(me.host); // 全局配置也在user中, 到web端 @@ -239,7 +239,10 @@ User = { callback(); }); }, - + isLocal: function() { + var me = this; + return me.local; + }, // send changes要用 getLastSyncUsn: function() { var me = this; diff --git a/src/public/js/app/page.js b/src/public/js/app/page.js index e18cb5b2..05f8d2f3 100644 --- a/src/public/js/app/page.js +++ b/src/public/js/app/page.js @@ -1415,16 +1415,16 @@ function initPage(initedCallback) { UserService.init(function(userInfo) { if(userInfo) { UserInfo = userInfo; - // 之前已同步过, 就不要full sync了 - if('LastSyncUsn' in UserInfo && UserInfo['LastSyncUsn'] > 0) { - _init(); //no full sync for local account //see https://github.com/leanote/desktop-app/issues/36 - } else if (UserInfo.IsLocal) { + if (UserInfo.IsLocal) { console.log('skip full sync for local account'); _init(); $('#syncRefresh').off ('click'); $('#syncRefresh').hide (); + }// 之前已同步过, 就不要full sync了 + else if('LastSyncUsn' in UserInfo && UserInfo['LastSyncUsn'] > 0) { + _init(); } else { fullSync(function() { _init();