Deactivate old editor on new select

This commit is contained in:
Mo Bitar
2017-11-08 22:21:19 -06:00
parent 092ece56a3
commit 8767f1c5ec
2 changed files with 20 additions and 7 deletions

View File

@@ -55,13 +55,18 @@ angular.module('app.frontend')
this.loadTagsString();
let associatedEditor = this.editorForNote(note);
if(associatedEditor) {
componentManager.activateComponent(associatedEditor);
} else if(this.editorComponent) {
if(this.editorComponent && this.editorComponent != associatedEditor) {
// Deactivate old editor
componentManager.deactivateComponent(this.editorComponent);
this.editorComponent = null;
}
// Activate new editor if it's different from the one currently activated
if(associatedEditor && associatedEditor != this.editorComponent) {
componentManager.activateComponent(associatedEditor);
}
this.editorComponent = associatedEditor;
this.noteReady = true;
if(note.safeText().length == 0 && note.dummy) {
@@ -93,7 +98,10 @@ angular.module('app.frontend')
} else {
// Use plain system editor
if(this.editorComponent) {
// This disassociates the editor from the note, but the component itself still needs to be deactivated
this.disableComponentForCurrentItem(this.editorComponent);
// Now deactivate the component
componentManager.deactivateComponent(this.editorComponent);
}
}
this.editorComponent = editorComponent;

View File

@@ -11,7 +11,7 @@ class ComponentManager {
this.contextStreamObservers = [];
this.activeComponents = [];
this.loggingEnabled = true;
// this.loggingEnabled = true;
this.permissionDialogs = [];
@@ -62,10 +62,11 @@ class ComponentManager {
name: "stream-context-item"
}
];
for(let observer of this.contextStreamObservers) {
this.runWithPermissions(observer.component, requiredContextPermissions, observer.originalMessage.permissions, function(){
for(let handler of this.handlers) {
if(handler.areas.includes(observer.component.area) === false) {
if(!handler.areas.includes(observer.component.area)) {
continue;
}
var itemInContext = handler.contextRequestHandler(observer.component);
@@ -78,7 +79,6 @@ class ComponentManager {
}
}.bind(this))
}
}.bind(this))
}
@@ -214,6 +214,11 @@ class ComponentManager {
else if(message.action === "save-items") {
var responseItems = message.data.items;
/*
We map the items here because modelManager is what updatese the UI. If you were to instead get the items directly,
this would update them server side via sync, but would never make its way back to the UI.
*/
var localItems = this.modelManager.mapResponseItemsToLocalModels(responseItems);
for(var item of localItems) {