This commit is contained in:
Mo Bitar
2018-07-08 17:49:28 -05:00
parent e53d3723c6
commit b0850ed3e3
8 changed files with 31 additions and 31 deletions

View File

@@ -86,6 +86,10 @@ angular.module('app')
syncManager.addEventHandler((syncEvent, data) => {
$rootScope.$broadcast(syncEvent, data || {});
if(syncEvent == "sync-session-invalid") {
alert("Your session has expired. New changes will not be pulled in. Please sign out and sign back in to refresh your session.");
}
});
syncManager.loadLocalItems().then(() => {
@@ -103,7 +107,7 @@ angular.module('app')
}
function loadAllTag() {
var allTag = new Tag({content: {title: "All"}});
var allTag = new SNTag({content: {title: "All"}});
allTag.all = true;
allTag.needsLoad = true;
$scope.allTag = allTag;
@@ -112,7 +116,7 @@ angular.module('app')
}
function loadArchivedTag() {
var archiveTag = new SmartTag({content: {title: "Archived", predicate: ["archived", "=", true]}});
var archiveTag = new SNSmartTag({content: {title: "Archived", predicate: ["archived", "=", true]}});
Object.defineProperty(archiveTag, "notes", {
get: () => {
return modelManager.notesMatchingPredicate(archiveTag.content.predicate);
@@ -282,10 +286,9 @@ angular.module('app')
return;
} else {
// sign out
authManager.signOut();
storageManager.clearAllData().then(() => {
authManager.signout().then(() => {
window.location.reload();
})
});
}
} else {
authManager.login(server, email, pw, false, false, {}).then((response) => {

View File

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

View File

@@ -161,7 +161,7 @@ angular.module('app')
}
this.noteCount = function(tag) {
var validNotes = Note.filterDummyNotes(tag.notes).filter(function(note){
var validNotes = SNNote.filterDummyNotes(tag.notes).filter(function(note){
return !note.archived;
});
return validNotes.length;

View File

@@ -153,7 +153,7 @@ class AccountMenu {
$scope.clearDatabaseAndRewriteAllItems(true, block);
}
else {
modelManager.resetLocalMemory();
modelManager.handleSignout();
storageManager.clearAllModels().then(() => {
block();
})
@@ -183,8 +183,7 @@ class AccountMenu {
return;
}
authManager.signOut();
storageManager.clearAllData().then(() => {
authManager.signout().then(() => {
window.location.reload();
})
}

View File

@@ -100,7 +100,6 @@ class AuthManager extends SFAuthManager {
async handleAuthResponse(response, email, url, authParams, keys) {
try {
await super.handleAuthResponse(response, email, url, authParams, keys);
this._authParams = authParams;
this.user = response.user;
this.storageManager.setItem("user", JSON.stringify(response.user));
} catch (e) {
@@ -131,7 +130,7 @@ class AuthManager extends SFAuthManager {
}
signOut() {
this._keys = null;
super.signout();
this.user = null;
this._authParams = null;
}

View File

@@ -2,7 +2,11 @@ class HttpManager extends SFHttpManager {
constructor(storageManager, $timeout) {
// calling callbacks in a $timeout allows UI to update
super(storageManager, $timeout);
super($timeout);
this.setJWTRequestHandler(async () => {
return storageManager.getItem("jwt");;
})
}
}

View File

@@ -1,13 +1,13 @@
SFModelManager.ContentTypeClassMapping = {
"Note" : Note,
"Tag" : Tag,
"SN|SmartTag" : SmartTag,
"Extension" : Extension,
"SN|Editor" : Editor,
"SN|Theme" : Theme,
"SN|Component" : Component,
"SF|Extension" : ServerExtension,
"SF|MFA" : Mfa
"Note" : SNNote,
"Tag" : SNTag,
"SN|SmartTag" : SNSmartTag,
"Extension" : SNExtension,
"SN|Editor" : SNEditor,
"SN|Theme" : SNTheme,
"SN|Component" : SNComponent,
"SF|Extension" : SNServerExtension,
"SF|MFA" : SNMfa
};
SFItem.AppDomain = "org.standardnotes.sn";
@@ -23,8 +23,8 @@ class ModelManager extends SFModelManager {
this.storageManager = storageManager;
}
resetLocalMemory() {
super.resetLocalMemory();
handleSignout() {
super.handleSignout();
this.notes.length = 0;
this.tags.length = 0;
this.components.length = 0;
@@ -75,10 +75,6 @@ class ModelManager extends SFModelManager {
}), 0, tag);
}
get filteredNotes() {
return Note.filterDummyNotes(this.notes);
}
setItemToBeDeleted(item) {
super.setItemToBeDeleted(item);

View File

@@ -149,7 +149,7 @@ class StorageManager extends SFStorageManager {
}
writeEncryptedStorageToDisk() {
var encryptedStorage = new EncryptedStorage();
var encryptedStorage = new SNEncryptedStorage();
// Copy over totality of current storage
encryptedStorage.content.storage = this.storageAsHash();
@@ -163,7 +163,7 @@ class StorageManager extends SFStorageManager {
async decryptStorage() {
var stored = JSON.parse(this.getItemSync("encryptedStorage", StorageManager.Fixed));
await SFJS.itemTransformer.decryptItem(stored, this.encryptedStorageKeys);
var encryptedStorage = new EncryptedStorage(stored);
var encryptedStorage = new SNEncryptedStorage(stored);
for(var key of Object.keys(encryptedStorage.content.storage)) {
this.setItem(key, encryptedStorage.storage[key]);