mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-15 15:41:19 +00:00
笔记本数量问题 , APP端的笔记不能自动保存, APP端的笔记不能自动保存. [ok] 同步删除笔记问题
笔记本数量问题 [ok] 两次粘贴问题 [ok] APP端的笔记不能自动保存. [ok] 同步删除笔记问题 [ok] 执行以下操作:APP内添加两篇笔记,手动同步到网页,网页可见.此时在网页中删掉其中一篇笔记后保存,网页可 达到预期效果.回到APP后手动同步, APP内的笔记仍然是2条,未作任何删改.已反复尝试证实. [ok]
This commit is contained in:
76
node_modules/note.js
generated
vendored
76
node_modules/note.js
generated
vendored
@@ -44,9 +44,11 @@ var Note = {
|
||||
var me = this;
|
||||
var userId = User.getCurActiveUserId();
|
||||
noteOrContent['UserId'] = userId;
|
||||
console.error("updateNoteOrContent")
|
||||
console.trace('updateNoteOrContent: ');
|
||||
console.log(noteOrContent);
|
||||
|
||||
// console.error("updateNoteOrContent")
|
||||
// console.trace('updateNoteOrContent: ');
|
||||
// console.log(noteOrContent);
|
||||
|
||||
var date = new Date();
|
||||
noteOrContent.UpdatedTime = date;
|
||||
|
||||
@@ -103,28 +105,36 @@ var Note = {
|
||||
// 只有title, Content, Tags修改了才算是IsDirty
|
||||
if('Content' in updates && dbNote['Content'] != updates['Content']) {
|
||||
isDirty = true;
|
||||
console.error(' content not same');
|
||||
console.log(dbNote['Content']);
|
||||
console.log(updates['Content']);
|
||||
} else if('Title' in updates && dbNote['Title'] != updates['Title']) {
|
||||
isDirty = true;
|
||||
console.error(' title not same');
|
||||
} else if('Tags' in updates) {
|
||||
var dbTags = dbNote['Tags'] || [];
|
||||
var nowTags = updates['Tags'] || [];
|
||||
if(dbTags.join(',') != nowTags.join(',')) {
|
||||
isDirty = true;
|
||||
console.error(' tag not same');
|
||||
}
|
||||
}
|
||||
|
||||
console.log('update note isDirty: ' + noteOrContent.NoteId);
|
||||
console.error(isDirty);
|
||||
// console.log('update note isDirty: ' + noteOrContent.NoteId);
|
||||
// console.error(isDirty);
|
||||
|
||||
updates['IsDirty'] = isDirty;
|
||||
|
||||
if(isDirty) {
|
||||
console.error("NONO----------");
|
||||
console.error("NONO---is dirty-------");
|
||||
// Web.alertWeb("??NONO");
|
||||
}
|
||||
updates['LocalIsDelete'] = false;
|
||||
updates.UpdatedTime = date;
|
||||
|
||||
console.log('finally update:');
|
||||
console.log(updates);
|
||||
|
||||
// Set an existing field's value
|
||||
Notes.update({NoteId: noteOrContent.NoteId}, { $set: updates }, {}, function (err, numReplaced) {
|
||||
if(err) {
|
||||
@@ -251,17 +261,32 @@ var Note = {
|
||||
clearTrash: function(callback) {
|
||||
var me = this;
|
||||
var userId = User.getCurActiveUserId();
|
||||
Notes.update({UserId: userId, IsTrash: true}, {$set: {LocalIsDelete: true, IsDirty: true}}, {multi: true}, function(err, n) {
|
||||
callback && callback();
|
||||
Notes.update(
|
||||
{UserId: userId, IsTrash: true},
|
||||
{$set: {LocalIsDelete: true, IsDirty: true}},
|
||||
{multi: true},
|
||||
function(err, n) {
|
||||
// Web.alertWeb(n);
|
||||
callback && callback();
|
||||
});
|
||||
},
|
||||
|
||||
deleteNote: function(noteId, callback) {
|
||||
Notes.update({NoteId: noteId}, {$set: {IsTrash: true, IsDirty: true}}, function(err, n) {
|
||||
if(err || !n) {
|
||||
var me = this;
|
||||
me.getNote(noteId, function(note) {
|
||||
if(!note) {
|
||||
callback(false);
|
||||
} else {
|
||||
callback(true);
|
||||
}
|
||||
Notes.update({NoteId: noteId}, {$set: {IsTrash: true, IsDirty: true}}, function(err, n) {
|
||||
if(err || !n) {
|
||||
callback(false);
|
||||
} else {
|
||||
callback(true);
|
||||
|
||||
// 重新统计
|
||||
Notebook.reCountNotebookNumberNotes(note.NotebookId);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
// 彻底删除笔记, 如果有tags, 则需要更新tags's count
|
||||
@@ -561,12 +586,20 @@ var Note = {
|
||||
// 有可能服务器上删除了是误删 ?
|
||||
deleteNoteForce: function(noteId, callback) {
|
||||
var me = this;
|
||||
Notes.remove({ServerNoteId: noteId}, function(err, n) {
|
||||
if(err) {
|
||||
me.getNoteByServerNoteId(noteId, function(note) {
|
||||
if(!note) {
|
||||
callback && callback(false);
|
||||
} else {
|
||||
callback && callback(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Notes.remove({_id: note._id}, function(err, n) {
|
||||
if(err) {
|
||||
callback && callback(false);
|
||||
} else {
|
||||
Notebook.reCountNotebookNumberNotes(note.NotebookId);
|
||||
callback && callback(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
// 添加笔记本, note object
|
||||
@@ -610,6 +643,9 @@ var Note = {
|
||||
// console.log(note.CreatedTime);
|
||||
callback && callback(newDoc);
|
||||
|
||||
// 重新统计
|
||||
Notebook.reCountNotebookNumberNotes(note.NotebookId);
|
||||
|
||||
// 下载内容, 图片, 附件
|
||||
me.syncContentAndImagesAndAttachs(newDoc);
|
||||
}
|
||||
@@ -721,6 +757,9 @@ var Note = {
|
||||
console.log(t);
|
||||
});
|
||||
|
||||
// 重新统计之
|
||||
Notebook.reCountNotebookNumberNotes(note.NotebookId);
|
||||
|
||||
// 下载内容, 图片, 附件
|
||||
me.syncContentAndImagesAndAttachs(note);
|
||||
}
|
||||
@@ -1185,7 +1224,10 @@ var Note = {
|
||||
|
||||
// 在send delete笔记时成功
|
||||
setNotDirty: function(noteId) {
|
||||
Notes.update({NoteId: noteId}, {$set:{IsDirty: false}})
|
||||
Notes.update({NoteId: noteId}, {$set: {IsDirty: false}})
|
||||
},
|
||||
removeNote: function(noteId) {
|
||||
Notes.remove({NoteId: noteId});
|
||||
},
|
||||
// 在send delete笔记时有冲突, 设为不删除
|
||||
setNotDirtyNotDelete: function(noteId) {
|
||||
|
Reference in New Issue
Block a user