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