mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-16 08:01:53 +00:00
笔记和标签同步BUGs
1. 修复不能添加已删除的tag 2. FullSync时可能导致一些笔记为Dirty 3. 笔记错误同步信息显示
This commit is contained in:
43
node_modules/tag.js
generated
vendored
43
node_modules/tag.js
generated
vendored
@@ -26,13 +26,15 @@ var Tag = {
|
||||
// 已存的, 不更新IsDirty
|
||||
var Note = require('note');
|
||||
if(!err && tag) {
|
||||
Note.countNoteByTag(title, function(cnt) {
|
||||
tag.Count = cnt;
|
||||
db.tags.update({UserId: userId, Title: title}, {$set: {Count: cnt, UpdatedTime: new Date()}}, function() {
|
||||
console.log('已存在tag' + title);
|
||||
// Note.countNoteByTag(title, function(cnt) {
|
||||
// tag.Count = cnt;
|
||||
// LocalIsDelete变为false, 可能之前删除了, 后来又重新添加了
|
||||
// {Tag: title}, 之前是 {Title: title}
|
||||
db.tags.update({UserId: userId, Tag: title}, {$set: {UpdatedTime: new Date(), LocalIsDelete: false, IsDirty: true}}, function() {
|
||||
console.log('已存在tag ' + title);
|
||||
callback(tag);
|
||||
});
|
||||
});
|
||||
// });
|
||||
} else {
|
||||
var date = new Date();
|
||||
db.tags.insert({
|
||||
@@ -55,27 +57,44 @@ var Tag = {
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
getTags: function(callback) {
|
||||
db.tags.find({UserId: User.getCurActiveUserId(), LocalIsDelete: false}, function(err, tags) {
|
||||
if(err) {
|
||||
callback && callback(false);
|
||||
} else {
|
||||
// 排序, 用UpdatedTime来排序
|
||||
tags.sort(function (a, b) {
|
||||
return a.UpdatedTime < b.UpdatedTime;
|
||||
});
|
||||
callback && callback(tags);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 删除标签, 更新为LocaleIsDelete = true
|
||||
deleteTag: function(title, callback, isForce) {
|
||||
deleteTag: function(title, callback, isForce, isFullSync) {
|
||||
title += '';
|
||||
var me = this;
|
||||
db.tags.update({UserId: User.getCurActiveUserId(), Tag: title}, {$set: {LocalIsDelete: true, IsDirty: !isForce, UpdatedTime: new Date()}}, function() {
|
||||
});
|
||||
//
|
||||
var Note = require('./note');
|
||||
// console.log(Note);
|
||||
Note.updateNoteToDeleteTag(title, function(updates) {
|
||||
callback && callback(updates);
|
||||
});
|
||||
|
||||
// 不是fullSync才更新笔记的标签, 防止fullSync时还有一批IsDirty的
|
||||
if (!isFullSync) {
|
||||
// 删除笔记内的tag
|
||||
var Note = require('./note');
|
||||
Note.updateNoteToDeleteTag(title, function(updates) {
|
||||
callback && callback(updates);
|
||||
});
|
||||
} else {
|
||||
console.log(' isFullSync not need updateNoteToDeleteTag');
|
||||
callback && callback({});
|
||||
}
|
||||
},
|
||||
|
||||
deleteLocalTag: function (title) {
|
||||
console.log(' deleteLocalTag', title)
|
||||
db.tags.remove({Tag: title});
|
||||
},
|
||||
|
||||
// 更新标签的数量, 在彻底删除笔记时调用
|
||||
|
Reference in New Issue
Block a user