diff --git a/apps/meteor/ee/server/apps/communication/rest.js b/apps/meteor/ee/server/apps/communication/rest.js index fbbae64080984..1099eaa9de85b 100644 --- a/apps/meteor/ee/server/apps/communication/rest.js +++ b/apps/meteor/ee/server/apps/communication/rest.js @@ -1007,7 +1007,7 @@ export class AppsRestApi { const updated = []; this.bodyParams.settings.forEach((s) => { - if (settings[s.id]) { + if (settings[s.id] && settings[s.id].value !== s.value) { Promise.await(manager.getSettingsManager().updateAppSetting(this.urlParams.id, s)); // Updating? updated.push(s); diff --git a/apps/meteor/server/services/apps-engine/service.ts b/apps/meteor/server/services/apps-engine/service.ts index 0356643351910..0c481c1684526 100644 --- a/apps/meteor/server/services/apps-engine/service.ts +++ b/apps/meteor/server/services/apps-engine/service.ts @@ -25,6 +25,13 @@ export class AppsEngineService extends ServiceClassInternal implements IAppsEngi }); this.onEvent('apps.added', async (appId: string): Promise => { + // if the app already exists in this instance, don't load it again + const app = Apps.getManager()?.getOneById(appId); + + if (app) { + return; + } + await (Apps.getManager() as any)?.loadOne(appId); }); @@ -64,7 +71,16 @@ export class AppsEngineService extends ServiceClassInternal implements IAppsEngi } }); - this.onEvent('apps.settingUpdated', async (appId: string, setting: ISetting): Promise => { + this.onEvent('apps.settingUpdated', async (appId: string, setting: ISetting & { id: string }): Promise => { + const app = Apps.getManager()?.getOneById(appId); + const oldSetting = app?.getStorageItem().settings[setting.id].value; + + // avoid updating the setting if the value is the same, + // which caused an infinite loop + if (oldSetting === setting.value) { + return; + } + const appManager = Apps.getManager(); if (!appManager) { return;