Misc updates
This commit is contained in:
@@ -48,7 +48,7 @@ angular.module('app')
|
||||
}
|
||||
})
|
||||
|
||||
modelManager.addItemSyncObserver("component-manager", "Note", (allItems, validItems, deletedItems, source) => {
|
||||
modelManager.addItemSyncObserver("editor-note-observer", "Note", (allItems, validItems, deletedItems, source) => {
|
||||
if(!this.note) { return; }
|
||||
|
||||
// Before checking if isMappingSourceRetrieved, we check if this item was deleted via a local source,
|
||||
@@ -75,7 +75,7 @@ angular.module('app')
|
||||
this.loadTagsString();
|
||||
});
|
||||
|
||||
modelManager.addItemSyncObserver("component-manager", "Tag", (allItems, validItems, deletedItems, source) => {
|
||||
modelManager.addItemSyncObserver("editor-tag-observer", "Tag", (allItems, validItems, deletedItems, source) => {
|
||||
if(!this.note) { return; }
|
||||
|
||||
for(var tag of allItems) {
|
||||
@@ -87,6 +87,25 @@ angular.module('app')
|
||||
}
|
||||
});
|
||||
|
||||
// Observe editor changes to see if the current note should update its editor
|
||||
|
||||
modelManager.addItemSyncObserver("editor-component-observer", "SN|Component", (allItems, validItems, deletedItems, source) => {
|
||||
if(!this.note) { return; }
|
||||
|
||||
var editors = allItems.filter(function(item) {
|
||||
return item.isEditor();
|
||||
});
|
||||
|
||||
// If no editors have changed
|
||||
if(editors.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Look through editors again and find the most proper one
|
||||
var editor = this.editorForNote(this.note);
|
||||
this.selectedEditor = editor;
|
||||
});
|
||||
|
||||
this.noteDidChange = function(note, oldNote) {
|
||||
this.setNote(note, oldNote);
|
||||
this.reloadComponentContext();
|
||||
@@ -95,6 +114,7 @@ angular.module('app')
|
||||
this.setNote = function(note, oldNote) {
|
||||
this.showExtensions = false;
|
||||
this.showMenu = false;
|
||||
this.noteStatus = null;
|
||||
this.loadTagsString();
|
||||
|
||||
let onReady = () => {
|
||||
@@ -136,25 +156,6 @@ angular.module('app')
|
||||
}
|
||||
}
|
||||
|
||||
// Observe editor changes to see if the current note should update its editor
|
||||
|
||||
modelManager.addItemSyncObserver("component-manager", "SN|Component", (allItems, validItems, deletedItems, source) => {
|
||||
if(!this.note) { return; }
|
||||
|
||||
var editors = allItems.filter(function(item) {
|
||||
return item.isEditor();
|
||||
});
|
||||
|
||||
// If no editors have changed
|
||||
if(editors.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Look through editors again and find the most proper one
|
||||
var editor = this.editorForNote(this.note);
|
||||
this.selectedEditor = editor;
|
||||
});
|
||||
|
||||
this.editorForNote = function(note) {
|
||||
let editors = componentManager.componentsForArea("editor-editor");
|
||||
for(var editor of editors) {
|
||||
|
||||
@@ -104,6 +104,13 @@ angular.module('app')
|
||||
syncManager.sync();
|
||||
}, 30000);
|
||||
});
|
||||
|
||||
authManager.addEventHandler((event) => {
|
||||
if(event == SFAuthManager.DidSignOutEvent) {
|
||||
modelManager.handleSignout();
|
||||
syncManager.handleSignout();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function loadAllTag() {
|
||||
@@ -286,7 +293,7 @@ angular.module('app')
|
||||
return;
|
||||
} else {
|
||||
// sign out
|
||||
authManager.signout().then(() => {
|
||||
authManager.signout(true).then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class LockScreen {
|
||||
return;
|
||||
}
|
||||
|
||||
authManager.signout().then(() => {
|
||||
authManager.signout(true).then(() => {
|
||||
window.location.reload();
|
||||
})
|
||||
}
|
||||
|
||||
@@ -174,8 +174,7 @@ angular.module('app')
|
||||
}
|
||||
|
||||
this.setNotes = function(notes) {
|
||||
|
||||
notes.forEach(function(note){
|
||||
notes.forEach((note) => {
|
||||
note.visible = true;
|
||||
})
|
||||
|
||||
@@ -204,7 +203,7 @@ angular.module('app')
|
||||
this.createNewNote();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
this.selectedNote = note;
|
||||
note.conflict_of = null; // clear conflict
|
||||
this.selectionMade()(note);
|
||||
|
||||
@@ -71,7 +71,7 @@ angular.module('app')
|
||||
this.selectTag(tag);
|
||||
}
|
||||
} else if(data.item.content_type == "SN|SmartTag") {
|
||||
var tag = new SmartTag(data.item);
|
||||
var tag = new SNSmartTag(data.item);
|
||||
Object.defineProperty(tag, "notes", {
|
||||
get: () => {
|
||||
return modelManager.notesMatchingPredicate(tag.content.predicate);
|
||||
|
||||
@@ -14,8 +14,6 @@ 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) => {
|
||||
@@ -153,7 +151,7 @@ class AccountMenu {
|
||||
$scope.clearDatabaseAndRewriteAllItems(true, block);
|
||||
}
|
||||
else {
|
||||
modelManager.handleSignout();
|
||||
modelManager.removeAllItemsFromMemory();
|
||||
storageManager.clearAllModels().then(() => {
|
||||
block();
|
||||
})
|
||||
@@ -183,7 +181,7 @@ class AccountMenu {
|
||||
return;
|
||||
}
|
||||
|
||||
authManager.signout().then(() => {
|
||||
authManager.signout(true).then(() => {
|
||||
window.location.reload();
|
||||
})
|
||||
}
|
||||
|
||||
@@ -198,27 +198,25 @@ class PasswordWizard {
|
||||
});
|
||||
}
|
||||
|
||||
$scope.processPasswordChange = function(callback) {
|
||||
$scope.processPasswordChange = async function(callback) {
|
||||
let newUserPassword = $scope.securityUpdate ? $scope.formData.currentPassword : $scope.formData.newPassword;
|
||||
|
||||
let currentServerPw = this.currentServerPw;
|
||||
|
||||
SFJS.crypto.generateInitialKeysAndAuthParamsForUser(authManager.user.email, newUserPassword).then((results) => {
|
||||
let newKeys = results.keys;
|
||||
let newAuthParams = results.authParams;
|
||||
let results = await SFJS.crypto.generateInitialKeysAndAuthParamsForUser(authManager.user.email, newUserPassword);
|
||||
let newKeys = results.keys;
|
||||
let newAuthParams = results.authParams;
|
||||
|
||||
// perform a sync beforehand to pull in any last minutes changes before we change the encryption key (and thus cant decrypt new changes)
|
||||
syncManager.sync().then((response) => {
|
||||
authManager.changePassword(authManager.user.email, currentServerPw, newKeys, newAuthParams).then((response) => {
|
||||
if(response.error) {
|
||||
alert(response.error.message ? response.error.message : "There was an error changing your password. Please try again.");
|
||||
$timeout(() => callback(false));
|
||||
} else {
|
||||
$timeout(() => callback(true));
|
||||
}
|
||||
})
|
||||
})
|
||||
});
|
||||
// perform a sync beforehand to pull in any last minutes changes before we change the encryption key (and thus cant decrypt new changes)
|
||||
let syncResponse = await syncManager.sync();
|
||||
authManager.changePassword(await syncManager.getServerURL(), authManager.user.email, currentServerPw, newKeys, newAuthParams).then((response) => {
|
||||
if(response.error) {
|
||||
alert(response.error.message ? response.error.message : "There was an error changing your password. Please try again.");
|
||||
$timeout(() => callback(false));
|
||||
} else {
|
||||
$timeout(() => callback(true));
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ class ArchiveManager {
|
||||
|
||||
async downloadBackup(encrypted) {
|
||||
// download in Standard File format
|
||||
var keys, authParams, protocolVersion;
|
||||
var keys, authParams;
|
||||
if(encrypted) {
|
||||
if(this.authManager.offline() && this.passcodeManager.hasPasscode()) {
|
||||
keys = this.passcodeManager.keys();
|
||||
|
||||
@@ -88,8 +88,8 @@ class AuthManager extends SFAuthManager {
|
||||
})
|
||||
}
|
||||
|
||||
async changePassword(email, current_server_pw, newKeys, newAuthParams) {
|
||||
return super.changePassword(email, current_server_pw, newKeys, newAuthParams).then((response) => {
|
||||
async changePassword(url, email, current_server_pw, newKeys, newAuthParams) {
|
||||
return super.changePassword(url, email, current_server_pw, newKeys, newAuthParams).then((response) => {
|
||||
if(!response.error) {
|
||||
this.checkForSecurityUpdate();
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ class DesktopManager {
|
||||
}
|
||||
|
||||
async desktop_requestBackupFile(callback) {
|
||||
var keys, authParams, protocolVersion;
|
||||
var keys, authParams;
|
||||
if(this.authManager.offline() && this.passcodeManager.hasPasscode()) {
|
||||
keys = this.passcodeManager.keys();
|
||||
authParams = this.passcodeManager.passcodeAuthParams();
|
||||
|
||||
@@ -30,6 +30,14 @@ class ModelManager extends SFModelManager {
|
||||
this.components.length = 0;
|
||||
}
|
||||
|
||||
removeAllItemsFromMemory() {
|
||||
for(var item of this.items) {
|
||||
item.deleted = true;
|
||||
}
|
||||
this.notifySyncObserversOfModels(this.items);
|
||||
this.handleSignout();
|
||||
}
|
||||
|
||||
findOrCreateTagByTitle(title) {
|
||||
var tag = _.find(this.tags, {title: title})
|
||||
if(!tag) {
|
||||
|
||||
@@ -26,10 +26,6 @@ angular.module('app')
|
||||
return JSON.parse(storageManager.getItemSync("offlineParams", StorageManager.Fixed));
|
||||
}
|
||||
|
||||
this.protocolVersion = function() {
|
||||
return this._authParams && this._authParams.version;
|
||||
}
|
||||
|
||||
this.unlock = function(passcode, callback) {
|
||||
var params = this.passcodeAuthParams();
|
||||
SFJS.crypto.computeEncryptionKeysForUser(passcode, params).then((keys) => {
|
||||
|
||||
Reference in New Issue
Block a user