Don't import files that didn't decrypt properly
This commit is contained in:
@@ -185,15 +185,24 @@ class AccountMenu {
|
||||
$scope.importData.loading = true;
|
||||
// allow loading indicator to come up with timeout
|
||||
$timeout(function(){
|
||||
$scope.importJSONData(data, password, function(response){
|
||||
$scope.importJSONData(data, password, function(response, errorCount){
|
||||
$timeout(function(){
|
||||
$scope.importData.loading = false;
|
||||
$scope.importData = null;
|
||||
if(!response) {
|
||||
alert("There was an error importing your data. Please try again.");
|
||||
} else {
|
||||
alert("Your data was successfully imported.")
|
||||
}
|
||||
|
||||
// Update UI before showing alert
|
||||
setTimeout(function () {
|
||||
if(!response) {
|
||||
alert("There was an error importing your data. Please try again.");
|
||||
} else {
|
||||
if(errorCount > 0) {
|
||||
var message = `Import complete. ${errorCount} items were not imported because there was an error decrypting them. Make sure the password is correct and try again.`;
|
||||
alert(message);
|
||||
} else {
|
||||
alert("Your data was successfully imported.")
|
||||
}
|
||||
}
|
||||
}, 10);
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -225,7 +234,7 @@ class AccountMenu {
|
||||
}
|
||||
|
||||
$scope.importJSONData = function(data, password, callback) {
|
||||
var onDataReady = function() {
|
||||
var onDataReady = function(errorCount) {
|
||||
var items = modelManager.mapResponseItemsToLocalModels(data.items);
|
||||
items.forEach(function(item){
|
||||
item.setDirty(true);
|
||||
@@ -233,7 +242,9 @@ class AccountMenu {
|
||||
item.markAllReferencesDirty();
|
||||
})
|
||||
|
||||
syncManager.sync(callback, {additionalFields: ["created_at", "updated_at"]});
|
||||
syncManager.sync((response) => {
|
||||
callback(response, errorCount);
|
||||
}, {additionalFields: ["created_at", "updated_at"]});
|
||||
}.bind(this)
|
||||
|
||||
if(data.auth_params) {
|
||||
@@ -244,8 +255,19 @@ class AccountMenu {
|
||||
data.items.forEach(function(item){
|
||||
item.enc_item_key = null;
|
||||
item.auth_hash = null;
|
||||
});
|
||||
|
||||
var errorCount = 0;
|
||||
// Don't import items that didn't decrypt properly
|
||||
data.items = data.items.filter(function(item){
|
||||
if(item.errorDecrypting) {
|
||||
errorCount++;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
onDataReady();
|
||||
|
||||
onDataReady(errorCount);
|
||||
}
|
||||
catch (e) {
|
||||
console.log("Error decrypting", e);
|
||||
|
||||
@@ -35,7 +35,6 @@ angular.module('app.frontend')
|
||||
}
|
||||
|
||||
items = items || [];
|
||||
console.log("Sorting", items.length, "items");
|
||||
return items.sort(function(a, b){
|
||||
return sortValueFn(a, b);
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user