conflict ok

todo conflict copy attach
This commit is contained in:
life
2015-02-01 01:07:40 +08:00
parent 00aac7c96a
commit 647ca66fa5
5 changed files with 22 additions and 8 deletions

4
node_modules/api.js generated vendored
View File

@@ -427,11 +427,13 @@ var Api = {
var ret = resp.body;
log('update note ret:');
log(ret);
if(Common.isOk(ret)) {
callback(ret);
/*
if(Common.isOk(ret)) {
} else {
callback(false);
}
*/
});
});
},

8
node_modules/note.js generated vendored
View File

@@ -574,10 +574,12 @@ var Note = {
// 将本地冲突的笔记复制一份
// serverNoteId
// TODO 附件也要复制一份
copyNoteForConfict: function(noteId, callback) {
var me = this;
me.getNote(noteId, function(note) {
if(!note) {
callback(false);
return;
}
// 新Id
@@ -646,6 +648,8 @@ var Note = {
// 复制一份
// [待测]
var changeConflicts = noteSyncInfo.changeConflicts;
console.log('changeConflicts');
console.log(changeConflicts);
for(var i in changeConflicts) {
var note = changeConflicts[i]; // note是本地的note
// 复制一份
@@ -659,8 +663,8 @@ var Note = {
Api.getNote(note.ServerNoteId, function(serverNote) {
serverNote.ServerNoteId = serverNote.NoteId;
serverNote.NoteId = note.NoteId;
me.updateNoteForceForConflict(serverNote, function(err, note2) {
if(!err) {
me.updateNoteForceForConflict(serverNote, function(note2) {
if(!note2) {
// 前端来处理, 全量sync时不用前端一个个处理
noteWeb && noteWeb.fixSyncConflict(note2, newNote);
}

9
node_modules/sync.js generated vendored
View File

@@ -559,16 +559,17 @@ var Sync = {
return cb();
});
} else {
console.log('local');
console.log(note);
// 更新
Api.updateNote(note, function(ret) {
if(!Common.isOk(ret)) {
console.log('updateNote eeeeeeeeeeror');
console.log(ret);
if(typeof ret == 'object') {
if(ret.msg == 'conflict') {
if(ret.Msg == 'conflict') {
console.log('updateNote 冲突-----------');
me._syncInfo.note.changeConflicts.push(note);
}
else if(newNote.Msg == 'notExists') {
else if(ret.Msg == 'notExists') {
// 可能服务器上已删除, 此时应该要作为添加而不是更新
me._syncInfo.note.changeNeedAdds.push(note);
}

View File

@@ -27,6 +27,9 @@ html, body {
border-radius: 10px;
border: 1px solid #000;
}
#noteItemList .item-conflict {
border: 1px solid #E4DA2D;
}
</style>
<!-- For Develop writting mod -->
<script>

View File

@@ -894,6 +894,9 @@ Note._renderNotes = function(notes, forNewNote, isShared, tang) { // 第几趟
tmp = $(tmp);
tmp.find(".item-blog").hide();
}
if(note.ConflictNoteId) {
$(tmp).addClass('item-conflict');
}
Note.noteItemListO.append(tmp);
/*
@@ -1978,6 +1981,7 @@ Note.fixSyncConflict = function(note, newNote) {
}
// 当前这个换成新复制的
target.attr('noteId', newNote.NoteId);
target.addClass('item-conflict');
// 重新render 左侧下, 因为有冲突了, 不要render内容啊
// 如果当前编辑的是这个笔记, 那切换到newNote上来