@usereactify/search 3.10.3 → 3.11.0
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.
|
@@ -41,7 +41,7 @@ function getCachedConfig() {
|
|
|
41
41
|
}
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
|
-
const useLiveConfig = (shopifyPermanentDomain) => {
|
|
44
|
+
const useLiveConfig = (shopifyPermanentDomain, configId) => {
|
|
45
45
|
const [config, setConfig] = react_1.default.useState(getCachedConfig());
|
|
46
46
|
react_1.default.useEffect(() => {
|
|
47
47
|
const cachedConfig = getCachedConfig();
|
|
@@ -49,14 +49,19 @@ const useLiveConfig = (shopifyPermanentDomain) => {
|
|
|
49
49
|
return;
|
|
50
50
|
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
51
51
|
debug("fetching fresh config");
|
|
52
|
-
const
|
|
52
|
+
const searchParams = new URLSearchParams();
|
|
53
|
+
searchParams.set("shop", shopifyPermanentDomain);
|
|
54
|
+
if (configId) {
|
|
55
|
+
searchParams.set("id", configId);
|
|
56
|
+
}
|
|
57
|
+
const json = yield fetch(`https://config.search.reactify.app/?${searchParams.toString()}`).then((response) => response.json());
|
|
53
58
|
setConfig(json.body);
|
|
54
59
|
window.sessionStorage.setItem("reactify-search:config", JSON.stringify({
|
|
55
60
|
expiresAt: new Date().getTime() + CACHE_EXPIRY,
|
|
56
61
|
config: json.body,
|
|
57
62
|
}));
|
|
58
63
|
}))();
|
|
59
|
-
}, [shopifyPermanentDomain]);
|
|
64
|
+
}, [shopifyPermanentDomain, configId]);
|
|
60
65
|
return {
|
|
61
66
|
config,
|
|
62
67
|
};
|
package/dist/provider.d.ts
CHANGED
package/dist/provider.js
CHANGED
|
@@ -27,7 +27,7 @@ const defaultCredentials = {
|
|
|
27
27
|
};
|
|
28
28
|
const Provider = (_a) => {
|
|
29
29
|
var { renderBooting } = _a, props = __rest(_a, ["renderBooting"]);
|
|
30
|
-
const { config } = (0, hooks_1.useLiveConfig)(props.shopifyPermanentDomain);
|
|
30
|
+
const { config } = (0, hooks_1.useLiveConfig)(props.shopifyPermanentDomain, props.configId);
|
|
31
31
|
if (!config) {
|
|
32
32
|
if (renderBooting)
|
|
33
33
|
return renderBooting();
|
|
@@ -83,7 +83,7 @@ const ConfiguredProvider = (props) => {
|
|
|
83
83
|
}, [searchSortFromURL]);
|
|
84
84
|
react_1.default.useEffect(() => {
|
|
85
85
|
if (window.location.search === "" && (sortOption === null || sortOption === void 0 ? void 0 : sortOption.id)) {
|
|
86
|
-
setSortOption(
|
|
86
|
+
setSortOption(sortOption.id, true);
|
|
87
87
|
}
|
|
88
88
|
}, [window.location.href]);
|
|
89
89
|
const [showInstantSearchResults, setShowInstantSearchResults] = react_1.default.useState(false);
|