From cf562cc05f2ac7db165f56ea680639827cb5393e Mon Sep 17 00:00:00 2001 From: robert-costello Date: Thu, 21 Nov 2024 14:21:49 -0500 Subject: [PATCH 1/3] use AppsAPI instead of appselect:getApp --- .../static/cloudcare/js/formplayer/utils/utils.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/corehq/apps/cloudcare/static/cloudcare/js/formplayer/utils/utils.js b/corehq/apps/cloudcare/static/cloudcare/js/formplayer/utils/utils.js index 123e4cb58379..2b01bfb74d9f 100644 --- a/corehq/apps/cloudcare/static/cloudcare/js/formplayer/utils/utils.js +++ b/corehq/apps/cloudcare/static/cloudcare/js/formplayer/utils/utils.js @@ -8,6 +8,7 @@ hqDefine("cloudcare/js/formplayer/utils/utils", [ 'hqwebapp/js/initial_page_data', 'hqwebapp/js/toggles', "cloudcare/js/formplayer/constants", + 'cloudcare/js/formplayer/apps/api', ], function ( $, _, @@ -16,7 +17,8 @@ hqDefine("cloudcare/js/formplayer/utils/utils", [ bootstrap, initialPageData, toggles, - constants + constants, + AppsAPI ) { var Utils = {}; @@ -452,7 +454,7 @@ hqDefine("cloudcare/js/formplayer/utils/utils", [ Utils.setSyncInterval = function (appId, restartInterval) { hqRequire(["cloudcare/js/formplayer/app"], function (FormplayerFrontend) { - const currentApp = FormplayerFrontend.getChannel().request("appselect:getApp", appId); + const currentApp = AppsAPI.getAppEntity(appId); let customProperties = {}; if (currentApp && currentApp.attributes && currentApp.attributes.profile) { customProperties = currentApp.attributes.profile.custom_properties || {}; @@ -488,7 +490,7 @@ hqDefine("cloudcare/js/formplayer/utils/utils", [ if (!FormplayerFrontend.syncInterval) { FormplayerFrontend.syncInterval = setInterval(function () { const urlObject = Utils.currentUrlToObject(), - currentApp = FormplayerFrontend.getChannel().request("appselect:getApp", urlObject.appId); + currentApp = AppsAPI.getAppEntity(appId); let customProperties = {}; if (currentApp && currentApp.attributes && currentApp.attributes.profile) { customProperties = currentApp.attributes.profile.custom_properties || {}; From e6e1e16943f0fa020367132e73a3afaf01d04dc8 Mon Sep 17 00:00:00 2001 From: robert-costello Date: Thu, 21 Nov 2024 14:52:44 -0500 Subject: [PATCH 2/3] grab appId from urlObject --- .../cloudcare/static/cloudcare/js/formplayer/utils/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/corehq/apps/cloudcare/static/cloudcare/js/formplayer/utils/utils.js b/corehq/apps/cloudcare/static/cloudcare/js/formplayer/utils/utils.js index 2b01bfb74d9f..8096a8285c64 100644 --- a/corehq/apps/cloudcare/static/cloudcare/js/formplayer/utils/utils.js +++ b/corehq/apps/cloudcare/static/cloudcare/js/formplayer/utils/utils.js @@ -490,7 +490,7 @@ hqDefine("cloudcare/js/formplayer/utils/utils", [ if (!FormplayerFrontend.syncInterval) { FormplayerFrontend.syncInterval = setInterval(function () { const urlObject = Utils.currentUrlToObject(), - currentApp = AppsAPI.getAppEntity(appId); + currentApp = AppsAPI.getAppEntity(urlObject.appId); let customProperties = {}; if (currentApp && currentApp.attributes && currentApp.attributes.profile) { customProperties = currentApp.attributes.profile.custom_properties || {}; From e34cd50a5992efa41bd791701d2fe1dd7eea193b Mon Sep 17 00:00:00 2001 From: robert-costello Date: Thu, 21 Nov 2024 15:01:43 -0500 Subject: [PATCH 3/3] remove unused import --- .../cloudcare/js/formplayer/utils/utils.js | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/corehq/apps/cloudcare/static/cloudcare/js/formplayer/utils/utils.js b/corehq/apps/cloudcare/static/cloudcare/js/formplayer/utils/utils.js index 8096a8285c64..a90579a22496 100644 --- a/corehq/apps/cloudcare/static/cloudcare/js/formplayer/utils/utils.js +++ b/corehq/apps/cloudcare/static/cloudcare/js/formplayer/utils/utils.js @@ -453,26 +453,24 @@ hqDefine("cloudcare/js/formplayer/utils/utils", [ }; Utils.setSyncInterval = function (appId, restartInterval) { - hqRequire(["cloudcare/js/formplayer/app"], function (FormplayerFrontend) { - const currentApp = AppsAPI.getAppEntity(appId); - let customProperties = {}; - if (currentApp && currentApp.attributes && currentApp.attributes.profile) { - customProperties = currentApp.attributes.profile.custom_properties || {}; - } + const currentApp = AppsAPI.getAppEntity(appId); + let customProperties = {}; + if (currentApp && currentApp.attributes && currentApp.attributes.profile) { + customProperties = currentApp.attributes.profile.custom_properties || {}; + } - const useAggressiveSyncTiming = (customProperties[constants.POST_FORM_SYNC] === "yes"); - if (!useAggressiveSyncTiming) { - return; - } + const useAggressiveSyncTiming = (customProperties[constants.POST_FORM_SYNC] === "yes"); + if (!useAggressiveSyncTiming) { + return; + } - const FIVE_MINUTES_IN_MILLISECONDS = 1000 * 60 * 5; - if (restartInterval) { - stopSyncInterval(); - startSyncInterval(FIVE_MINUTES_IN_MILLISECONDS); - } else { - startSyncInterval(FIVE_MINUTES_IN_MILLISECONDS); - } - }); + const FIVE_MINUTES_IN_MILLISECONDS = 1000 * 60 * 5; + if (restartInterval) { + stopSyncInterval(); + startSyncInterval(FIVE_MINUTES_IN_MILLISECONDS); + } else { + startSyncInterval(FIVE_MINUTES_IN_MILLISECONDS); + } }; function startSyncInterval(delayInMilliseconds) {