Don't remove both kanban items when a duplicate is deleted

pull/1/head
yflory 4 years ago
parent 1c9d36d9ea
commit dbba45e67e

@ -145,7 +145,7 @@ define([
}; };
var _updateBoardsThrottle = Util.throttle(_updateBoards, 1000); var _updateBoardsThrottle = Util.throttle(_updateBoards, 1000);
var updateBoards = function (framework, kanban, boards) { var updateBoards = function (framework, kanban, boards) {
if ((now() - _lastUpdate) > 5000) { if ((now() - _lastUpdate) > 5000 || framework.isLocked()) {
_updateBoards(framework, kanban, boards); _updateBoards(framework, kanban, boards);
return; return;
} }
@ -1207,8 +1207,17 @@ define([
var items = boards.items || {}; var items = boards.items || {};
var data = boards.data || {}; var data = boards.data || {};
var list = boards.list || []; var list = boards.list || [];
// Remove duplicate boards
list = boards.list = Util.deduplicateString(list);
Object.keys(data).forEach(function (id) { Object.keys(data).forEach(function (id) {
if (list.indexOf(Number(id)) === -1) { delete data[id]; } if (list.indexOf(Number(id)) === -1) {
list.push(Number(id));
}
// Remove duplicate items
var b = data[id];
b.item = Util.deduplicateString(b.item || []);
}); });
Object.keys(items).forEach(function (eid) { Object.keys(items).forEach(function (eid) {
var exists = Object.keys(data).some(function (id) { var exists = Object.keys(data).some(function (id) {

@ -299,7 +299,9 @@ define([
// Move to trash? // Move to trash?
if (target.classList.contains('kanban-trash')) { if (target.classList.contains('kanban-trash')) {
list.splice(index1, 1); list.splice(index1, 1);
delete self.options.boards.data[id]; if (list.indexOf(id) === -1) {
delete self.options.boards.data[id];
}
self.onChange(); self.onChange();
return; return;
} }
@ -444,6 +446,14 @@ define([
}); });
return res; return res;
}; };
this.checkItem = function (eid) {
var boards = self.options.boards;
var data = boards.data || {};
var exists = Object.keys(data).some(function (id) {
return (data[id].item || []).indexOf(Number(eid)) !== -1;
});
return exists;
};
this.moveItem = function (eid, board, pos) { this.moveItem = function (eid, board, pos) {
var boards = self.options.boards; var boards = self.options.boards;
var same = -1; var same = -1;
@ -453,11 +463,13 @@ define([
obj.board.item.splice(obj.pos, 1); obj.board.item.splice(obj.pos, 1);
if (obj.board === board) { same = obj.pos; } if (obj.board === board) { same = obj.pos; }
}); });
// If it's a deletion, remove the item data // If it's a deletion and not a duplicate, remove the item data
if (!board) { if (!board) {
delete boards.items[eid]; if (!self.checkItem(eid)) {
delete self.cache[eid]; delete boards.items[eid];
removeUnusedTags(boards); delete self.cache[eid];
removeUnusedTags(boards);
}
self.options.refresh(); self.options.refresh();
return; return;
} }

Loading…
Cancel
Save