fix #1871? ("blind" fix, need confirmation)

This commit is contained in:
gorhill 2017-02-03 08:12:26 -05:00
parent 1ba853df8c
commit 60605033bf
2 changed files with 18 additions and 6 deletions

View file

@ -793,6 +793,10 @@ var backupUserData = function(callback) {
var restoreUserData = function(request) {
var userData = request.userData;
var restart = function() {
vAPI.app.restart();
};
var onAllRemoved = function() {
µBlock.saveLocalSettings();
vAPI.storage.set(userData.userSettings);
@ -811,13 +815,17 @@ var restoreUserData = function(request) {
// 'filterLists' is available up to uBO v1.10.4, not beyond.
// 'selectedFilterLists' is available from uBO v1.11 and beyond.
var listKeys;
if ( Array.isArray(userData.selectedFilterLists) ) {
µb.saveSelectedFilterLists(userData.selectedFilterLists);
listKeys = userData.selectedFilterLists;
} else if ( userData.filterLists instanceof Object ) {
µb.saveSelectedFilterLists(µb.newListKeysFromOldData(userData.filterLists));
listKeys = µb.newListKeysFromOldData(userData.filterLists);
}
if ( listKeys !== undefined ) {
µb.saveSelectedFilterLists(listKeys, restart);
} else {
restart();
}
vAPI.app.restart();
};
// https://github.com/chrisaljoudi/uBlock/issues/1102

View file

@ -196,7 +196,11 @@
});
};
µBlock.saveSelectedFilterLists = function(newKeys, append) {
µBlock.saveSelectedFilterLists = function(newKeys, append, callback) {
if ( typeof append === 'function' ) {
callback = append;
append = false;
}
var oldKeys = this.selectedFilterLists.slice();
if ( append ) {
newKeys = newKeys.concat(oldKeys);
@ -214,7 +218,7 @@
remoteBlacklists: this.oldDataFromNewListKeys(newKeys)
};
this.selectedFilterLists = newKeys;
vAPI.storage.set(bin);
vAPI.storage.set(bin, callback);
};
// TODO(seamless migration):