mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-17 16:45:21 +00:00
fix note sync; add marker to mark dirty & sync error note and
This commit is contained in:
4
node_modules/api.js
generated
vendored
4
node_modules/api.js
generated
vendored
@@ -571,6 +571,10 @@ var Api = {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// for test
|
||||
// data.FileDatas = null;
|
||||
|
||||
needle.post(me.getUrl('note/updateNote'), data, {multipart: needMultiple}, function(err, resp) {
|
||||
// console.log('update note ret------------------');
|
||||
me.checkError(err, resp);
|
||||
|
73
node_modules/note.js
generated
vendored
73
node_modules/note.js
generated
vendored
@@ -616,7 +616,7 @@ var Note = {
|
||||
var me = this;
|
||||
// 修复内容, 修改图片, 附件链接为本地链接
|
||||
content = me.fixNoteContent(content);
|
||||
db.notes.update({NoteId: noteId}, { $set: {Content: content, InitSync: false, IsContentDirty: false} }, {}, function (err, numReplaced) {
|
||||
db.notes.update({NoteId: noteId}, { $set: {Err: null, Content: content, InitSync: false, IsContentDirty: false} }, {}, function (err, numReplaced) {
|
||||
if(err) {
|
||||
log(err);
|
||||
callback && callback(false);
|
||||
@@ -965,6 +965,7 @@ var Note = {
|
||||
// 不要服务器上的
|
||||
delete note['UpdatedTime'];
|
||||
delete note['CreatedTime'];
|
||||
note.Err = null;
|
||||
|
||||
db.notes.update({NoteId: note.NoteId}, {$set: note}, {}, function (err, cnt) { // Callback is optional
|
||||
// console.log('re:');
|
||||
@@ -1329,15 +1330,6 @@ var Note = {
|
||||
// 因为在处理冲突的时候有些成为更新了, 所以必须在此之后调用
|
||||
// console.log('has updates...');
|
||||
// console.log(noteSyncInfo.updates);
|
||||
|
||||
// 处理更新的
|
||||
if (!Common.isEmpty(noteSyncInfo.updates)) {
|
||||
Web.updateSyncNote(noteSyncInfo.updates);
|
||||
}
|
||||
|
||||
if (!Common.isEmpty(noteSyncInfo.changeUpdates)) {
|
||||
Web.updateChangeUpdates(noteSyncInfo.changeUpdates);
|
||||
}
|
||||
});
|
||||
|
||||
// 发送改变的冲突
|
||||
@@ -1378,6 +1370,36 @@ var Note = {
|
||||
})(i);
|
||||
}
|
||||
|
||||
// errors
|
||||
Web.updateErrors(noteSyncInfo.errors);
|
||||
|
||||
// 1. pull
|
||||
// 更新的
|
||||
if (!Common.isEmpty(noteSyncInfo.updates)) {
|
||||
Web.updateSyncNote(noteSyncInfo.updates);
|
||||
}
|
||||
// 处理添加的
|
||||
var addNotes = noteSyncInfo.adds;
|
||||
if (!isEmpty(addNotes)) {
|
||||
console.log(' has add note...', addNotes);
|
||||
Web.addSyncNote(addNotes);
|
||||
}
|
||||
// 处理删除的
|
||||
Web.deleteSyncNote(noteSyncInfo.deletes);
|
||||
|
||||
|
||||
// 2. push
|
||||
|
||||
// 处理添加的
|
||||
if (!Common.isEmpty(noteSyncInfo.changeAdds)) {
|
||||
Web.updateChangeAdds(noteSyncInfo.changeAdds);
|
||||
}
|
||||
|
||||
// 处理更新的
|
||||
if (!Common.isEmpty(noteSyncInfo.changeUpdates)) {
|
||||
Web.updateChangeUpdates(noteSyncInfo.changeUpdates);
|
||||
}
|
||||
|
||||
// 服务器没有, 但是是发送更新的, 所以需要作为添加以后再send changes
|
||||
if(noteSyncInfo.changeNeedAdds) {
|
||||
var needAddNotes = noteSyncInfo.changeNeedAdds;
|
||||
@@ -1388,16 +1410,6 @@ var Note = {
|
||||
}
|
||||
}
|
||||
|
||||
// 处理添加的
|
||||
var addNotes = noteSyncInfo.adds;
|
||||
if (!isEmpty(addNotes)) {
|
||||
console.log(' has add note...', addNotes);
|
||||
Web.addSyncNote(addNotes);
|
||||
}
|
||||
|
||||
// 处理删除的
|
||||
Web.deleteSyncNote(noteSyncInfo.deletes);
|
||||
|
||||
// 为了博客
|
||||
var changeAdds = noteSyncInfo.changeAdds || [];
|
||||
var changeUpdates = noteSyncInfo.changeUpdates || [];
|
||||
@@ -1847,6 +1859,27 @@ var Note = {
|
||||
Api.exportPdf(serverNoteId, callback);
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 设置笔记同步错误信息
|
||||
setError: function (noteId, err, ret, callback) {
|
||||
var me = this;
|
||||
var Err = {};
|
||||
try {
|
||||
if (err && typeof err == 'object') {
|
||||
Err.err = err.toString();
|
||||
}
|
||||
} catch(e) {
|
||||
}
|
||||
if (typeof ret == 'object' && 'Msg' in ret) {
|
||||
Err.msg = ret.Msg;
|
||||
} else {
|
||||
Err.msg = ret + '';
|
||||
}
|
||||
|
||||
db.notes.update({NoteId: noteId}, { $set: {Err: msg} }, {}, function (err, numReplaced) {
|
||||
return callback && callback(true);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
27
node_modules/sync.js
generated
vendored
27
node_modules/sync.js
generated
vendored
@@ -360,8 +360,8 @@ var Sync = {
|
||||
// 表示没有获取到content, 则只能标志为冲突了
|
||||
// 内容不一样, 也标为冲突
|
||||
if (content === false || content != noteLocal.Content) {
|
||||
// me._syncInfo.note.conflicts.push({server: note, local: noteLocal});
|
||||
me.fixSynced('note', 'conflicts', {server: note, local: noteLocal});
|
||||
me._syncInfo.note.conflicts.push({server: note, local: noteLocal});
|
||||
// me.fixSynced('note', 'conflicts', {server: note, local: noteLocal});
|
||||
}
|
||||
// 否则, 内容一样, 标为不冲突, 需要更新
|
||||
else {
|
||||
@@ -375,7 +375,6 @@ var Sync = {
|
||||
}
|
||||
canCall();
|
||||
}, false);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@@ -659,7 +658,6 @@ var Sync = {
|
||||
if (mainType == 'notebook') {
|
||||
Notebook.fixConflicts(o);
|
||||
} else if (mainType == 'note') {
|
||||
console.error('........');
|
||||
Note.fixConflicts(o);
|
||||
} else {
|
||||
Web.addOrDeleteTagFromSync(o);
|
||||
@@ -737,6 +735,7 @@ var Sync = {
|
||||
setSyncFinished: function() {
|
||||
var me = this;
|
||||
me.incrSyncStart = false;
|
||||
Web.syncProgress(0);
|
||||
},
|
||||
incrSync: function(again) {
|
||||
if (User.isLocal()) {
|
||||
@@ -985,7 +984,9 @@ var Sync = {
|
||||
newNote.NoteId = note.NoteId;
|
||||
|
||||
newNote.IsBlog = note.IsBlog; // 前端要用
|
||||
me._syncInfo.note.changeAdds.push(newNote);
|
||||
|
||||
// me._syncInfo.note.changeAdds.push(newNote);
|
||||
me.fixSynced('note', 'changeAdds', newNote);
|
||||
|
||||
Note.updateNoteForceForSendChange(newNote, true);
|
||||
|
||||
@@ -1052,21 +1053,26 @@ var Sync = {
|
||||
});
|
||||
}
|
||||
else if(ret.Msg == 'notExists') {
|
||||
Note.setError(note.NoteId, err, ret);
|
||||
me.fixSynced('note', 'errors', {err: err, ret: ret, note: note});
|
||||
// me._syncInfo.note.errors.push({err: err, ret: ret, note: note});
|
||||
// 可能服务器上已删除, 此时应该要作为添加而不是更新
|
||||
me._syncInfo.note.changeNeedAdds.push(note);
|
||||
// me._syncInfo.note.changeNeedAdds.push(note);
|
||||
cb();
|
||||
}
|
||||
// 其它错误, 不加, notImage 导致不能终止
|
||||
else {
|
||||
console.error(' updateNote error', err);
|
||||
me._syncInfo.note.errors.push({err: err, ret: ret, note: note});
|
||||
Note.setError(note.NoteId, err, ret);
|
||||
console.error(' updateNote error', err, ret);
|
||||
me.fixSynced('note', 'errors', {err: err, ret: ret, note: note});
|
||||
cb();
|
||||
}
|
||||
}
|
||||
// 更新失败了, 服务器返回异常
|
||||
else {
|
||||
Note.setError(note.NoteId, err, ret);
|
||||
console.error(' updateNote error', err);
|
||||
me._syncInfo.note.errors.push({err: err, ret: ret, note: note});
|
||||
me.fixSynced('note', 'errors', {err: err, ret: ret, note: note});
|
||||
cb();
|
||||
}
|
||||
}
|
||||
@@ -1076,7 +1082,8 @@ var Sync = {
|
||||
ret.ServerNoteId = ret.NoteId;
|
||||
ret.NoteId = note.NoteId;
|
||||
Note.updateNoteForceForSendChange(ret, false);
|
||||
me._syncInfo.note.changeUpdates.push(note);
|
||||
// me._syncInfo.note.changeUpdates.push(note);
|
||||
me.fixSynced('note', 'changeUpdates', note);
|
||||
|
||||
me.checkNeedIncSyncAgain(ret.Usn);
|
||||
|
||||
|
8
node_modules/web.js
generated
vendored
8
node_modules/web.js
generated
vendored
@@ -78,10 +78,18 @@ var Web = {
|
||||
var me = this;
|
||||
me.Note.updateSync(notes);
|
||||
},
|
||||
updateErrors: function (notes) {
|
||||
var me = this;
|
||||
me.Note.updateErrors(notes);
|
||||
},
|
||||
updateChangeUpdates: function (notes) {
|
||||
var me = this;
|
||||
me.Note.updateChangeUpdates(notes);
|
||||
},
|
||||
updateChangeAdds: function (notes) {
|
||||
var me = this;
|
||||
me.Note.updateChangeAdds(notes);
|
||||
},
|
||||
deleteSyncNote: function(notes) {
|
||||
var me = this;
|
||||
me.Note.deleteSync(notes);
|
||||
|
@@ -639,6 +639,7 @@ function log(o) {
|
||||
</a>
|
||||
</p>
|
||||
<span class="lang">Maker as resolved</span>: <input type="checkbox" class="conflict-resolved"/>
|
||||
<p class="lang">It will not be synced before fixed.</p>
|
||||
</div>
|
||||
|
||||
<script src="public/config.js"></script>
|
||||
|
@@ -21,7 +21,7 @@ Note.notebookIds = {}; // notebookId => true
|
||||
|
||||
// 初始化模版字符串
|
||||
// blog, star, settings
|
||||
var itemIsBlog = '<div class="item-blog"><i class="fa fa-bold" title="' + getMsg('Blog') + '"></i></div><div class="item-conflict-info"><i class="fa fa-bug" title="' + getMsg('Conflict') + '!!"></i></div><div class="item-star"><i class="fa fa-star-o" title="' + getMsg('Star') + '"></i></div><div class="item-setting"><i class="fa fa-cog" title="' + getMsg('Setting') + '"></i></div><span class="dirty-bg"></span>';
|
||||
var itemIsBlog = '<div class="item-options"><div class="item-blog"><i class="fa fa-bold" title="' + getMsg('Blog') + '"></i></div><div class="item-conflict-info"><i class="fa fa-bug" title="' + getMsg('Conflict') + '!!"></i></div><div class="item-warning"><i class="fa fa-warning" title="' + getMsg('Error') + '!!"></i></div><div class="item-star"><i class="fa fa-star-o" title="' + getMsg('Star') + '"></i></div><div class="item-setting"><i class="fa fa-cog" title="' + getMsg('Setting') + '"></i></div></div>';
|
||||
Note.itemTplNoImg = '<li href="#" class="item ?" data-seq="?" noteId="?">';
|
||||
Note.itemTplNoImg += itemIsBlog + '<div class="item-desc"><p class="item-title">?</p><p class="item-info"><i class="fa fa-book"></i> <span class="note-notebook">?</span> <i class="fa fa-clock-o"></i> <span class="updated-time">?</span></p><p class="desc">?</p></div></li>';
|
||||
Note.itemTpl = '<li href="#" class="item ? item-image" data-seq="?" noteId="?"><div class="item-thumb" style=""><img src="?"/></div>';
|
||||
@@ -445,9 +445,12 @@ Note.getImgSrc = function(content) {
|
||||
return "";
|
||||
};
|
||||
|
||||
Note.setNoteDirty = function (noteId) {
|
||||
var $leftNoteNav = $(tt('[noteId="?"]', noteId));
|
||||
$leftNoteNav.addClass('item-dirty');
|
||||
Note.setNoteDirty = function (noteId, isDirty) {
|
||||
var $leftNoteNav = $(tt('#noteItemList [noteId="?"]', noteId));
|
||||
if (!isDirty) {
|
||||
$leftNoteNav.removeClass('item-err');
|
||||
}
|
||||
isDirty ? $leftNoteNav.addClass('item-dirty') : $leftNoteNav.removeClass('item-dirty');
|
||||
};
|
||||
|
||||
// 如果当前的改变了, 就保存它
|
||||
@@ -510,7 +513,7 @@ Note.curChangedSaveIt = function(force, callback) {
|
||||
Pjax.changeNote(ret);
|
||||
}
|
||||
|
||||
me.setNoteDirty(hasChanged.NoteId);
|
||||
me.setNoteDirty(hasChanged.NoteId, true);
|
||||
|
||||
callback && callback(ret);
|
||||
}, force);
|
||||
@@ -521,6 +524,9 @@ Note.curChangedSaveIt = function(force, callback) {
|
||||
// 如果是强制的, 则要加历史, 但因笔记内容没改, 所以之前不会有
|
||||
if (force) {
|
||||
var note = me.getCurNote();
|
||||
if (!note) {
|
||||
return;
|
||||
}
|
||||
var content = getEditorContent(note.IsMarkdown);
|
||||
if (isArray(content)) {
|
||||
content = content[0];
|
||||
@@ -799,15 +805,13 @@ Note.renderChangedNote = function(changedNote) {
|
||||
}
|
||||
|
||||
// 找到左侧相应的note
|
||||
var $leftNoteNav = $(tt('[noteId="?"]', changedNote.NoteId));
|
||||
var $leftNoteNav = $(tt('#noteItemList [noteId="?"]', changedNote.NoteId));
|
||||
if(changedNote.Title) {
|
||||
$leftNoteNav.find(".item-title").html(trimTitle(changedNote.Title));
|
||||
// 如果标题改了, 如果也在star列表中, 那也要改star的标题啊
|
||||
Note.changeStarNoteTitle(changedNote.NoteId, trimTitle(changedNote.Title));
|
||||
}
|
||||
|
||||
// $leftNoteNav.addClass('item-dirty');
|
||||
|
||||
if($leftNoteNav.hasClass("list-item")) {
|
||||
return; //list view只需要更新title
|
||||
}
|
||||
@@ -897,7 +901,7 @@ Note.renderNoteContent = function(content, dontNeedSetReadonly, seq2) {
|
||||
// Note.setCurNoteId(content.NoteId);
|
||||
|
||||
// 重新渲染到左侧 desc, 因为笔记传过来是没有desc的
|
||||
var $leftNoteNav = $(tt('[noteId="?"]', content.NoteId));
|
||||
var $leftNoteNav = $(tt('#noteItemList [noteId="?"]', content.NoteId));
|
||||
if($leftNoteNav.find(".desc").text() == "") {
|
||||
Note.renderNoteDesc(content);
|
||||
}
|
||||
@@ -1011,7 +1015,9 @@ Note._getNoteHtmlObjct = function(note, isShared) {
|
||||
// blog ?
|
||||
if(!note.IsBlog) {
|
||||
tmp = $(tmp);
|
||||
tmp.find(".item-blog").hide();
|
||||
tmp.removeClass('item-b');
|
||||
} else {
|
||||
tmp.addClass('item-b');
|
||||
}
|
||||
// star ?
|
||||
if(note.Star) {
|
||||
@@ -1032,15 +1038,36 @@ Note._renderNotes = function(notes, forNewNote, isShared, tang) { // 第几趟
|
||||
classes += " item-active";
|
||||
}
|
||||
var note = notes[i];
|
||||
note.Title = trimTitle(note.Title);
|
||||
if (note.IsDirty) {
|
||||
classes += " item-dirty";
|
||||
}
|
||||
if (note.IsDeleted) {
|
||||
console.error('note.IsDeleted');
|
||||
continue;
|
||||
}
|
||||
|
||||
note.Title = trimTitle(note.Title);
|
||||
if (note.IsDirty || note.IsNew) {
|
||||
classes += " item-dirty";
|
||||
}
|
||||
// 不是trash才要star, conflict fix
|
||||
if(!note.IsTrash) {
|
||||
// star ?
|
||||
if(note.Star) {
|
||||
classes += ' item-is-star';
|
||||
}
|
||||
if(note.ConflictNoteId) {
|
||||
classes += ' item-conflict';
|
||||
}
|
||||
} else {
|
||||
classes += ' item-is-trash';
|
||||
}
|
||||
|
||||
if (note.Err) {
|
||||
classes += ' item-err';
|
||||
}
|
||||
|
||||
if (note.IsBlog) {
|
||||
classes += ' item-b';
|
||||
}
|
||||
|
||||
// 这里, 如果没有内容, 则添加到异步池中
|
||||
if(note.InitSync) {
|
||||
Note.addGetNoteContentLazy(note.NoteId);
|
||||
@@ -1056,25 +1083,10 @@ Note._renderNotes = function(notes, forNewNote, isShared, tang) { // 第几趟
|
||||
} else {
|
||||
tmp = tt(Note.getItemTplNoImg(), classes, i, note.NoteId, note.Title, Notebook.getNotebookTitle(note.NotebookId), goNowToDatetime(note.UpdatedTime), note.Desc || '');
|
||||
}
|
||||
if(!note.IsBlog) {
|
||||
tmp = $(tmp);
|
||||
tmp.find(".item-blog").hide();
|
||||
}
|
||||
|
||||
// 不是trash才要star, conflict fix
|
||||
if(!note.IsTrash) {
|
||||
// star ?
|
||||
if(note.Star) {
|
||||
$(tmp).addClass('item-is-star');
|
||||
}
|
||||
|
||||
if(note.ConflictNoteId) {
|
||||
$(tmp).addClass('item-conflict');
|
||||
}
|
||||
} else {
|
||||
// 不准star
|
||||
$(tmp).find('.item-star').remove();
|
||||
}
|
||||
// if(!note.IsBlog) {
|
||||
// tmp = $(tmp);
|
||||
// tmp.find(".item-blog").hide();
|
||||
// }
|
||||
|
||||
Note.noteItemListO.append(tmp);
|
||||
}
|
||||
@@ -1139,7 +1151,7 @@ Note.newNote = function(notebookId, isShare, fromUserId, isMarkdown) {
|
||||
newItem = tt(Note.getItemTplNoImg(), baseClasses, me.newNoteSeq(), note.NoteId, note.Title, notebookTitle, curDate, "");
|
||||
|
||||
newItem = $(newItem);
|
||||
newItem.find(".item-blog").hide();
|
||||
// newItem.find(".item-blog").hide();
|
||||
|
||||
// 是否在当前notebook下, 不是则切换过去, 并得到该notebook下所有的notes, 追加到后面!
|
||||
if(!Notebook.isCurNotebook(notebookId)) {
|
||||
@@ -1157,7 +1169,7 @@ Note.newNote = function(notebookId, isShare, fromUserId, isMarkdown) {
|
||||
Note.noteItemListO.prepend(newItem);
|
||||
}
|
||||
|
||||
Note.selectTarget($(tt('[noteId="?"]', note.NoteId)));
|
||||
Note.selectTarget($(tt('#noteItemList [noteId="?"]', note.NoteId)));
|
||||
|
||||
setTimeout(function() {
|
||||
$("#noteTitle").focus();
|
||||
@@ -1341,7 +1353,7 @@ Note.changeToNextSkipNotes = function(noteIds) {
|
||||
}
|
||||
|
||||
// 全删除了
|
||||
if (me.$itemList.find('li').length == noteIds.length) {
|
||||
if (me.$itemList.find('li').length <= noteIds.length) {
|
||||
me.showEditorMask();
|
||||
return;
|
||||
}
|
||||
@@ -2035,7 +2047,7 @@ Note._initshowConflictInfo = function() {
|
||||
return;
|
||||
}
|
||||
// 是否在该列表中?
|
||||
var target = $(tt('[noteId="?"]', conflictNoteId)); //
|
||||
var target = $(tt('#noteItemList [noteId="?"]', conflictNoteId)); //
|
||||
// 如果当前笔记在笔记列表中, 那么生成一个新笔记放在这个笔记上面
|
||||
if(target.length > 0) {
|
||||
} else {
|
||||
@@ -3296,7 +3308,7 @@ $(function() {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
// 得到ID
|
||||
var noteId = $(this).parent().attr('noteId');
|
||||
var noteId = $(this).closest('li').attr('noteId');
|
||||
var note = Note.getNote(noteId);
|
||||
if(note.ServerNoteId) {
|
||||
openExternal(UserInfo.Host + '/blog/post/' + note.ServerNoteId);
|
||||
@@ -3304,11 +3316,10 @@ $(function() {
|
||||
});
|
||||
|
||||
// note setting
|
||||
$("#noteItemList").on("click", ".item-my .item-setting", function(e) {
|
||||
$("#noteItemList").on("click", ".item-setting", function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
var $p = $(this).parent();
|
||||
Note.noteMenuSys.popup(e, $p);
|
||||
Note.noteMenuSys.popup(e, $(this).closest('li'));
|
||||
});
|
||||
$("#noteItemList").on("contextmenu", "li", function(e) {
|
||||
e.preventDefault();
|
||||
@@ -3317,7 +3328,7 @@ $(function() {
|
||||
});
|
||||
|
||||
// 收藏
|
||||
$("#noteItemList").on("click", ".item-my .item-star", function(e) {
|
||||
$("#noteItemList").on("click", ".item-star", function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
var $li = $(this).closest('li');
|
||||
@@ -3339,10 +3350,28 @@ $(function() {
|
||||
Note.renderStarNote($li);
|
||||
});
|
||||
|
||||
$("#noteItemList").on("click", ".item-my .item-conflict-info", function(e) {
|
||||
$("#noteItemList").on("click", ".item-conflict-info", function(e) {
|
||||
Note.showConflictInfo(this, e);
|
||||
});
|
||||
|
||||
$("#noteItemList").on("click", ".item-warning", function(e) {
|
||||
var $li = $(this).closest('li');
|
||||
var noteId = $li.attr('noteId');
|
||||
var note = Note.getNote(noteId);
|
||||
if (!note) {
|
||||
return;
|
||||
}
|
||||
if (!note.Err) {
|
||||
$li.removeClass('item-err');
|
||||
return;
|
||||
}
|
||||
var err = note.Err;
|
||||
var msg = getMsg('Sync error') + '\n';
|
||||
err.err && (msg = getMsg('Error') + ': ' + err.err + '\n')
|
||||
err.msg && (msg += getMsg('Message') + ': ' + getMsg(err.msg));
|
||||
alert(msg);
|
||||
});
|
||||
|
||||
Note._syncRefreshE = $('#syncRefresh');
|
||||
Note._syncWarningE = $('#syncWarning');
|
||||
// sync
|
||||
@@ -3388,7 +3417,7 @@ Note.fixSyncConflict = function(note, newNote) {
|
||||
Note.addNoteCache(note);
|
||||
Note.addNoteCache(newNote);
|
||||
|
||||
var target = $(tt('[noteId="?"]', note.NoteId)); //
|
||||
var target = $(tt('#noteItemList [noteId="?"]', note.NoteId)); //
|
||||
// 如果当前笔记在笔记列表中, 那么生成一个新笔记放在这个笔记上面
|
||||
if(target.length > 0) {
|
||||
var newHtmlObject = Note._getNoteHtmlObjct(note);
|
||||
@@ -3409,12 +3438,12 @@ Note.fixSyncConflict = function(note, newNote) {
|
||||
|
||||
// 设置博客是否可以见
|
||||
Note.setNoteBlogVisible = function(noteId, isBlog) {
|
||||
var target = $(tt('[noteId="?"]', noteId));
|
||||
var target = $(tt('#noteItemList [noteId="?"]', noteId));
|
||||
if(target.length) {
|
||||
if(isBlog) {
|
||||
target.find(".item-blog").removeAttr('style');
|
||||
target.addClass('item-b');
|
||||
} else {
|
||||
target.find(".item-blog").hide();
|
||||
target.removeClass('item-b');
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -3441,6 +3470,7 @@ Note.updateNoteCacheForServer = function(notes) {
|
||||
};
|
||||
|
||||
// 更新
|
||||
// push
|
||||
// --> send changes
|
||||
Note.updateSync = function(notes) {
|
||||
if(isEmpty(notes)) {
|
||||
@@ -3449,6 +3479,8 @@ Note.updateSync = function(notes) {
|
||||
|
||||
var curNotebookIsTrash = Notebook.curNotebookIsTrash();
|
||||
|
||||
var currentIsDeleted = false;
|
||||
|
||||
for(var i = 0; i < notes.length; ++i) {
|
||||
var note = notes[i];
|
||||
note.InitSync = true; // 需要重新获取内容
|
||||
@@ -3465,10 +3497,8 @@ Note.updateSync = function(notes) {
|
||||
Note.reRenderNote(Note.curNoteId);
|
||||
}
|
||||
|
||||
var target = $(tt('[noteId="?"]', note.NoteId));
|
||||
if(target.length) {
|
||||
target.removeClass('item-dirty');
|
||||
}
|
||||
// 不是dirty的
|
||||
Note.setNoteDirty(note.NoteId, false);
|
||||
|
||||
// 设置当前是否是博客
|
||||
// alert(note.NoteId + " " + note.IsBlog);
|
||||
@@ -3476,20 +3506,44 @@ Note.updateSync = function(notes) {
|
||||
|
||||
// 如果是trash, 且当前不在trash目录下, 且有该笔记, 则删除之
|
||||
if(!curNotebookIsTrash && note.IsTrash) {
|
||||
|
||||
// 前端缓存也要删除!!
|
||||
// 先删除, 不然changeToNext()之前会先保存现在的, 导致僵尸note
|
||||
Note.deleteCache(note.NoteId)
|
||||
Note.deleteCache(note.NoteId);
|
||||
|
||||
// 当前笔记要删除了, 如果有多个笔记要删除, 这就有问题了
|
||||
// 刚一切换到下一个, 就被删除了, 导致没有被选中
|
||||
if(target.length) {
|
||||
if(Note.curNoteId == note.NoteId) {
|
||||
currentIsDeleted = true;
|
||||
Note.changeToNext(target);
|
||||
}
|
||||
target.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 最后再删除
|
||||
if (currentIsDeleted) {
|
||||
// Note.changeToNext(target);
|
||||
setTimeout (function () {
|
||||
Note.checkHasSelectedNote();
|
||||
}, 100);
|
||||
}
|
||||
};
|
||||
|
||||
Note.checkHasSelectedNote = function () {
|
||||
if(!$('#noteItemList .item-active').length) {
|
||||
if($('#noteItemList .item').length > 0) {
|
||||
Note.changeNote($('#noteItemList .item').eq(0).attr("noteId"));
|
||||
}
|
||||
else {
|
||||
Note.showEditorMask();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// pull
|
||||
// 添加同步的notes
|
||||
// <-- server
|
||||
Note.addSync = function(notes) {
|
||||
@@ -3533,7 +3587,7 @@ Note.deleteSync = function(notes) {
|
||||
Note.clearCacheByNotebookId(note.NotebookId);
|
||||
delete Note.cache[noteId];
|
||||
// 如果在笔记列表中则删除
|
||||
$(tt('[noteId="?"]', note.NoteId)).remove();
|
||||
$(tt('#noteItemList [noteId="?"]', note.NoteId)).remove();
|
||||
}
|
||||
|
||||
// 前端缓存也要删除!!
|
||||
@@ -3541,16 +3595,54 @@ Note.deleteSync = function(notes) {
|
||||
}
|
||||
};
|
||||
|
||||
// 发送改变成功了的
|
||||
Note.updateChangeUpdates = function (notes) {
|
||||
// push
|
||||
|
||||
// 发送成功添加了的
|
||||
Note.updateChangeAdds = function (notes) {
|
||||
if(isEmpty(notes)) {
|
||||
return;
|
||||
}
|
||||
for(var i in notes) {
|
||||
for(var i = 0; i < notes.length; ++i) {
|
||||
var note = notes[i];
|
||||
var target = $(tt('[noteId="?"]', note.NoteId));
|
||||
if(target.length) {
|
||||
target.removeClass('item-dirty');
|
||||
}
|
||||
this.setNoteDirty(note.NoteId, false);
|
||||
}
|
||||
};
|
||||
|
||||
// 发送改变成功了的
|
||||
Note.updateChangeUpdates = function (notes) {
|
||||
this.updateChangeAdds(notes);
|
||||
};
|
||||
|
||||
// 返回 {err:'', msg: ''}
|
||||
Note._getError = function (err, ret) {
|
||||
var Err = {};
|
||||
try {
|
||||
if (err && typeof err == 'object') {
|
||||
Err.err = err.toString();
|
||||
}
|
||||
} catch(e) {
|
||||
}
|
||||
if (typeof ret == 'object' && 'Msg' in ret) {
|
||||
Err.msg = ret.Msg;
|
||||
} else {
|
||||
Err.msg = ret + '';
|
||||
}
|
||||
return Err;
|
||||
};
|
||||
Note.updateErrors = function (errs) {
|
||||
if(isEmpty(errs)) {
|
||||
return;
|
||||
}
|
||||
for(var i = 0; i < errs.length; ++i) {
|
||||
var err = errs[i]; // {err: err, ret: ret, note: note}
|
||||
var note = err.note;
|
||||
if (!note || !note.NoteId) {
|
||||
continue;
|
||||
}
|
||||
var Err = this._getError(err.err, err.ret);
|
||||
this.setNoteCache({NoteId: note.NoteId, Err: Err}, false);
|
||||
|
||||
var $leftNoteNav = $(tt('#noteItemList [noteId="?"]', note.NoteId));
|
||||
$leftNoteNav.addClass('item-err');
|
||||
}
|
||||
}
|
||||
|
@@ -263,7 +263,7 @@ Notebook.getTreeSetting = function(isSearch, isShare) {
|
||||
ajaxData.siblings.push(notebookId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// {siblings: [id1, id2], parentNotebookId: 'xx', curNotebookId: 'yy'}
|
||||
NotebookService.dragNotebooks(ajaxData.curNotebookId, ajaxData.parentNotebookId, ajaxData.siblings);
|
||||
|
||||
|
@@ -321,6 +321,11 @@
|
||||
|
||||
"Network error, please check out your network.": "网络异常, 请检查网络或稍后再试",
|
||||
"You need to sign in Leanote": "您需要重新登录Leanote",
|
||||
"You need to upgrade Leanote account": "同步失败, 帐户已到期或流量已用完, 您需要升级Leanote帐户"
|
||||
"You need to upgrade Leanote account": "同步失败, 帐户已到期或流量已用完, 您需要升级Leanote帐户",
|
||||
|
||||
"It will not be synced before fixed.": "该笔记未解决前将不会同步",
|
||||
"Sync error": "同步失败",
|
||||
"Message": "信息",
|
||||
"notExists": "服务端笔记不存在",
|
||||
"fileUploadError": "图片/附件上传失败"
|
||||
}
|
||||
|
@@ -510,34 +510,70 @@ h3 {
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
#noteItemList .item-conflict {
|
||||
border: 1px solid #DBB624 !important;
|
||||
}
|
||||
#noteItemList .item-err {
|
||||
border: 1px solid red !important;
|
||||
}
|
||||
|
||||
// blog
|
||||
#noteItemList .item:hover {
|
||||
.item-setting,
|
||||
.item-star,
|
||||
.item-blog {
|
||||
display: block;
|
||||
.item-star
|
||||
{
|
||||
display: inline-block;
|
||||
}
|
||||
&.item-conflict {
|
||||
.item-conflict-info {
|
||||
display: block;
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
&.item-b {
|
||||
.item-blog {
|
||||
display: inline-block;
|
||||
}
|
||||
&.item-conflict {
|
||||
.item-blog {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
&.item-err {
|
||||
.item-warning {
|
||||
background-color: red;
|
||||
display: inline-block;
|
||||
.fa {
|
||||
// color: red;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#noteItemList {
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
|
||||
.item-options {
|
||||
position: absolute;
|
||||
right: 1px;
|
||||
bottom: 0;
|
||||
font-size: 10px;
|
||||
z-index: 2;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.item-setting,
|
||||
.item-blog,
|
||||
.item-star,
|
||||
.item-conflict-info {
|
||||
position: absolute;
|
||||
right: 1px;
|
||||
font-size: 10px;
|
||||
z-index: 2;
|
||||
.item-conflict-info,
|
||||
.item-warning
|
||||
{
|
||||
display: inline-block;
|
||||
padding: 3px;
|
||||
margin-left: 3px;
|
||||
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
.fa {
|
||||
@@ -550,32 +586,23 @@ h3 {
|
||||
opacity: 0.8;
|
||||
}
|
||||
background-color: #464C5E;
|
||||
}
|
||||
.item-blog {
|
||||
// top: 1px;
|
||||
bottom: 0;
|
||||
right: 45px;
|
||||
// 暂不支持
|
||||
display: none;
|
||||
}
|
||||
.item-setting {
|
||||
bottom: 0;
|
||||
display: none;
|
||||
z-index: 3;
|
||||
}
|
||||
.item-star {
|
||||
bottom: 0;
|
||||
right: 23px;
|
||||
display: none;
|
||||
}
|
||||
.item-conflict-info {
|
||||
bottom: 0;
|
||||
right: 45px;
|
||||
.fa {
|
||||
color: #f0ad4e !important;
|
||||
}
|
||||
display: none;
|
||||
}
|
||||
|
||||
.item-is-trash {
|
||||
.item-star {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
// 是star的
|
||||
.item-is-star {
|
||||
.item-star {
|
||||
@@ -1722,10 +1749,6 @@ h3 {
|
||||
border-radius: 0 !important;
|
||||
}
|
||||
|
||||
#noteItemList .item-conflict {
|
||||
border: 2px solid #DBB624;
|
||||
}
|
||||
|
||||
#tagNav {
|
||||
i,
|
||||
em {
|
||||
@@ -1773,7 +1796,7 @@ h3 {
|
||||
|
||||
#conflictTips {
|
||||
width: 230px;
|
||||
height: 80px;
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
.conflict-title {
|
||||
@@ -2314,17 +2337,39 @@ img::selection {
|
||||
top: 11px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
.list-view {
|
||||
.item-dirty {
|
||||
&:after {
|
||||
top: auto;
|
||||
bottom: 10px;
|
||||
}
|
||||
}
|
||||
// .item-err:after {
|
||||
// top: 9px!important;
|
||||
// }
|
||||
}
|
||||
|
||||
.item-dirty {
|
||||
&::after {
|
||||
// .item-err {
|
||||
// &:after {
|
||||
// width: 12px !important;
|
||||
// height: 12px !important;
|
||||
// background: red !important;
|
||||
// right: 5px !important;
|
||||
// top: 4px !important;
|
||||
// }
|
||||
// }
|
||||
|
||||
.item-dirty, .item-err {
|
||||
&:after {
|
||||
content: "";
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
background: #FF6363;
|
||||
position: absolute;
|
||||
right: 7px;
|
||||
bottom: 6px;
|
||||
top: 6px;
|
||||
border-radius: 50%;
|
||||
z-index: 2;
|
||||
}
|
||||
// .dirty-bg {
|
||||
// position: absolute;
|
||||
|
Reference in New Issue
Block a user