merged master

This commit is contained in:
Mo Bitar
2017-03-01 17:52:37 -06:00
16 changed files with 239 additions and 79 deletions

View File

@@ -78,7 +78,7 @@ angular.module('app.frontend')
callback(response);
}.bind(this), function(response){
console.error("Error logging in", response);
callback(null);
callback(response);
})
}.bind(this));
@@ -106,8 +106,8 @@ angular.module('app.frontend')
callback(response);
}.bind(this), function(response){
console.error("Registration error", response);
callback(null);
})
callback(response);
}.bind(this))
}.bind(this));
}
@@ -120,7 +120,7 @@ angular.module('app.frontend')
this.handleAuthResponse(response, email, null, authParams, keys.mk, keys.pw);
callback(response);
}.bind(this), function(response){
var error = response.data;
var error = response;
if(!error) {
error = {message: "Something went wrong while changing your password. Your password was not changed. Please try again."}
}

View File

@@ -6,10 +6,10 @@ class AccountMenu {
this.scope = {};
}
controller($scope, authManager, modelManager, syncManager, $timeout) {
controller($scope, authManager, modelManager, syncManager, dbManager, $timeout) {
'ngInject';
$scope.formData = {url: syncManager.serverURL};
$scope.formData = {mergeLocal: true, url: syncManager.serverURL};
$scope.user = authManager.user;
$scope.server = syncManager.serverURL;
@@ -82,7 +82,6 @@ class AccountMenu {
$scope.loginSubmitPressed = function() {
$scope.formData.status = "Generating Login Keys...";
console.log("logging in with url", $scope.formData.url);
$timeout(function(){
authManager.login($scope.formData.url, $scope.formData.email, $scope.formData.user_password, function(response){
if(!response || response.error) {
@@ -99,6 +98,11 @@ class AccountMenu {
}
$scope.submitRegistrationForm = function() {
var confirmation = prompt("Please confirm your password. Note that because your notes are encrypted using your password, Standard Notes does not have a password reset option. You cannot forget your password.")
if(confirmation !== $scope.formData.user_password) {
alert("The two passwords you entered do not match. Please try again.");
return;
}
$scope.formData.status = "Generating Account Keys...";
$timeout(function(){
@@ -114,10 +118,32 @@ class AccountMenu {
})
}
$scope.localNotesCount = function() {
return modelManager.filteredNotes.length;
}
$scope.mergeLocalChanged = function() {
if(!$scope.formData.mergeLocal) {
if(!confirm("Unchecking this option means any of the notes you have written while you were signed out will be deleted. Are you sure you want to discard these notes?")) {
$scope.formData.mergeLocal = true;
}
}
}
$scope.onAuthSuccess = function() {
syncManager.markAllItemsDirtyAndSaveOffline(function(){
var block = function() {
window.location.reload();
})
}
if($scope.formData.mergeLocal) {
syncManager.markAllItemsDirtyAndSaveOffline(function(){
block();
})
} else {
dbManager.clearAllItems(function(){
block();
})
}
}
$scope.destroyLocalData = function() {

View File

@@ -59,7 +59,9 @@ class ModelManager {
}
mapResponseItemsToLocalModelsOmittingFields(items, omitFields) {
var models = [];
var models = [], processedObjects = [];
// first loop should add and process items
for (var json_obj of items) {
json_obj = _.omit(json_obj, omitFields || [])
var item = this.findItem(json_obj["uuid"]);
@@ -80,11 +82,16 @@ class ModelManager {
this.addItem(item);
if(json_obj.content) {
this.resolveReferencesForItem(item);
}
models.push(item);
processedObjects.push(json_obj);
}
// second loop should process references
for (var index in processedObjects) {
var json_obj = processedObjects[index];
if(json_obj.content) {
this.resolveReferencesForItem(models[index]);
}
}
this.notifySyncObserversOfModels(models);
@@ -174,6 +181,7 @@ class ModelManager {
return;
}
for(var reference of contentObject.references) {
var referencedItem = this.findItem(reference.uuid);
if(referencedItem) {

View File

@@ -187,7 +187,6 @@ class SyncManager {
var saved = this.handleItemsResponse(response.saved_items, omitFields);
this.handleUnsavedItemsResponse(response.unsaved)
this.writeItemsToLocalStorage(saved, false, null);
this.writeItemsToLocalStorage(retrieved, false, null);
@@ -213,7 +212,7 @@ class SyncManager {
}.bind(this), function(response){
console.log("Sync error: ", response);
var error = response.data ? response.data.error : {message: "Could not connect to server."};
var error = response ? response.error : {message: "Could not connect to server."};
this.syncStatus.syncOpInProgress = false;
this.syncStatus.error = error;