mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-16 16:04:56 +00:00
要保存新建两次, 被阻止
This commit is contained in:
5
node_modules/note.js
generated
vendored
5
node_modules/note.js
generated
vendored
@@ -398,7 +398,8 @@ var Note = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
db.notes.update({NoteId: noteId}, {$set: {IsTrash: true, IsDirty: true}}, function(err, n) {
|
// {multi: true},
|
||||||
|
db.notes.update({NoteId: noteId}, {$set: {IsTrash: true, IsDirty: true}}, {multi: true}, function(err, n) {
|
||||||
if(err || !n) {
|
if(err || !n) {
|
||||||
callback(false);
|
callback(false);
|
||||||
} else {
|
} else {
|
||||||
@@ -449,7 +450,7 @@ var Note = {
|
|||||||
if(note) {
|
if(note) {
|
||||||
// 如果是本地用户, 则直接删除
|
// 如果是本地用户, 则直接删除
|
||||||
if(User.isLocal()) {
|
if(User.isLocal()) {
|
||||||
db.notes.remove({_id: note._id}, function(err, n) {
|
db.notes.remove({_id: note._id}, {multi: true}, function(err, n) {
|
||||||
if(n) {
|
if(n) {
|
||||||
me.deleteNoteAllOthers(note);
|
me.deleteNoteAllOthers(note);
|
||||||
// 如果有tags, 则重新更新tags' count
|
// 如果有tags, 则重新更新tags' count
|
||||||
|
@@ -148,11 +148,15 @@ Note.getNotesByNotebookId = function(notebookId, sortBy, isAsc) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var note = Note.cache[i];
|
var note = Note.cache[i];
|
||||||
|
if (!note) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (! ('IsMarkdown' in note)) {
|
if (! ('IsMarkdown' in note)) {
|
||||||
console.error('僵尸note------');
|
console.error('僵尸note------');
|
||||||
}
|
}
|
||||||
// 不要trash的not, 共享的也不要
|
// 不要trash的not, 共享的也不要
|
||||||
if(note.IsTrash || note.IsShared) {
|
if(note.IsTrash || note.IsDeleted || note.LocalIsDelete) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(notebookId == "all" || note.NotebookId == notebookId) {
|
if(notebookId == "all" || note.NotebookId == notebookId) {
|
||||||
@@ -442,12 +446,14 @@ Note.getImgSrc = function(content) {
|
|||||||
return "";
|
return "";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// 如果当前的改变了, 就保存它
|
// 如果当前的改变了, 就保存它
|
||||||
// 以后要定时调用
|
// 以后要定时调用
|
||||||
// force , 默认是true, 表强校验内容
|
// force , 默认是true, 表强校验内容
|
||||||
// 定时保存传false
|
// 定时保存传false
|
||||||
Note.saveInProcess = {}; // noteId => bool, true表示该note正在保存到服务器, 服务器未响应
|
Note.saveInProcess = {}; // noteId => bool, true表示该note正在保存到服务器, 服务器未响应
|
||||||
Note.savePool = {}; // 保存池, 以后的保存先放在pool中, id => note
|
Note.savePool = {}; // 保存池, 以后的保存先放在pool中, id => note
|
||||||
|
Note.savePoolNew = {}; // 如果之前新建的保存了, 连续2次事件, 拖动笔记, 则会保存新建两次, 此时数据库中出现两个noteId一样的
|
||||||
Note.curChangedSaveIt = function(force, callback) {
|
Note.curChangedSaveIt = function(force, callback) {
|
||||||
var me = Note;
|
var me = Note;
|
||||||
// 如果当前没有笔记, 不保存
|
// 如果当前没有笔记, 不保存
|
||||||
@@ -481,7 +487,14 @@ Note.curChangedSaveIt = function(force, callback) {
|
|||||||
// 保存之
|
// 保存之
|
||||||
me.saveInProcess[hasChanged.NoteId] = true;
|
me.saveInProcess[hasChanged.NoteId] = true;
|
||||||
|
|
||||||
// console.trace('要保存了.......');
|
if (hasChanged.IsNew) {
|
||||||
|
if (me.savePoolNew[hasChanged.NoteId]) {
|
||||||
|
console.log('要保存新建两次, 被阻止')
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
me.savePoolNew[hasChanged.NoteId] = true;
|
||||||
|
}
|
||||||
|
|
||||||
// console.log(hasChanged);
|
// console.log(hasChanged);
|
||||||
NoteService.updateNoteOrContent(hasChanged, function(ret) {
|
NoteService.updateNoteOrContent(hasChanged, function(ret) {
|
||||||
me.saveInProcess[hasChanged.NoteId] = false;
|
me.saveInProcess[hasChanged.NoteId] = false;
|
||||||
@@ -1162,7 +1175,7 @@ Note.newNote = function(notebookId, isShare, fromUserId, isMarkdown) {
|
|||||||
Note.setCurNoteId(note.NoteId);
|
Note.setCurNoteId(note.NoteId);
|
||||||
|
|
||||||
// 更新数量
|
// 更新数量
|
||||||
Notebook.incrNotebookNumberNotes(notebookId);
|
// Notebook.incrNotebookNumberNotes(notebookId);
|
||||||
|
|
||||||
// 切换到写模式
|
// 切换到写模式
|
||||||
Note.toggleWriteable(true);
|
Note.toggleWriteable(true);
|
||||||
@@ -1411,11 +1424,16 @@ Note.deleteNote = function(target, contextmenuItem, isShared) {
|
|||||||
// 取消star
|
// 取消star
|
||||||
Note.unStar(noteId);
|
Note.unStar(noteId);
|
||||||
|
|
||||||
|
/*
|
||||||
|
由后端到前端render
|
||||||
if (!note.IsTrash) {
|
if (!note.IsTrash) {
|
||||||
// 减少数量
|
// 减少数量
|
||||||
Notebook.minusNotebookNumberNotes(note.NotebookId);
|
// Notebook.minusNotebookNumberNotes(note.NotebookId);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
Note.clearCacheByNotebookId(note.NotebookId);
|
Note.clearCacheByNotebookId(note.NotebookId);
|
||||||
|
|
||||||
|
// 删除缓存
|
||||||
delete Note.cache[noteId];
|
delete Note.cache[noteId];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1625,7 +1643,7 @@ Note.moveNote = function(target, data) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NoteService.moveNote(noteIds, toNotebookId, function(ret) {
|
NoteService.moveNote(noteIds, toNotebookId, function(ret) {
|
||||||
if(ret) {
|
if(ret) {
|
||||||
me.clearCacheByNotebookId(toNotebookId);
|
me.clearCacheByNotebookId(toNotebookId);
|
||||||
|
Reference in New Issue
Block a user