避免trash的笔记一同步变成不是trash的了

This commit is contained in:
life
2015-11-01 11:04:47 +08:00
parent 91bc298d94
commit 580220eee4
2 changed files with 38 additions and 18 deletions

12
node_modules/note.js generated vendored
View File

@@ -704,13 +704,19 @@ var Note = {
note.InitSync = true; // 刚同步完, 表示content, images, attach没有同步 note.InitSync = true; // 刚同步完, 表示content, images, attach没有同步
note.IsDirty = false; note.IsDirty = false;
note.LocalIsDelete = false; note.LocalIsDelete = false;
note.IsTrash = false; // 这里, 悲剧, 一个大BUG, 应该和server端IsTrash一致,
// 不然同步的时候将IsTrash的笔记同步到非IsTrash, 2015/10/31 fixed 谢谢 3601提供的信息
// note.IsTrash = false;
if (typeof note.IsTrash == 'boolean') {
note.IsTrash = note.IsTrash;
}
else {
note.IsTrash = false;
}
note.ServerNoteId = note.NoteId; note.ServerNoteId = note.NoteId;
note.NoteId = Common.objectId(); note.NoteId = Common.objectId();
console.error('add note force' + note.Title + Common.goNowToDate(note.CreatedTime));
note.CreatedTime = Common.goNowToDate(note.CreatedTime); note.CreatedTime = Common.goNowToDate(note.CreatedTime);
note.UpdatedTime = Common.goNowToDate(note.UpdatedTime); note.UpdatedTime = Common.goNowToDate(note.UpdatedTime);

View File

@@ -745,9 +745,9 @@ Note.reRenderNote = function(noteId) {
NoteService.getNoteContent(noteId, function(noteContent) { NoteService.getNoteContent(noteId, function(noteContent) {
if(noteContent) { if(noteContent) {
Note.setNoteCache(noteContent, false); Note.setNoteCache(noteContent, false);
Attach.renderNoteAttachNum(noteId, true);
// 确保重置的是当前note // 确保重置的是当前note
if (Note.curNoteId === noteId) { if (Note.curNoteId === noteId) {
Attach.renderNoteAttachNum(noteId, true);
Note.renderNoteContent(noteContent, true); Note.renderNoteContent(noteContent, true);
} }
} }
@@ -789,9 +789,7 @@ Note.renderChangedNote = function(changedNote) {
$leftNoteNav.find(".item-thumb").remove(); // 以前有, 现在没有了 $leftNoteNav.find(".item-thumb").remove(); // 以前有, 现在没有了
$leftNoteNav.removeClass("item-image"); $leftNoteNav.removeClass("item-image");
} }
};
}
// 清空右侧note信息, 可能是共享的, // 清空右侧note信息, 可能是共享的,
// 此时需要清空只读的, 且切换到note edit模式下 // 此时需要清空只读的, 且切换到note edit模式下
@@ -822,7 +820,7 @@ Note.clearAll = function() {
Note.clearNoteInfo(); Note.clearNoteInfo();
Note.clearNoteList(); Note.clearNoteList();
} };
// render到编辑器 // render到编辑器
// render note // render note
@@ -977,6 +975,10 @@ Note._getNoteHtmlObjct = function(note, isShared) {
baseClasses = "item-shared"; baseClasses = "item-shared";
} }
var classes = baseClasses; var classes = baseClasses;
if (note.IsDeleted) {
console.error('_getNoteHtmlObjct note.IsDeleted');
return;
}
var tmp; var tmp;
if(note.ImgSrc) { if(note.ImgSrc) {
@@ -1011,6 +1013,11 @@ Note._renderNotes = function(notes, forNewNote, isShared, tang) { // 第几趟
var note = notes[i]; var note = notes[i];
note.Title = trimTitle(note.Title); note.Title = trimTitle(note.Title);
if (note.IsDeleted) {
console.error('note.IsDeleted');
continue;
}
if(note.InitSync) { if(note.InitSync) {
Note.getNoteContentLazy(note.NoteId); Note.getNoteContentLazy(note.NoteId);
} }
@@ -3295,19 +3302,26 @@ Note.addSync = function(notes) {
} }
for(var i in notes) { for(var i in notes) {
var note = notes[i]; var note = notes[i];
Note.addNoteCache(note); // 避免trash的也加进来
if (!note.IsDeleted) {
if (
(note.IsTrash && Notebook.curNotebookIsTrash())
|| !note.IsTrash) {
console.log(note); Note.addNoteCache(note);
// 很可能其笔记本也是新添加的, 此时重新render notebooks' numberNotes // 很可能其笔记本也是新添加的, 此时重新render notebooks' numberNotes
Notebook.reRenderNotebookNumberNotesIfIsNewNotebook(note.NotebookId); Notebook.reRenderNotebookNumberNotesIfIsNewNotebook(note.NotebookId);
// alert(note.ServerNoteId); // alert(note.ServerNoteId);
// 添加到当前的笔记列表中 // 添加到当前的笔记列表中
var newHtmlObject = Note._getNoteHtmlObjct(note); var newHtmlObject = Note._getNoteHtmlObjct(note);
$('#noteItemList').prepend(newHtmlObject); if (newHtmlObject) {
$('#noteItemList').prepend(newHtmlObject);
Note.setNoteBlogVisible(note.NoteId, note.IsBlog); Note.setNoteBlogVisible(note.NoteId, note.IsBlog);
}
}
}
} }
}; };