Functioning integration

This commit is contained in:
Mo Bitar
2018-06-29 17:47:02 -05:00
parent 7849c00f7d
commit b4902f03c5
7 changed files with 31 additions and 20 deletions

View File

@@ -25,7 +25,10 @@ angular.module('app')
.controller('FooterCtrl', function ($rootScope, authManager, modelManager, $timeout, dbManager,
syncManager, storageManager, passcodeManager, componentManager, singletonManager, nativeExtManager) {
this.securityUpdateAvailable = authManager.checkForSecurityUpdate();
authManager.checkForSecurityUpdate().then((available) => {
this.securityUpdateAvailable = available;
})
$rootScope.$on("security-update-status-changed", () => {
this.securityUpdateAvailable = authManager.securityUpdateAvailable;
})

View File

@@ -88,7 +88,7 @@ angular.module('app')
$rootScope.$broadcast(syncEvent, data || {});
});
syncManager.loadLocalItems(function(items) {
syncManager.loadLocalItems().then(() => {
$scope.allTag.didLoad = true;
$scope.$apply();
@@ -285,20 +285,20 @@ angular.module('app')
return $location.search()[key];
}
function autoSignInFromParams() {
async function autoSignInFromParams() {
var server = urlParam("server");
var email = urlParam("email");
var pw = urlParam("pw");
if(!authManager.offline()) {
// check if current account
if(syncManager.serverURL === server && authManager.user.email === email) {
if(await syncManager.getServerURL() === server && authManager.user.email === email) {
// already signed in, return
return;
} else {
// sign out
authManager.signOut();
storageManager.clearAllData(() => {
storageManager.clearAllData().then(() => {
window.location.reload();
})
}

View File

@@ -34,7 +34,7 @@ class LockScreen {
}
authManager.signOut();
storageManager.clearAllData(() => {
storageManager.clearAllData().then(() => {
window.location.reload();
})
}

View File

@@ -13,10 +13,19 @@ class AccountMenu {
$timeout, $compile, archiveManager) {
'ngInject';
$scope.formData = {mergeLocal: true, url: syncManager.serverURL, ephemeral: false};
$scope.formData = {mergeLocal: true, ephemeral: false};
$scope.user = authManager.user;
$scope.server = syncManager.serverURL;
$scope.securityUpdateAvailable = authManager.checkForSecurityUpdate();
syncManager.getServerURL().then((url) => {
$timeout(() => {
$scope.server = url;
$scope.formData.url = url;
})
})
authManager.checkForSecurityUpdate().then((available) => {
$scope.securityUpdateAvailable = available;
})
$scope.close = function() {
$timeout(() => {
@@ -145,7 +154,7 @@ class AccountMenu {
}
else {
modelManager.resetLocalMemory();
storageManager.clearAllModels(function(){
storageManager.clearAllModels().them(() => {
block();
})
}
@@ -162,7 +171,7 @@ class AccountMenu {
// clearAllModels will remove data from backing store, but not from working memory
// See: https://github.com/standardnotes/desktop/issues/131
$scope.clearDatabaseAndRewriteAllItems = function(alternateUuids, callback) {
storageManager.clearAllModels(() => {
storageManager.clearAllModels().then(() => {
syncManager.markAllItemsDirtyAndSaveOffline(alternateUuids).then(() => {
callback && callback();
})
@@ -175,7 +184,7 @@ class AccountMenu {
}
authManager.signOut();
storageManager.clearAllData(() => {
storageManager.clearAllData().then(() => {
window.location.reload();
})
}

View File

@@ -87,7 +87,6 @@ class AuthManager extends SFAuthManager {
return super.login(url, email, password, strictSignin, extraParams).then((response) => {
if(!response.error) {
this.setEphemeral(ephemeral);
this.handleAuthResponse(response, email, url, authParams, keys);
this.checkForSecurityUpdate();
}
@@ -124,13 +123,13 @@ class AuthManager extends SFAuthManager {
}
}
checkForSecurityUpdate() {
async checkForSecurityUpdate() {
if(this.offline()) {
return false;
}
let latest = SFJS.version();
let updateAvailable = this.protocolVersion() !== latest;
let updateAvailable = await this.protocolVersion() !== latest;
if(updateAvailable !== this.securityUpdateAvailable) {
this.securityUpdateAvailable = updateAvailable;
this.$rootScope.$broadcast("security-update-status-changed");

View File

@@ -102,7 +102,7 @@ class ModelManager extends SFModelManager {
_.pull(this._extensions, item);
}
this.storageManager.deleteModel(item, callback);
this.storageManager.deleteModel(item).then(callback);
}
/*

View File

@@ -70,7 +70,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.getItem(key));
newStorage.setItem(key, this.storage.getItemSync(key));
}
this.itemsStorageMode = mode;
@@ -134,7 +134,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.getItem(key)
hash[key] = this.storage.getItemSync(key)
}
return hash;
}
@@ -157,7 +157,7 @@ class StorageManager extends SFStorageManager {
}
async decryptStorage() {
var stored = JSON.parse(this.getItem("encryptedStorage", StorageManager.Fixed));
var stored = JSON.parse(this.getItemSync("encryptedStorage", StorageManager.Fixed));
await SFJS.itemTransformer.decryptItem(stored, this.encryptedStorageKeys);
var encryptedStorage = new EncryptedStorage(stored);
@@ -167,7 +167,7 @@ class StorageManager extends SFStorageManager {
}
hasPasscode() {
return this.getItem("encryptedStorage", StorageManager.Fixed) !== null;
return this.getItemSync("encryptedStorage", StorageManager.Fixed) !== null;
}