Skip to content

Commit

Permalink
Merge pull request #35416 from dimagi/rc/fix-replace-call-to-missing-…
Browse files Browse the repository at this point in the history
…fp-func

use AppsAPI instead of appselect:getApp
  • Loading branch information
Robert-Costello authored Nov 21, 2024
2 parents 80feb53 + e34cd50 commit be39fb3
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions corehq/apps/cloudcare/static/cloudcare/js/formplayer/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
$,
_,
Expand All @@ -16,7 +17,8 @@ hqDefine("cloudcare/js/formplayer/utils/utils", [
bootstrap,
initialPageData,
toggles,
constants
constants,
AppsAPI
) {
var Utils = {};

Expand Down Expand Up @@ -451,26 +453,24 @@ 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);
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) {
Expand All @@ -488,7 +488,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(urlObject.appId);
let customProperties = {};
if (currentApp && currentApp.attributes && currentApp.attributes.profile) {
customProperties = currentApp.attributes.profile.custom_properties || {};
Expand Down

0 comments on commit be39fb3

Please sign in to comment.