From 06e69d1ad9ec231b919abf7259e92f45f4df3ccf Mon Sep 17 00:00:00 2001 From: life Date: Sat, 2 Jul 2016 17:13:12 +0800 Subject: [PATCH] Cannot sync InitSync note to server --- node_modules/sync.js | 6 ++++++ public/js/app/note.js | 21 ++++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/node_modules/sync.js b/node_modules/sync.js index 8f0f022d..50cdee84 100644 --- a/node_modules/sync.js +++ b/node_modules/sync.js @@ -906,6 +906,12 @@ var Sync = { // 调api, 所有执行后再callback(); // 一个一个同步执行, 因为要有 async.eachSeries(notes, function(note, cb) { + + if (note.InitSync) { + console.error('InitSync is Dirty'); + return cb(); + } + if(note.LocalIsNew) { // 是新的, 且不是trash和删除的 if(!note.IsTrash && !note.LocalIsDelete) { diff --git a/public/js/app/note.js b/public/js/app/note.js index 7146c6e8..53ae51ec 100644 --- a/public/js/app/note.js +++ b/public/js/app/note.js @@ -238,7 +238,7 @@ Note.alertWeb = function(msg) { // 返回已改变的信息 Note.curHasChanged = function(force) { var cacheNote = Note.getCurNote(); - if (!cacheNote) { + if (!cacheNote || cacheNote.InitSync) { // 还没有同步的, 不能保存 return false; } // else { @@ -712,9 +712,14 @@ Note.changeNote = function(selectNoteId, isShare, needSaveChanged, callback) { var seq = Note.contentAjaxSeq; function setContent(ret, fromCache, seq2) { - if(ret) { - cacheNote.InitSync = false; + // 找不到内容, 就一直loading + if (!ret) { + console.error('取不到内容'); + return; } + + cacheNote.InitSync = false; + ret = ret || {}; Note.contentAjax = null; if(seq2 != Note.contentAjaxSeq) { @@ -1811,6 +1816,13 @@ Note.toggleReadOnly = function(needSave) { // 切换到编辑模式 LEA.toggleWriteable = Note.toggleWriteable = function(isFromNewNote) { var me = Note; + var note = me.getCurNote(); + if (note) { + if (note.InitSync) { + alert('Waiting for lading content from server'); + return; + } + } // $('#infoToolbar').hide(); $('#editor').removeClass('read-only'); @@ -1820,8 +1832,7 @@ LEA.toggleWriteable = Note.toggleWriteable = function(isFromNewNote) { // markdown $('#mdEditor').removeClass('read-only'); - var note = me.getCurNote(); - if(!note) { + if (!note) { return; }