Components autoupdate
This commit is contained in:
@@ -20,6 +20,7 @@ class Component extends Item {
|
|||||||
super.mapContentToLocalProperties(content)
|
super.mapContentToLocalProperties(content)
|
||||||
this.url = content.url;
|
this.url = content.url;
|
||||||
this.name = content.name;
|
this.name = content.name;
|
||||||
|
this.autoupdate = content.autoupdate;
|
||||||
|
|
||||||
this.package_info = content.package_info;
|
this.package_info = content.package_info;
|
||||||
|
|
||||||
@@ -49,6 +50,7 @@ class Component extends Item {
|
|||||||
permissions: this.permissions,
|
permissions: this.permissions,
|
||||||
active: this.active,
|
active: this.active,
|
||||||
local: this.local,
|
local: this.local,
|
||||||
|
autoupdate: this.autoupdate,
|
||||||
componentData: this.componentData,
|
componentData: this.componentData,
|
||||||
disassociatedItemIds: this.disassociatedItemIds,
|
disassociatedItemIds: this.disassociatedItemIds,
|
||||||
associatedItemIds: this.associatedItemIds,
|
associatedItemIds: this.associatedItemIds,
|
||||||
|
|||||||
@@ -44,8 +44,14 @@ class ComponentManager {
|
|||||||
|
|
||||||
var syncedComponents = allItems.filter(function(item){return item.content_type === "SN|Component" });
|
var syncedComponents = allItems.filter(function(item){return item.content_type === "SN|Component" });
|
||||||
|
|
||||||
// Ensure any component in our data is installed by the system
|
/* We only want to sync if the item source is Retrieved, not MappingSourceRemoteSaved to avoid
|
||||||
this.desktopManager.syncComponentsInstallation(syncedComponents);
|
recursion caused by the component being modified and saved after it is updated.
|
||||||
|
*/
|
||||||
|
if(syncedComponents.length > 0 && source != ModelManager.MappingSourceRemoteSaved) {
|
||||||
|
console.log("Web, Syncing Components", syncedComponents, "source", source);
|
||||||
|
// Ensure any component in our data is installed by the system
|
||||||
|
this.desktopManager.syncComponentsInstallation(syncedComponents);
|
||||||
|
}
|
||||||
|
|
||||||
for(var component of syncedComponents) {
|
for(var component of syncedComponents) {
|
||||||
var activeComponent = _.find(this.activeComponents, {uuid: component.uuid});
|
var activeComponent = _.find(this.activeComponents, {uuid: component.uuid});
|
||||||
@@ -61,6 +67,10 @@ class ComponentManager {
|
|||||||
return observer.contentTypes.indexOf(item.content_type) !== -1;
|
return observer.contentTypes.indexOf(item.content_type) !== -1;
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if(relevantItems.length == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
var requiredPermissions = [
|
var requiredPermissions = [
|
||||||
{
|
{
|
||||||
name: "stream-items",
|
name: "stream-items",
|
||||||
|
|||||||
@@ -2,10 +2,11 @@
|
|||||||
|
|
||||||
class DesktopManager {
|
class DesktopManager {
|
||||||
|
|
||||||
constructor($rootScope, modelManager, authManager, passcodeManager) {
|
constructor($rootScope, modelManager, syncManager, authManager, passcodeManager) {
|
||||||
this.passcodeManager = passcodeManager;
|
this.passcodeManager = passcodeManager;
|
||||||
this.modelManager = modelManager;
|
this.modelManager = modelManager;
|
||||||
this.authManager = authManager;
|
this.authManager = authManager;
|
||||||
|
this.syncManager = syncManager;
|
||||||
this.$rootScope = $rootScope;
|
this.$rootScope = $rootScope;
|
||||||
|
|
||||||
this.isDesktop = isDesktopApplication();
|
this.isDesktop = isDesktopApplication();
|
||||||
@@ -46,12 +47,22 @@ class DesktopManager {
|
|||||||
// All `components` should be installed
|
// All `components` should be installed
|
||||||
syncComponentsInstallation(components) {
|
syncComponentsInstallation(components) {
|
||||||
if(!this.isDesktop) return;
|
if(!this.isDesktop) return;
|
||||||
|
|
||||||
|
/* Allows us to look up component on desktop_updateComponentComplete */
|
||||||
|
this.syncingComponents = components;
|
||||||
|
|
||||||
var data = components.map((component) => {
|
var data = components.map((component) => {
|
||||||
return this.convertComponentForTransmission(component);
|
return this.convertComponentForTransmission(component);
|
||||||
})
|
})
|
||||||
this.installationSyncHandler(data);
|
this.installationSyncHandler(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
desktop_updateComponentComplete(componentData) {
|
||||||
|
var component = this.syncingComponents.filter((c) => {return c.uuid == componentData.uuid})[0];
|
||||||
|
component.setDirty(true);
|
||||||
|
this.syncManager.sync();
|
||||||
|
}
|
||||||
|
|
||||||
/* Used to resolve "sn://" */
|
/* Used to resolve "sn://" */
|
||||||
desktop_setApplicationDataPath(path) {
|
desktop_setApplicationDataPath(path) {
|
||||||
this.applicationDataPath = path;
|
this.applicationDataPath = path;
|
||||||
|
|||||||
Reference in New Issue
Block a user