Fixes
This commit is contained in:
@@ -26,7 +26,7 @@ angular.module('app')
|
||||
syncManager, storageManager, passcodeManager, componentManager, singletonManager, nativeExtManager) {
|
||||
|
||||
authManager.checkForSecurityUpdate().then((available) => {
|
||||
this.securityUpdateAvailable = available;
|
||||
this.securityUpdateAvailable = available;
|
||||
})
|
||||
|
||||
$rootScope.$on("security-update-status-changed", () => {
|
||||
|
||||
@@ -89,10 +89,10 @@ angular.module('app')
|
||||
});
|
||||
|
||||
syncManager.loadLocalItems().then(() => {
|
||||
$scope.allTag.didLoad = true;
|
||||
$scope.$apply();
|
||||
|
||||
$rootScope.$broadcast("initial-data-loaded");
|
||||
$timeout(() => {
|
||||
$scope.allTag.didLoad = true;
|
||||
$rootScope.$broadcast("initial-data-loaded");
|
||||
})
|
||||
|
||||
syncManager.sync();
|
||||
// refresh every 30s
|
||||
@@ -225,14 +225,14 @@ angular.module('app')
|
||||
$scope.didShowErrorAlert = true;
|
||||
alert("There was an error saving your note. Please try again.");
|
||||
}
|
||||
if(callback) {
|
||||
callback(false);
|
||||
}
|
||||
$timeout(() => {
|
||||
callback && callback(false);
|
||||
})
|
||||
} else {
|
||||
note.hasChanges = false;
|
||||
if(callback) {
|
||||
callback(true);
|
||||
}
|
||||
$timeout(() => {
|
||||
callback && callback(true);
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -273,7 +273,9 @@ angular.module('app')
|
||||
$scope.safeApply();
|
||||
}, 50);
|
||||
} else {
|
||||
$rootScope.notifyDelete();
|
||||
$timeout(() => {
|
||||
$rootScope.notifyDelete();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ class LockScreen {
|
||||
};
|
||||
}
|
||||
|
||||
controller($scope, passcodeManager, authManager, syncManager) {
|
||||
controller($scope, passcodeManager, authManager, syncManager, storageManager) {
|
||||
'ngInject';
|
||||
|
||||
$scope.formData = {};
|
||||
|
||||
@@ -14,6 +14,8 @@ class AccountMenu {
|
||||
'ngInject';
|
||||
|
||||
$scope.formData = {mergeLocal: true, ephemeral: false};
|
||||
$scope.formData.email = "july2@bitar.io";
|
||||
$scope.formData.user_password = "password";
|
||||
$scope.user = authManager.user;
|
||||
|
||||
syncManager.getServerURL().then((url) => {
|
||||
@@ -69,38 +71,34 @@ class AccountMenu {
|
||||
$timeout(function(){
|
||||
authManager.login($scope.formData.url, $scope.formData.email, $scope.formData.user_password,
|
||||
$scope.formData.ephemeral, $scope.formData.strictSignin, extraParams).then((response) => {
|
||||
if(!response || response.error) {
|
||||
$timeout(() => {
|
||||
if(!response || response.error) {
|
||||
|
||||
syncManager.unlockSyncing();
|
||||
syncManager.unlockSyncing();
|
||||
|
||||
$scope.formData.status = null;
|
||||
var error = response ? response.error : {message: "An unknown error occured."}
|
||||
$scope.formData.status = null;
|
||||
var error = response ? response.error : {message: "An unknown error occured."}
|
||||
|
||||
// MFA Error
|
||||
if(error.tag == "mfa-required" || error.tag == "mfa-invalid") {
|
||||
$timeout(() => {
|
||||
// MFA Error
|
||||
if(error.tag == "mfa-required" || error.tag == "mfa-invalid") {
|
||||
$scope.formData.showLogin = false;
|
||||
$scope.formData.mfa = error;
|
||||
})
|
||||
}
|
||||
|
||||
// General Error
|
||||
else {
|
||||
$timeout(() => {
|
||||
}
|
||||
// General Error
|
||||
else {
|
||||
$scope.formData.showLogin = true;
|
||||
$scope.formData.mfa = null;
|
||||
if(error.message) { alert(error.message); }
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Success
|
||||
else {
|
||||
$scope.onAuthSuccess(() => {
|
||||
syncManager.unlockSyncing();
|
||||
syncManager.sync();
|
||||
});
|
||||
}
|
||||
// Success
|
||||
else {
|
||||
$scope.onAuthSuccess(() => {
|
||||
syncManager.unlockSyncing();
|
||||
syncManager.sync();
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
})
|
||||
}
|
||||
@@ -117,15 +115,17 @@ class AccountMenu {
|
||||
|
||||
$timeout(function(){
|
||||
authManager.register($scope.formData.url, $scope.formData.email, $scope.formData.user_password, $scope.formData.ephemeral).then((response) => {
|
||||
if(!response || response.error) {
|
||||
$scope.formData.status = null;
|
||||
var error = response ? response.error : {message: "An unknown error occured."}
|
||||
alert(error.message);
|
||||
} else {
|
||||
$scope.onAuthSuccess(() => {
|
||||
syncManager.sync();
|
||||
});
|
||||
}
|
||||
$timeout(() => {
|
||||
if(!response || response.error) {
|
||||
$scope.formData.status = null;
|
||||
var error = response ? response.error : {message: "An unknown error occured."}
|
||||
alert(error.message);
|
||||
} else {
|
||||
$scope.onAuthSuccess(() => {
|
||||
syncManager.sync();
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
})
|
||||
}
|
||||
@@ -252,11 +252,29 @@ class AccountMenu {
|
||||
|
||||
$scope.importJSONData = function(data, password, callback) {
|
||||
var onDataReady = (errorCount) => {
|
||||
var items = modelManager.mapResponseItemsToLocalModels(data.items, SFModelManager.MappingSourceFileImport);
|
||||
var itemsToBeMapped = [];
|
||||
for(var itemData of data.items) {
|
||||
var existing = modelManager.findItem(itemData.uuid);
|
||||
if(existing) {
|
||||
// if the item already exists, check to see if it's different from the import data.
|
||||
// If it's the same, do nothing, otherwise, create a copy.
|
||||
itemData.uuid = null;
|
||||
var dup = modelManager.createDuplicateItem(itemData);
|
||||
if(!itemData.deleted && !existing.isItemContentEqualWith(dup)) {
|
||||
// Data differs
|
||||
modelManager.addDuplicatedItem(dup, existing);
|
||||
itemsToBeMapped.push(dup);
|
||||
}
|
||||
} else {
|
||||
// it doesn't exist, push it into items to be mapped
|
||||
itemsToBeMapped.push(itemData);
|
||||
}
|
||||
}
|
||||
|
||||
var items = modelManager.mapResponseItemsToLocalModels(itemsToBeMapped, SFModelManager.MappingSourceFileImport);
|
||||
items.forEach(function(item){
|
||||
item.setDirty(true, true);
|
||||
item.deleted = false;
|
||||
modelManager.markAllReferencesDirtyForItem(item, true);
|
||||
|
||||
// We don't want to activate any components during import process in case of exceptions
|
||||
// breaking up the import proccess
|
||||
|
||||
@@ -71,14 +71,6 @@ class AuthManager extends SFAuthManager {
|
||||
}
|
||||
}
|
||||
|
||||
async resolveResponseInTimeout(response) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.$timeout(() => {
|
||||
resolve(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async getAuthParamsForEmail(url, email, extraParams) {
|
||||
return super.getAuthParamsForEmail(url, email, extraParams);
|
||||
}
|
||||
@@ -90,25 +82,25 @@ class AuthManager extends SFAuthManager {
|
||||
this.checkForSecurityUpdate();
|
||||
}
|
||||
|
||||
return this.resolveResponseInTimeout(response);
|
||||
return response;
|
||||
})
|
||||
}
|
||||
|
||||
async register(url, email, password, ephemeral) {
|
||||
super.register(url, email, password).then((response) => {
|
||||
return super.register(url, email, password).then((response) => {
|
||||
if(!response.error) {
|
||||
this.setEphemeral(ephemeral);
|
||||
}
|
||||
return this.resolveResponseInTimeout(response);
|
||||
return response;
|
||||
})
|
||||
}
|
||||
|
||||
async changePassword(email, current_server_pw, newKeys, newAuthParams) {
|
||||
super.changePassword(email, current_server_pw, newKeys, newAuthParams).then((response) => {
|
||||
return super.changePassword(email, current_server_pw, newKeys, newAuthParams).then((response) => {
|
||||
if(!response.error) {
|
||||
this.checkForSecurityUpdate();
|
||||
}
|
||||
return this.resolveResponseInTimeout(response);
|
||||
return response;
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,10 @@ class MemoryStorage {
|
||||
return this.memory[key] || null;
|
||||
}
|
||||
|
||||
getItemSync(key) {
|
||||
return this.getItem(key);
|
||||
}
|
||||
|
||||
get length() {
|
||||
return Object.keys(this.memory).length;
|
||||
}
|
||||
@@ -70,7 +74,7 @@ class StorageManager extends SFStorageManager {
|
||||
var length = this.storage.length;
|
||||
for(var i = 0; i < length; i++) {
|
||||
var key = this.storage.key(i);
|
||||
newStorage.setItem(key, this.storage.getItemSync(key));
|
||||
newStorage.setItem(key, this.storage.getItem(key));
|
||||
}
|
||||
|
||||
this.itemsStorageMode = mode;
|
||||
@@ -134,7 +138,7 @@ class StorageManager extends SFStorageManager {
|
||||
var length = this.storage.length;
|
||||
for(var i = 0; i < length; i++) {
|
||||
var key = this.storage.key(i);
|
||||
hash[key] = this.storage.getItemSync(key)
|
||||
hash[key] = this.storage.getItem(key)
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
@@ -147,7 +151,7 @@ class StorageManager extends SFStorageManager {
|
||||
writeEncryptedStorageToDisk() {
|
||||
var encryptedStorage = new EncryptedStorage();
|
||||
// Copy over totality of current storage
|
||||
encryptedStorage.storage = this.storageAsHash();
|
||||
encryptedStorage.content.storage = this.storageAsHash();
|
||||
|
||||
// Save new encrypted storage in Fixed storage
|
||||
var params = new SFItemParams(encryptedStorage, this.encryptedStorageKeys, this.encryptedStorageAuthParams.version);
|
||||
@@ -161,7 +165,7 @@ class StorageManager extends SFStorageManager {
|
||||
await SFJS.itemTransformer.decryptItem(stored, this.encryptedStorageKeys);
|
||||
var encryptedStorage = new EncryptedStorage(stored);
|
||||
|
||||
for(var key of Object.keys(encryptedStorage.storage)) {
|
||||
for(var key of Object.keys(encryptedStorage.content.storage)) {
|
||||
this.setItem(key, encryptedStorage.storage[key]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,8 +159,8 @@
|
||||
%button.button.info{"type" => "submit"}
|
||||
.label Decrypt & Import
|
||||
%p
|
||||
Importing from backup will overwrite existing notes with matching note from backup. Existing notes not found in the backup will remain as-is and won't be overwritten.
|
||||
%p If you'd like to import only a selection of notes instead of the whole file, please use the Batch Manager extension instead.
|
||||
Importing from backup will not overwrite existing data, but instead create a duplicate of any differing data.
|
||||
%p If you'd like to import only a selection of items instead of the whole file, please use the Batch Manager extension.
|
||||
.panel-row
|
||||
.spinner.small.info{"ng-if" => "importData.loading"}
|
||||
.footer
|
||||
|
||||
Reference in New Issue
Block a user