use-frontbacked 5.1.6 → 5.1.7
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/dist/cjs/index.js +33 -23
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.es.js +33 -23
- package/dist/esm/index.es.js.map +1 -1
- package/package.json +2 -1
package/dist/esm/index.es.js
CHANGED
|
@@ -2932,17 +2932,20 @@ var DownloadType = function DownloadType(_a) {
|
|
|
2932
2932
|
}
|
|
2933
2933
|
}, [adminInfo]);
|
|
2934
2934
|
useEffect(function () {
|
|
2935
|
+
var _a, _b, _c, _d;
|
|
2935
2936
|
if (onGetTool && toolId) {
|
|
2936
2937
|
var tool = onGetTool(toolId);
|
|
2937
2938
|
consoleLog("DownloadType.setDocRules", tool);
|
|
2938
|
-
setDocRules(!tool ? null :
|
|
2939
|
-
allow_freemium: (tool === null || tool === void 0 ? void 0 : tool.allow_freemium)
|
|
2940
|
-
create_price: (tool === null || tool === void 0 ? void 0 : tool.create_price)
|
|
2941
|
-
update_price: (tool === null || tool === void 0 ? void 0 : tool.update_price)
|
|
2942
|
-
create_price_is_monthly: (tool === null || tool === void 0 ? void 0 : tool.create_price_is_monthly)
|
|
2939
|
+
setDocRules(!tool ? null : {
|
|
2940
|
+
allow_freemium: (_a = tool === null || tool === void 0 ? void 0 : tool.allow_freemium) !== null && _a !== void 0 ? _a : true,
|
|
2941
|
+
create_price: (_b = tool === null || tool === void 0 ? void 0 : tool.create_price) !== null && _b !== void 0 ? _b : 0,
|
|
2942
|
+
update_price: (_c = tool === null || tool === void 0 ? void 0 : tool.update_price) !== null && _c !== void 0 ? _c : 0,
|
|
2943
|
+
create_price_is_monthly: (_d = tool === null || tool === void 0 ? void 0 : tool.create_price_is_monthly) !== null && _d !== void 0 ? _d : false,
|
|
2943
2944
|
yearly_price: tool === null || tool === void 0 ? void 0 : tool.yearly_price,
|
|
2944
2945
|
quarterly_price: tool === null || tool === void 0 ? void 0 : tool.quarterly_price
|
|
2945
|
-
})
|
|
2946
|
+
});
|
|
2947
|
+
} else {
|
|
2948
|
+
setDocRules(null);
|
|
2946
2949
|
}
|
|
2947
2950
|
}, [onGetTool, toolId]);
|
|
2948
2951
|
var download = function download() {
|
|
@@ -3081,7 +3084,7 @@ var DownloadType = function DownloadType(_a) {
|
|
|
3081
3084
|
setAutoProcessOn(false);
|
|
3082
3085
|
}
|
|
3083
3086
|
}
|
|
3084
|
-
}, [docRules]);
|
|
3087
|
+
}, [docRules, permission.isToolsEditor, toolId, updateMessage, removeFreemiumBeforeUpdate, renewSubscription, isFreemium]);
|
|
3085
3088
|
if (permission.isToolsEditor && toolId == "other_tools" || !toolId || !onGetTool || !freeTitle || !freeMessage || !paidTitle || !paidMessage) return null;
|
|
3086
3089
|
return /*#__PURE__*/React.createElement(DrawerPop, {
|
|
3087
3090
|
placement: "bottom",
|
|
@@ -3254,11 +3257,23 @@ var readCachedMetadata = function readCachedMetadata() {
|
|
|
3254
3257
|
return null;
|
|
3255
3258
|
}
|
|
3256
3259
|
};
|
|
3260
|
+
var readCachedToolsData = function readCachedToolsData() {
|
|
3261
|
+
if (!isBrowser()) return null;
|
|
3262
|
+
if (window.toolsCache) return window.toolsCache;
|
|
3263
|
+
var cachedMetadata = readCachedMetadata();
|
|
3264
|
+
var cachedData = cachedMetadata === null || cachedMetadata === void 0 ? void 0 : cachedMetadata.cachedData;
|
|
3265
|
+
if (cachedData) {
|
|
3266
|
+
window.toolsCache = cachedData;
|
|
3267
|
+
return cachedData;
|
|
3268
|
+
}
|
|
3269
|
+
return null;
|
|
3270
|
+
};
|
|
3257
3271
|
var useTools = function useTools(config) {
|
|
3258
|
-
var
|
|
3272
|
+
var cachedToolsData = readCachedToolsData();
|
|
3273
|
+
var _a = useState(cachedToolsData),
|
|
3259
3274
|
data = _a[0],
|
|
3260
3275
|
setData = _a[1];
|
|
3261
|
-
var _b = useState(!
|
|
3276
|
+
var _b = useState(!cachedToolsData),
|
|
3262
3277
|
loading = _b[0],
|
|
3263
3278
|
setLoading = _b[1];
|
|
3264
3279
|
var _c = useState(null),
|
|
@@ -3272,31 +3287,26 @@ var useTools = function useTools(config) {
|
|
|
3272
3287
|
setToolsByTemplatesUrl = _e[1];
|
|
3273
3288
|
useEffect(function () {
|
|
3274
3289
|
if (!(config === null || config === void 0 ? void 0 : config.r2Domain)) return;
|
|
3275
|
-
|
|
3276
|
-
|
|
3290
|
+
var cachedToolsData = readCachedToolsData();
|
|
3291
|
+
if (cachedToolsData) {
|
|
3292
|
+
setData(cachedToolsData);
|
|
3277
3293
|
setLoading(false);
|
|
3278
|
-
consoleLog("useTools.returns
|
|
3294
|
+
consoleLog("useTools.returns cached tools data: ", cachedToolsData);
|
|
3279
3295
|
}
|
|
3280
3296
|
if (!window.toolsFetchPromise) {
|
|
3281
3297
|
window.toolsFetchPromise = function () {
|
|
3282
3298
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
3283
|
-
var attempts,
|
|
3299
|
+
var attempts, cachedData, response, err_1;
|
|
3284
3300
|
var _a, _b;
|
|
3285
3301
|
return __generator(this, function (_c) {
|
|
3286
3302
|
switch (_c.label) {
|
|
3287
3303
|
case 0:
|
|
3288
3304
|
attempts = 0;
|
|
3289
|
-
|
|
3290
|
-
if (
|
|
3291
|
-
cachedData
|
|
3292
|
-
|
|
3293
|
-
window.toolsCache = cachedData;
|
|
3294
|
-
setData(cachedData);
|
|
3295
|
-
setLoading(false);
|
|
3296
|
-
//return cachedData;
|
|
3297
|
-
}
|
|
3305
|
+
cachedData = readCachedToolsData();
|
|
3306
|
+
if (cachedData) {
|
|
3307
|
+
setData(cachedData);
|
|
3308
|
+
setLoading(false);
|
|
3298
3309
|
}
|
|
3299
|
-
|
|
3300
3310
|
consoleLog("useTools.refreshing");
|
|
3301
3311
|
_c.label = 1;
|
|
3302
3312
|
case 1:
|