mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-18 01:16:56 +00:00
reload notebook after synced
This commit is contained in:
39
node_modules/sync.js
generated
vendored
39
node_modules/sync.js
generated
vendored
@@ -186,11 +186,13 @@ var Sync = {
|
||||
Notebook.getNotebookByServerNotebookId(notebookId, function(notebookLocal) {
|
||||
// 2.1 本地没有, 表示是新建
|
||||
if(!notebookLocal) {
|
||||
console.log('add addNotebookForce...')
|
||||
console.log(' add addNotebookForce...', notebook.Title)
|
||||
// TODO
|
||||
Notebook.addNotebookForce(notebook, function(notebook) {
|
||||
// me._syncInfo.notebook.adds.push(notebook);
|
||||
me.fixSynced('notebook', 'adds', notebook);
|
||||
// 要最后一起添加, 因为有层级关系
|
||||
console.log(' ', notebook.Title)
|
||||
me._syncInfo.notebook.adds.push(notebook);
|
||||
// me.fixSynced('notebook', 'adds', notebook);
|
||||
canCall();
|
||||
});
|
||||
} else {
|
||||
@@ -209,8 +211,9 @@ var Sync = {
|
||||
// 这里都是用服务器端的数据, 不处理冲突
|
||||
Notebook.updateNotebookForce(notebook, notebookLocal, function(notebook) {
|
||||
if(notebook) {
|
||||
// me._syncInfo.notebook.updates.push(notebook);
|
||||
me.fixSynced('notebook', 'updates', notebook);
|
||||
// 前端一起渲染
|
||||
me._syncInfo.notebook.updates.push(notebook);
|
||||
// me.fixSynced('notebook', 'updates', notebook);
|
||||
}
|
||||
canCall();
|
||||
})
|
||||
@@ -226,7 +229,7 @@ var Sync = {
|
||||
return;
|
||||
}
|
||||
Api.getSyncNotebooks(afterUsn, me._notebookMaxEntry, function(notebooks) {
|
||||
console.log(' syncNotebook')
|
||||
console.log(' syncNotebook', notebooks)
|
||||
// console.log(notebooks);
|
||||
if(Common.isOk(notebooks)) {
|
||||
me._totalSyncNotebookNum += notebooks.length;
|
||||
@@ -663,6 +666,15 @@ var Sync = {
|
||||
}
|
||||
},
|
||||
|
||||
// 前端重新渲染
|
||||
fixSyncedNotebook: function () {
|
||||
var me = this;
|
||||
if(me.incrSyncStart) {
|
||||
console.log(' fixSyncedNotebook')
|
||||
Notebook.fixConflicts(me._syncInfo.notebook);
|
||||
}
|
||||
},
|
||||
|
||||
// 处理冲突
|
||||
fixConflicts: function(callback) {
|
||||
var me = this;
|
||||
@@ -676,7 +688,7 @@ var Sync = {
|
||||
// 不是fullSync
|
||||
if(me.incrSyncStart) {
|
||||
|
||||
Notebook.fixConflicts(me._syncInfo.notebook);
|
||||
// Notebook.fixConflicts(me._syncInfo.notebook);
|
||||
|
||||
Note.fixConflicts(me._syncInfo.note, function() {
|
||||
// 避免无限循环, 别send changes了
|
||||
@@ -773,9 +785,12 @@ var Sync = {
|
||||
// 同步笔记本
|
||||
me.syncNotebook(lastSyncUsn, function(ok) {
|
||||
if(ok) {
|
||||
me.fixSyncedNotebook();
|
||||
console.log(' incr notebook ok', lastSyncUsn);
|
||||
|
||||
me.addSyncProcessStatus(10);
|
||||
console.log(' incr note start');
|
||||
|
||||
// 同步笔记
|
||||
me.syncNote(lastSyncUsn, function(ok) {
|
||||
if(ok) {
|
||||
@@ -864,11 +879,13 @@ var Sync = {
|
||||
if(!newNotebook.NotebookId) {
|
||||
if(newNotebook.Msg == 'conflict') {
|
||||
// 没用, 前端不会处理的, 按理不会出现这种情况, 因为先sync
|
||||
me._syncInfo.notebook.conflicts.push(newNotebook);
|
||||
// me._syncInfo.notebook.conflicts.push(newNotebook);
|
||||
me.fixSynced('notebook', 'conflicts', newNotebook);
|
||||
} else if(newNotebook.Msg == 'notExists') {
|
||||
// 服务器端没有, 那么要作为添加
|
||||
// 可能服务器上已删除, 此时应该要作为添加而不是更新
|
||||
me._syncInfo.notebook.changeNeedAdds.push(notebook);
|
||||
// me.fixSynced('notebook', 'changeNeedAdds', notebook);
|
||||
}
|
||||
|
||||
// me.checkNeedIncSyncAgain(newNotebook.Usn);
|
||||
@@ -877,15 +894,17 @@ var Sync = {
|
||||
else {
|
||||
// 更新
|
||||
// TODO 后端updateNotebook只要传Usn回来即可
|
||||
console.log("返回来的notebook" + newNotebook.Title)
|
||||
console.log(" 返回来的notebook" + newNotebook.Title)
|
||||
|
||||
Notebook.updateNotebookForceForSendChange(notebook.NotebookId, newNotebook, function() {
|
||||
if(notebook.LocalIsNew) {
|
||||
// 没用
|
||||
me._syncInfo.notebook.changeAdds.push(newNotebook);
|
||||
// me.fixSynced('notebook', 'changeAdds', newNotebook);
|
||||
} else {
|
||||
// 没用
|
||||
me._syncInfo.notebook.updates.push(newNotebook);
|
||||
// me._syncInfo.notebook.updates.push(newNotebook);
|
||||
me.fixSynced('notebook', 'updates', newNotebook);
|
||||
}
|
||||
|
||||
// 这里才cb(), 因为先添加父, 再添加子
|
||||
|
Reference in New Issue
Block a user