Reload component context on unhide
This commit is contained in:
@@ -713,7 +713,7 @@ angular.module('app')
|
||||
if(this.note) {
|
||||
for(var component of this.componentStack) {
|
||||
if(component.active) {
|
||||
component.hidden = !component.isExplicitlyEnabledForItem(this.note);
|
||||
componentManager.setComponentHidden(component, !component.isExplicitlyEnabledForItem(this.note));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -728,7 +728,7 @@ angular.module('app')
|
||||
// If it's not active, then hidden won't be set, and we mean to activate and show it.
|
||||
if(component.hidden || !component.active) {
|
||||
// Unhide, associate with current item
|
||||
component.hidden = false;
|
||||
componentManager.setComponentHidden(component, false);
|
||||
this.associateComponentWithCurrentNote(component);
|
||||
if(!component.active) {
|
||||
componentManager.activateComponent(component);
|
||||
@@ -736,7 +736,7 @@ angular.module('app')
|
||||
componentManager.contextItemDidChangeInArea("editor-stack");
|
||||
} else {
|
||||
// not hidden, hide
|
||||
component.hidden = true;
|
||||
componentManager.setComponentHidden(component, true);
|
||||
this.disassociateComponentWithCurrentNote(component);
|
||||
}
|
||||
}
|
||||
@@ -749,6 +749,7 @@ angular.module('app')
|
||||
}
|
||||
|
||||
component.setDirty(true);
|
||||
syncManager.sync();
|
||||
}
|
||||
|
||||
this.associateComponentWithCurrentNote = function(component) {
|
||||
@@ -759,6 +760,7 @@ angular.module('app')
|
||||
}
|
||||
|
||||
component.setDirty(true);
|
||||
syncManager.sync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -197,6 +197,32 @@ class ComponentManager {
|
||||
}
|
||||
}
|
||||
|
||||
setComponentHidden(component, hidden) {
|
||||
/*
|
||||
A hidden component will not receive messages.
|
||||
However, when a component is unhidden, we need to send it any items it may have
|
||||
registered streaming for.
|
||||
*/
|
||||
if(hidden) {
|
||||
component.hidden = true;
|
||||
} else if(component.hidden) {
|
||||
// Only enter this condition if component is hidden to make this note have double side effects.
|
||||
component.hidden = false;
|
||||
|
||||
// streamContextItem
|
||||
let contextObserver = _.find(this.contextStreamObservers, {identifier: component.uuid});
|
||||
if(contextObserver) {
|
||||
this.handleStreamContextItemMessage(component, contextObserver.originalMessage);
|
||||
}
|
||||
|
||||
// streamItems
|
||||
let streamObserver = _.find(this.streamObservers, {identifier: component.uuid});
|
||||
if(streamObserver) {
|
||||
this.handleStreamItemsMessage(component, streamObserver.originalMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
jsonForItem(item, component, source) {
|
||||
var params = {uuid: item.uuid, content_type: item.content_type, created_at: item.created_at, updated_at: item.updated_at, deleted: item.deleted};
|
||||
params.content = item.createContentJSONFromProperties();
|
||||
|
||||
Reference in New Issue
Block a user