mirror of
https://github.com/MatMoul/quickdial-webext.git
synced 2024-12-23 15:36:12 +00:00
Improvement: Limit sync bookmark surcharge
This commit is contained in:
parent
340a84730e
commit
351d043094
@ -212,7 +212,7 @@ app.Bookmarks._onMoved = function(){ app.GridNodes.sync(app.node, app.settings.g
|
|||||||
app.Bookmarks._onRemoved = function(){ app.GridNodes.sync(app.node, app.settings.grid.root, function(){ browser.runtime.sendMessage({ cmd: app.Messages.Commands.gridNodesLoaded }); }); }
|
app.Bookmarks._onRemoved = function(){ app.GridNodes.sync(app.node, app.settings.grid.root, function(){ browser.runtime.sendMessage({ cmd: app.Messages.Commands.gridNodesLoaded }); }); }
|
||||||
app.Bookmarks.initListener = function(){ // (Called from app.init) (/!\ Need filter to root tree only) Init listener of bookmarks
|
app.Bookmarks.initListener = function(){ // (Called from app.init) (/!\ Need filter to root tree only) Init listener of bookmarks
|
||||||
browser.bookmarks.onCreated.addListener(app.Bookmarks._onCreated);
|
browser.bookmarks.onCreated.addListener(app.Bookmarks._onCreated);
|
||||||
//browser.bookmarks.onChanged.addListener(app.Bookmarks._onChanged);
|
browser.bookmarks.onChanged.addListener(app.Bookmarks._onChanged);
|
||||||
browser.bookmarks.onMoved.addListener(app.Bookmarks._onMoved);
|
browser.bookmarks.onMoved.addListener(app.Bookmarks._onMoved);
|
||||||
browser.bookmarks.onRemoved.addListener(app.Bookmarks._onRemoved);
|
browser.bookmarks.onRemoved.addListener(app.Bookmarks._onRemoved);
|
||||||
}
|
}
|
||||||
@ -359,6 +359,11 @@ app.GridNodes.GridNodeType = { // GridNodeType
|
|||||||
bookmark: 2
|
bookmark: 2
|
||||||
}
|
}
|
||||||
app.GridNodes.sync = function(gridNode, rootPath, callback){ // Sync GridNodes with Bookmarks
|
app.GridNodes.sync = function(gridNode, rootPath, callback){ // Sync GridNodes with Bookmarks
|
||||||
|
if(app.GridNodes._syncing) {
|
||||||
|
app.GridNodes._needSync = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
app.GridNodes._syncing = true;
|
||||||
app.Bookmarks.load(rootPath, function(bookmarkItem){
|
app.Bookmarks.load(rootPath, function(bookmarkItem){
|
||||||
function syncNode(gridNode, bookmarkItem){
|
function syncNode(gridNode, bookmarkItem){
|
||||||
gridNode.id = bookmarkItem.id;
|
gridNode.id = bookmarkItem.id;
|
||||||
@ -414,8 +419,14 @@ app.GridNodes.sync = function(gridNode, rootPath, callback){ // Sync GridNodes w
|
|||||||
}
|
}
|
||||||
|
|
||||||
syncNode(gridNode, bookmarkItem);
|
syncNode(gridNode, bookmarkItem);
|
||||||
app.GridNodes.save();
|
delete app.GridNodes._syncing;
|
||||||
if(callback) callback();
|
if(app.GridNodes._needSync == true) {
|
||||||
|
delete app.GridNodes._needSync;
|
||||||
|
app.GridNodes.sync(gridNode, rootPath, callback);
|
||||||
|
} else {
|
||||||
|
app.GridNodes.save();
|
||||||
|
if(callback) callback();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
app.GridNodes.save = function(callback){ // Save GridNodes
|
app.GridNodes.save = function(callback){ // Save GridNodes
|
||||||
|
Loading…
Reference in New Issue
Block a user