More explicit variable names and comments for synced items

This commit is contained in:
Mo Bitar
2017-11-04 13:35:18 -05:00
parent 341c5d7dd7
commit 9b0f802537
4 changed files with 39 additions and 20 deletions

View File

@@ -28,12 +28,12 @@ class ComponentManager {
this.handleMessage(this.componentForSessionKey(event.data.sessionKey), event.data);
}.bind(this), false);
this.modelManager.addItemSyncObserver("component-manager", "*", function(items) {
this.modelManager.addItemSyncObserver("component-manager", "*", function(allItems, validItems, deletedItems) {
var syncedComponents = items.filter(function(item){return item.content_type === "SN|Component" });
var syncedComponents = allItems.filter(function(item){return item.content_type === "SN|Component" });
for(var component of syncedComponents) {
var activeComponent = _.find(this.activeComponents, {uuid: component.uuid});
if(component.active && !activeComponent) {
if(component.active && !component.deleted && !activeComponent) {
this.activateComponent(component);
} else if(!component.active && activeComponent) {
this.deactivateComponent(component);
@@ -41,7 +41,7 @@ class ComponentManager {
}
for(let observer of this.streamObservers) {
var relevantItems = items.filter(function(item){
var relevantItems = allItems.filter(function(item){
return observer.contentTypes.indexOf(item.content_type) !== -1;
})
@@ -70,7 +70,7 @@ class ComponentManager {
}
var itemInContext = handler.contextRequestHandler(observer.component);
if(itemInContext) {
var matchingItem = _.find(items, {uuid: itemInContext.uuid});
var matchingItem = _.find(allItems, {uuid: itemInContext.uuid});
if(matchingItem) {
this.sendContextItemInReply(observer.component, matchingItem, observer.originalMessage);
}