mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-16 08:01:53 +00:00
fixConflict问题
当是第一个笔记时, inchangeNoteid=curNoteId 此时, 冲突, 会去服务器上拿数据->contentSynced -> 返回到前台, 虽然curNoteId != noteId, 但是inChangeNoteId=noteId, 于是reRenderNote 导致内容不符. 解决方法, 设置curNoteId时把inChangeNoteId清空
This commit is contained in:
2
node_modules/note.js
generated
vendored
2
node_modules/note.js
generated
vendored
@@ -120,7 +120,7 @@ var Note = {
|
|||||||
|
|
||||||
if(isDirty) {
|
if(isDirty) {
|
||||||
console.error("NONO----------");
|
console.error("NONO----------");
|
||||||
Web.alertWeb("NONO");
|
// Web.alertWeb("??NONO");
|
||||||
}
|
}
|
||||||
updates['LocalIsDelete'] = false;
|
updates['LocalIsDelete'] = false;
|
||||||
updates.UpdatedTime = date;
|
updates.UpdatedTime = date;
|
||||||
|
@@ -642,6 +642,10 @@ Note.changeNoteForPjax = function(noteId, mustPush, needTargetNotebook) {
|
|||||||
Note.contentAjax = null;
|
Note.contentAjax = null;
|
||||||
Note.contentAjaxSeq = 1;
|
Note.contentAjaxSeq = 1;
|
||||||
Note.inChangeNoteId = '';
|
Note.inChangeNoteId = '';
|
||||||
|
Note.setCurNoteId = function(noteId) {
|
||||||
|
Note.curNoteId = noteId;
|
||||||
|
Note.inChangeNoteId = '';
|
||||||
|
};
|
||||||
Note.changeNote = function(selectNoteId, isShare, needSaveChanged, callback) {
|
Note.changeNote = function(selectNoteId, isShare, needSaveChanged, callback) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
@@ -740,6 +744,9 @@ Note.changeNote = function(selectNoteId, isShare, needSaveChanged, callback) {
|
|||||||
// 重新渲染笔记, 因为sync更新了
|
// 重新渲染笔记, 因为sync更新了
|
||||||
Note.reRenderNote = function(noteId) {
|
Note.reRenderNote = function(noteId) {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
|
console.error("???")
|
||||||
|
|
||||||
me.showContentLoading();
|
me.showContentLoading();
|
||||||
var note = Note.getNote(noteId);
|
var note = Note.getNote(noteId);
|
||||||
Note.renderNote(note);
|
Note.renderNote(note);
|
||||||
@@ -846,7 +853,8 @@ Note.renderNoteContent = function(content) {
|
|||||||
setEditorContent(content.Content, content.IsMarkdown, content.Preview);
|
setEditorContent(content.Content, content.IsMarkdown, content.Preview);
|
||||||
|
|
||||||
// 只有在renderNoteContent时才设置curNoteId
|
// 只有在renderNoteContent时才设置curNoteId
|
||||||
Note.curNoteId = content.NoteId;
|
Note.setCurNoteId(content.NoteId);
|
||||||
|
|
||||||
// life
|
// life
|
||||||
// 重新渲染到左侧 desc, 因为笔记传过来是没有desc的
|
// 重新渲染到左侧 desc, 因为笔记传过来是没有desc的
|
||||||
content.Desc = Note.genDesc(content.Content);
|
content.Desc = Note.genDesc(content.Content);
|
||||||
@@ -1133,7 +1141,7 @@ Note.newNote = function(notebookId, isShare, fromUserId, isMarkdown) {
|
|||||||
|
|
||||||
Note.renderNote(note);
|
Note.renderNote(note);
|
||||||
Note.renderNoteContent(note);
|
Note.renderNoteContent(note);
|
||||||
Note.curNoteId = note.NoteId;
|
Note.setCurNoteId(note.NoteId);
|
||||||
|
|
||||||
// 更新数量
|
// 更新数量
|
||||||
Notebook.incrNotebookNumberNotes(notebookId)
|
Notebook.incrNotebookNumberNotes(notebookId)
|
||||||
@@ -1954,6 +1962,8 @@ Note.contentSynced = function(noteId, content) {
|
|||||||
if(me.curNoteId == noteId || me.inChangeNoteId == noteId) {
|
if(me.curNoteId == noteId || me.inChangeNoteId == noteId) {
|
||||||
// alert(note.Title);
|
// alert(note.Title);
|
||||||
// 重新渲染
|
// 重新渲染
|
||||||
|
// alert(me.curNoteId == noteId); false
|
||||||
|
// alert(me.inChangeNoteId == noteId); true
|
||||||
Note.reRenderNote(noteId);
|
Note.reRenderNote(noteId);
|
||||||
} else {
|
} else {
|
||||||
// 生成desc
|
// 生成desc
|
||||||
@@ -2707,7 +2717,7 @@ Note.fixSyncConflict = function(note, newNote) {
|
|||||||
|
|
||||||
// 如果当前编辑的是这个笔记, 那切换到newNote上来
|
// 如果当前编辑的是这个笔记, 那切换到newNote上来
|
||||||
if(Note.curNoteId == note.NoteId) {
|
if(Note.curNoteId == note.NoteId) {
|
||||||
Note.curNoteId = newNote.NoteId;
|
Note.setCurNoteId(newNote.NoteId);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user