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