在 incrSync 内控制本地账户的同步开关

This commit is contained in:
Xuesong Wang
2015-09-09 18:43:47 +08:00
parent a481a90fab
commit d9b42dbbc4
3 changed files with 15 additions and 8 deletions

4
src/node_modules/sync.js generated vendored
View File

@@ -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();

11
src/node_modules/user.js generated vendored
View File

@@ -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;

View File

@@ -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();