1
0
mirror of https://github.com/MatMoul/quickdial-webext.git synced 2024-12-23 15:36:12 +00:00

Bug: Convert separator to empty cell

This commit is contained in:
MatMoul 2017-11-26 13:20:10 +01:00
parent beb52273a2
commit 72ab3e5f6b

View File

@ -436,56 +436,60 @@ app.GridNodes.sync = function(gridNode, rootPath, callback){ // Sync GridNodes w
function syncNode(gridNode, bookmarkItem){ function syncNode(gridNode, bookmarkItem){
gridNode.id = bookmarkItem.id; gridNode.id = bookmarkItem.id;
gridNode.title = bookmarkItem.title; gridNode.title = bookmarkItem.title;
if(bookmarkItem.url){ switch(bookmarkItem.type){
gridNode.type = app.GridNodes.GridNodeType.bookmark; case 'bookmark':
if(gridNode.url != bookmarkItem.url){ gridNode.type = app.GridNodes.GridNodeType.bookmark;
gridNode.url = bookmarkItem.url; if(gridNode.url != bookmarkItem.url){
delete gridNode.image; gridNode.url = bookmarkItem.url;
} delete gridNode.image;
} else if(bookmarkItem.children){ }
gridNode.type = app.GridNodes.GridNodeType.folder; break;
var EmptyNodes = []; case 'folder':
if(! gridNode.children) gridNode.children = []; gridNode.type = app.GridNodes.GridNodeType.folder;
else { var EmptyNodes = [];
for(var i=gridNode.children.length-1; i>=0; i--){ if(! gridNode.children) gridNode.children = [];
if(!gridNode.children[i]) gridNode.children[i] = { type: app.GridNodes.GridNodeType.empty }; else {
if(gridNode.children[i].type==app.GridNodes.GridNodeType.empty){ for(var i=gridNode.children.length-1; i>=0; i--){
EmptyNodes.unshift(gridNode.children[i]); if(!gridNode.children[i]) gridNode.children[i] = { type: app.GridNodes.GridNodeType.empty };
} else { if(gridNode.children[i].type==app.GridNodes.GridNodeType.empty){
var found = false; EmptyNodes.unshift(gridNode.children[i]);
for(var child of bookmarkItem.children){ } else {
if(child.id==gridNode.children[i].id){ var found = false;
found = true; for(var child of bookmarkItem.children){
break; if(child.id==gridNode.children[i].id){
found = true;
break;
}
} }
} if(! found){
if(! found){ if(i<gridNode.children.length - 1){
if(i<gridNode.children.length - 1){ gridNode.children[i] = { type: app.GridNodes.GridNodeType.empty };
gridNode.children[i] = { type: app.GridNodes.GridNodeType.empty }; EmptyNodes.unshift(gridNode.children[i]);
EmptyNodes.unshift(gridNode.children[i]); } else {
} else { gridNode.children.pop();
gridNode.children.pop(); }
} }
} }
} }
} }
} for(var child of bookmarkItem.children){
for(var child of bookmarkItem.children){ var childGridNode = app.GridNodes.getChildNode(gridNode, child.id);
var childGridNode = app.GridNodes.getChildNode(gridNode, child.id); if(!childGridNode){
if(!childGridNode){ if(EmptyNodes.length>0){
if(EmptyNodes.length>0){ childGridNode = EmptyNodes[0];
childGridNode = EmptyNodes[0]; EmptyNodes.shift();
EmptyNodes.shift(); }else {
}else { childGridNode = {};
childGridNode = {}; gridNode.children.push(childGridNode)
gridNode.children.push(childGridNode) }
} }
syncNode(childGridNode, child);
} }
syncNode(childGridNode, child); EmptyNodes.length = 0;
} break;
EmptyNodes.length = 0; default:
} else { gridNode.type = app.GridNodes.GridNodeType.empty;
gridNode.type = app.GridNodes.GridNodeType.empty; break;
} }
} }