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; }
|
if(!this.note) { return; }
|
||||||
|
|
||||||
// Before checking if isMappingSourceRetrieved, we check if this item was deleted via a local source,
|
// Before checking if isMappingSourceRetrieved, we check if this item was deleted via a local source,
|
||||||
@@ -75,7 +75,7 @@ angular.module('app')
|
|||||||
this.loadTagsString();
|
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; }
|
if(!this.note) { return; }
|
||||||
|
|
||||||
for(var tag of allItems) {
|
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.noteDidChange = function(note, oldNote) {
|
||||||
this.setNote(note, oldNote);
|
this.setNote(note, oldNote);
|
||||||
this.reloadComponentContext();
|
this.reloadComponentContext();
|
||||||
@@ -95,6 +114,7 @@ angular.module('app')
|
|||||||
this.setNote = function(note, oldNote) {
|
this.setNote = function(note, oldNote) {
|
||||||
this.showExtensions = false;
|
this.showExtensions = false;
|
||||||
this.showMenu = false;
|
this.showMenu = false;
|
||||||
|
this.noteStatus = null;
|
||||||
this.loadTagsString();
|
this.loadTagsString();
|
||||||
|
|
||||||
let onReady = () => {
|
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) {
|
this.editorForNote = function(note) {
|
||||||
let editors = componentManager.componentsForArea("editor-editor");
|
let editors = componentManager.componentsForArea("editor-editor");
|
||||||
for(var editor of editors) {
|
for(var editor of editors) {
|
||||||
|
|||||||
@@ -104,6 +104,13 @@ angular.module('app')
|
|||||||
syncManager.sync();
|
syncManager.sync();
|
||||||
}, 30000);
|
}, 30000);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
authManager.addEventHandler((event) => {
|
||||||
|
if(event == SFAuthManager.DidSignOutEvent) {
|
||||||
|
modelManager.handleSignout();
|
||||||
|
syncManager.handleSignout();
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadAllTag() {
|
function loadAllTag() {
|
||||||
@@ -286,7 +293,7 @@ angular.module('app')
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
// sign out
|
// sign out
|
||||||
authManager.signout().then(() => {
|
authManager.signout(true).then(() => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class LockScreen {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
authManager.signout().then(() => {
|
authManager.signout(true).then(() => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -174,8 +174,7 @@ angular.module('app')
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.setNotes = function(notes) {
|
this.setNotes = function(notes) {
|
||||||
|
notes.forEach((note) => {
|
||||||
notes.forEach(function(note){
|
|
||||||
note.visible = true;
|
note.visible = true;
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ angular.module('app')
|
|||||||
this.selectTag(tag);
|
this.selectTag(tag);
|
||||||
}
|
}
|
||||||
} else if(data.item.content_type == "SN|SmartTag") {
|
} else if(data.item.content_type == "SN|SmartTag") {
|
||||||
var tag = new SmartTag(data.item);
|
var tag = new SNSmartTag(data.item);
|
||||||
Object.defineProperty(tag, "notes", {
|
Object.defineProperty(tag, "notes", {
|
||||||
get: () => {
|
get: () => {
|
||||||
return modelManager.notesMatchingPredicate(tag.content.predicate);
|
return modelManager.notesMatchingPredicate(tag.content.predicate);
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ 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) => {
|
||||||
@@ -153,7 +151,7 @@ class AccountMenu {
|
|||||||
$scope.clearDatabaseAndRewriteAllItems(true, block);
|
$scope.clearDatabaseAndRewriteAllItems(true, block);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
modelManager.handleSignout();
|
modelManager.removeAllItemsFromMemory();
|
||||||
storageManager.clearAllModels().then(() => {
|
storageManager.clearAllModels().then(() => {
|
||||||
block();
|
block();
|
||||||
})
|
})
|
||||||
@@ -183,7 +181,7 @@ class AccountMenu {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
authManager.signout().then(() => {
|
authManager.signout(true).then(() => {
|
||||||
window.location.reload();
|
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 newUserPassword = $scope.securityUpdate ? $scope.formData.currentPassword : $scope.formData.newPassword;
|
||||||
|
|
||||||
let currentServerPw = this.currentServerPw;
|
let currentServerPw = this.currentServerPw;
|
||||||
|
|
||||||
SFJS.crypto.generateInitialKeysAndAuthParamsForUser(authManager.user.email, newUserPassword).then((results) => {
|
let results = await SFJS.crypto.generateInitialKeysAndAuthParamsForUser(authManager.user.email, newUserPassword);
|
||||||
let newKeys = results.keys;
|
let newKeys = results.keys;
|
||||||
let newAuthParams = results.authParams;
|
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)
|
// 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) => {
|
let syncResponse = await syncManager.sync();
|
||||||
authManager.changePassword(authManager.user.email, currentServerPw, newKeys, newAuthParams).then((response) => {
|
authManager.changePassword(await syncManager.getServerURL(), authManager.user.email, currentServerPw, newKeys, newAuthParams).then((response) => {
|
||||||
if(response.error) {
|
if(response.error) {
|
||||||
alert(response.error.message ? response.error.message : "There was an error changing your password. Please try again.");
|
alert(response.error.message ? response.error.message : "There was an error changing your password. Please try again.");
|
||||||
$timeout(() => callback(false));
|
$timeout(() => callback(false));
|
||||||
} else {
|
} else {
|
||||||
$timeout(() => callback(true));
|
$timeout(() => callback(true));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class ArchiveManager {
|
|||||||
|
|
||||||
async downloadBackup(encrypted) {
|
async downloadBackup(encrypted) {
|
||||||
// download in Standard File format
|
// download in Standard File format
|
||||||
var keys, authParams, protocolVersion;
|
var keys, authParams;
|
||||||
if(encrypted) {
|
if(encrypted) {
|
||||||
if(this.authManager.offline() && this.passcodeManager.hasPasscode()) {
|
if(this.authManager.offline() && this.passcodeManager.hasPasscode()) {
|
||||||
keys = this.passcodeManager.keys();
|
keys = this.passcodeManager.keys();
|
||||||
|
|||||||
@@ -88,8 +88,8 @@ class AuthManager extends SFAuthManager {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async changePassword(email, current_server_pw, newKeys, newAuthParams) {
|
async changePassword(url, email, current_server_pw, newKeys, newAuthParams) {
|
||||||
return super.changePassword(email, current_server_pw, newKeys, newAuthParams).then((response) => {
|
return super.changePassword(url, email, current_server_pw, newKeys, newAuthParams).then((response) => {
|
||||||
if(!response.error) {
|
if(!response.error) {
|
||||||
this.checkForSecurityUpdate();
|
this.checkForSecurityUpdate();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ class DesktopManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async desktop_requestBackupFile(callback) {
|
async desktop_requestBackupFile(callback) {
|
||||||
var keys, authParams, protocolVersion;
|
var keys, authParams;
|
||||||
if(this.authManager.offline() && this.passcodeManager.hasPasscode()) {
|
if(this.authManager.offline() && this.passcodeManager.hasPasscode()) {
|
||||||
keys = this.passcodeManager.keys();
|
keys = this.passcodeManager.keys();
|
||||||
authParams = this.passcodeManager.passcodeAuthParams();
|
authParams = this.passcodeManager.passcodeAuthParams();
|
||||||
|
|||||||
@@ -30,6 +30,14 @@ class ModelManager extends SFModelManager {
|
|||||||
this.components.length = 0;
|
this.components.length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeAllItemsFromMemory() {
|
||||||
|
for(var item of this.items) {
|
||||||
|
item.deleted = true;
|
||||||
|
}
|
||||||
|
this.notifySyncObserversOfModels(this.items);
|
||||||
|
this.handleSignout();
|
||||||
|
}
|
||||||
|
|
||||||
findOrCreateTagByTitle(title) {
|
findOrCreateTagByTitle(title) {
|
||||||
var tag = _.find(this.tags, {title: title})
|
var tag = _.find(this.tags, {title: title})
|
||||||
if(!tag) {
|
if(!tag) {
|
||||||
|
|||||||
@@ -26,10 +26,6 @@ angular.module('app')
|
|||||||
return JSON.parse(storageManager.getItemSync("offlineParams", StorageManager.Fixed));
|
return JSON.parse(storageManager.getItemSync("offlineParams", StorageManager.Fixed));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.protocolVersion = function() {
|
|
||||||
return this._authParams && this._authParams.version;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.unlock = function(passcode, callback) {
|
this.unlock = function(passcode, callback) {
|
||||||
var params = this.passcodeAuthParams();
|
var params = this.passcodeAuthParams();
|
||||||
SFJS.crypto.computeEncryptionKeysForUser(passcode, params).then((keys) => {
|
SFJS.crypto.computeEncryptionKeysForUser(passcode, params).then((keys) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user