mirror of
https://github.com/leanote/desktop-app.git
synced 2025-12-23 01:00:08 +08:00
网络断开时, auth检查
sync还有问题
This commit is contained in:
22
node_modules/note.js
generated
vendored
22
node_modules/note.js
generated
vendored
@@ -42,7 +42,7 @@ var Note = {
|
||||
updateNoteOrContent: function(noteOrContent, callback) {
|
||||
var userId = User.getCurActiveUserId();
|
||||
noteOrContent['UserId'] = userId;
|
||||
log('update');
|
||||
console.log('updateNoteOrContent: ' + noteOrContent.NoteId);
|
||||
var date = new Date();
|
||||
noteOrContent.UpdatedTime = date;
|
||||
|
||||
@@ -445,6 +445,7 @@ var Note = {
|
||||
// note是服务器传过来的, 需要处理下fix
|
||||
// NoteId, ServerNoteId, NotebookId(本地的)
|
||||
addNoteForce: function(note, callback) {
|
||||
var me = this;
|
||||
note.InitSync = true; // 刚同步完, 表示content, images, attach没有同步
|
||||
note.IsDirty = false;
|
||||
note.ServerNoteId = note.NoteId;
|
||||
@@ -674,7 +675,7 @@ var Note = {
|
||||
|
||||
// 将本地冲突的笔记复制一份
|
||||
// serverNoteId
|
||||
// TODO 附件也要复制一份
|
||||
// 附件也要复制一份
|
||||
copyNoteForConfict: function(noteId, callback) {
|
||||
var me = this;
|
||||
me.getNote(noteId, function(note) {
|
||||
@@ -684,6 +685,7 @@ var Note = {
|
||||
}
|
||||
// 新Id
|
||||
delete note['_id'];
|
||||
delete note['ServerNoteId'];
|
||||
note.NoteId = Common.objectId();
|
||||
note.ConflictNoteId = noteId; // 与noteId有冲突
|
||||
note.ConflictTime = new Date(); // 发生冲突时间
|
||||
@@ -811,12 +813,8 @@ var Note = {
|
||||
// notes是服务器的数据, 与本地的有冲突
|
||||
// 1) 将本地的note复制一份
|
||||
// 2) 服务器替换之前
|
||||
fixConflicts: function(noteSyncInfo, noteWeb, callback) {
|
||||
fixConflicts: function(noteSyncInfo, callback) {
|
||||
var me = this;
|
||||
// 处理冲突
|
||||
if(!noteWeb) {
|
||||
return callback && callback();
|
||||
}
|
||||
|
||||
var conflictNotes = noteSyncInfo.conflicts;
|
||||
log('fix note conflicts');
|
||||
@@ -832,7 +830,7 @@ var Note = {
|
||||
me.updateNoteForceForConflict(note, function(note2) {
|
||||
if(note2) {
|
||||
// 前端来处理, 全量sync时不用前端一个个处理
|
||||
noteWeb && noteWeb.fixSyncConflict(note2, newNote);
|
||||
Web.fixSyncConflictNote(note2, newNote);
|
||||
}
|
||||
cb();
|
||||
});
|
||||
@@ -870,7 +868,7 @@ var Note = {
|
||||
me.updateNoteForceForConflict(serverNote, function(note2) {
|
||||
if(!note2) {
|
||||
// 前端来处理, 全量sync时不用前端一个个处理
|
||||
noteWeb && noteWeb.fixSyncConflict(note2, newNote);
|
||||
Web.fixSyncConflict(note2, newNote);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -893,16 +891,16 @@ var Note = {
|
||||
var addNotes = noteSyncInfo.adds;
|
||||
log('has add...');
|
||||
log(addNotes);
|
||||
noteWeb.addSync(addNotes);
|
||||
Web.addSyncNote(addNotes);
|
||||
|
||||
log('has updates...');
|
||||
log(noteSyncInfo);
|
||||
log(noteSyncInfo.updates);
|
||||
// 处理更新的
|
||||
noteWeb.updateSync(noteSyncInfo.updates);
|
||||
Web.updateSyncNote(noteSyncInfo.updates);
|
||||
|
||||
// 处理删除的
|
||||
noteWeb.deleteSync(noteSyncInfo.deletes);
|
||||
Web.deleteSyncNote(noteSyncInfo.deletes);
|
||||
},
|
||||
|
||||
// 得到所有文件要传的基本信息和传送的数据
|
||||
|
||||
Reference in New Issue
Block a user