mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-17 08:38:18 +00:00
在 incrSync 内控制本地账户的同步开关
This commit is contained in:
4
src/node_modules/sync.js
generated
vendored
4
src/node_modules/sync.js
generated
vendored
@@ -612,6 +612,10 @@ var Sync = {
|
|||||||
me.incrSyncStart = false;
|
me.incrSyncStart = false;
|
||||||
},
|
},
|
||||||
incrSync: function(again) {
|
incrSync: function(again) {
|
||||||
|
if (User.isLocal()) {
|
||||||
|
console.log('no sync for local account');
|
||||||
|
return;
|
||||||
|
}
|
||||||
var me = this;
|
var me = this;
|
||||||
me._stop = false;
|
me._stop = false;
|
||||||
me._initSyncInfo();
|
me._initSyncInfo();
|
||||||
|
11
src/node_modules/user.js
generated
vendored
11
src/node_modules/user.js
generated
vendored
@@ -28,7 +28,7 @@ User = {
|
|||||||
LastSyncTime: null,
|
LastSyncTime: null,
|
||||||
// add local account support flag
|
// add local account support flag
|
||||||
// see https://github.com/leanote/desktop-app/issues/36
|
// see https://github.com/leanote/desktop-app/issues/36
|
||||||
isLocal: null,
|
local: null,
|
||||||
// 登录后保存当前
|
// 登录后保存当前
|
||||||
setCurUser: function(user) {
|
setCurUser: function(user) {
|
||||||
var me = this;
|
var me = this;
|
||||||
@@ -38,7 +38,7 @@ User = {
|
|||||||
this.email = user.Email;
|
this.email = user.Email;
|
||||||
this.username = user.Username;
|
this.username = user.Username;
|
||||||
this.host = user.Host; // http://leanote.com, http://localhost
|
this.host = user.Host; // http://leanote.com, http://localhost
|
||||||
this.isLocal = user.IsLocal;
|
this.local = user.IsLocal;
|
||||||
// 保存到数据库中
|
// 保存到数据库中
|
||||||
this.saveCurUser(user);
|
this.saveCurUser(user);
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ User = {
|
|||||||
me.LastSyncUsn = user.LastSyncUsn;
|
me.LastSyncUsn = user.LastSyncUsn;
|
||||||
me.LastSyncTime = user.LastSyncTime;
|
me.LastSyncTime = user.LastSyncTime;
|
||||||
me.host = user.Host;
|
me.host = user.Host;
|
||||||
me.isLocal = user.IsLocal;
|
me.local = user.IsLocal;
|
||||||
Evt.setHost(me.host);
|
Evt.setHost(me.host);
|
||||||
|
|
||||||
// 全局配置也在user中, 到web端
|
// 全局配置也在user中, 到web端
|
||||||
@@ -239,7 +239,10 @@ User = {
|
|||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
isLocal: function() {
|
||||||
|
var me = this;
|
||||||
|
return me.local;
|
||||||
|
},
|
||||||
// send changes要用
|
// send changes要用
|
||||||
getLastSyncUsn: function() {
|
getLastSyncUsn: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
@@ -1415,16 +1415,16 @@ function initPage(initedCallback) {
|
|||||||
UserService.init(function(userInfo) {
|
UserService.init(function(userInfo) {
|
||||||
if(userInfo) {
|
if(userInfo) {
|
||||||
UserInfo = userInfo;
|
UserInfo = userInfo;
|
||||||
// 之前已同步过, 就不要full sync了
|
|
||||||
if('LastSyncUsn' in UserInfo && UserInfo['LastSyncUsn'] > 0) {
|
|
||||||
_init();
|
|
||||||
//no full sync for local account
|
//no full sync for local account
|
||||||
//see https://github.com/leanote/desktop-app/issues/36
|
//see https://github.com/leanote/desktop-app/issues/36
|
||||||
} else if (UserInfo.IsLocal) {
|
if (UserInfo.IsLocal) {
|
||||||
console.log('skip full sync for local account');
|
console.log('skip full sync for local account');
|
||||||
_init();
|
_init();
|
||||||
$('#syncRefresh').off ('click');
|
$('#syncRefresh').off ('click');
|
||||||
$('#syncRefresh').hide ();
|
$('#syncRefresh').hide ();
|
||||||
|
}// 之前已同步过, 就不要full sync了
|
||||||
|
else if('LastSyncUsn' in UserInfo && UserInfo['LastSyncUsn'] > 0) {
|
||||||
|
_init();
|
||||||
} else {
|
} else {
|
||||||
fullSync(function() {
|
fullSync(function() {
|
||||||
_init();
|
_init();
|
||||||
|
Reference in New Issue
Block a user