@growth-operations/ui-shared 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/sdk/app/settings.js +10 -2
package/package.json
CHANGED
package/src/sdk/app/settings.js
CHANGED
|
@@ -8,7 +8,10 @@
|
|
|
8
8
|
// shared with other importers.
|
|
9
9
|
//
|
|
10
10
|
// getSettings accepts { force } to bypass the cache (e.g. polling for live sync
|
|
11
|
-
// status, which a stale cache would otherwise mask).
|
|
11
|
+
// status, which a stale cache would otherwise mask). `force` bypasses BOTH the
|
|
12
|
+
// frontend module cache AND the backend account cache: it appends ?fresh=1 so a
|
|
13
|
+
// backend that honors it (e.g. toast's CacheableMixin-backed /settings) reads
|
|
14
|
+
// live state instead of its own ~120s-cached copy. updateSettings invalidates
|
|
12
15
|
// the cache on write.
|
|
13
16
|
//
|
|
14
17
|
// All requests go through callAppApi → hubspot.fetch rules apply (object body,
|
|
@@ -33,9 +36,14 @@ export function makeSettingsApi({ path = "/api/v1/settings" } = {}) {
|
|
|
33
36
|
return settingsPromise;
|
|
34
37
|
}
|
|
35
38
|
|
|
39
|
+
// On a forced read, also ask the backend to bypass its own cache (?fresh=1)
|
|
40
|
+
// so we don't just re-fetch a server-side-stale copy.
|
|
41
|
+
const reqPath = force
|
|
42
|
+
? `${path}${path.includes("?") ? "&" : "?"}fresh=1`
|
|
43
|
+
: path;
|
|
36
44
|
const fetchPromise = (async () => {
|
|
37
45
|
try {
|
|
38
|
-
const settings = await callAppApi(context,
|
|
46
|
+
const settings = await callAppApi(context, reqPath, "GET");
|
|
39
47
|
cachedSettings = settings;
|
|
40
48
|
settingsPromise = null;
|
|
41
49
|
return settings;
|