@promoboxx/use-filter 1.11.0 → 1.11.1
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/useFilter.js +9 -4
- package/dist/useSimpleFilter.js +14 -2
- package/package.json +1 -1
package/dist/useFilter.js
CHANGED
|
@@ -47,10 +47,15 @@ function useFilter(namespace, options) {
|
|
|
47
47
|
ctxRef.current = ctxRefValue;
|
|
48
48
|
});
|
|
49
49
|
var _a = react_1.useState(function () {
|
|
50
|
-
var
|
|
51
|
-
var
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
var _a;
|
|
51
|
+
var fromStore = store_1.getFilterStore(ctxRef.current.store).getFilter(namespace);
|
|
52
|
+
// If the filter is already in the store, we have to make sure it ...
|
|
53
|
+
// - has both the filter and filterInfo
|
|
54
|
+
// - has all the fields the user passed to the hook
|
|
55
|
+
if (fromStore) {
|
|
56
|
+
var filterInfo_1 = buildDefaultFilterInfo_1.default(__assign(__assign({}, fromStore), { shouldRunImmediately: true, filter: __assign(__assign({}, (_a = options.defaultFilterInfo) === null || _a === void 0 ? void 0 : _a.filter), fromStore.filter) }));
|
|
57
|
+
return filterInfo_1;
|
|
58
|
+
}
|
|
54
59
|
}), filterInfo = _a[0], setFilterInfoState = _a[1];
|
|
55
60
|
var _b = react_1.useState(function () {
|
|
56
61
|
return store_1.getFilterStore(ctxRef.current.store).getData(namespace);
|
package/dist/useSimpleFilter.js
CHANGED
|
@@ -34,8 +34,20 @@ function useSimpleFilter(namespace, options) {
|
|
|
34
34
|
ctxRef.current = ctxRefValue;
|
|
35
35
|
});
|
|
36
36
|
var _a = react_1.useState(false), isLoading = _a[0], setIsLoading = _a[1];
|
|
37
|
-
var _b = react_1.useState(function () {
|
|
38
|
-
|
|
37
|
+
var _b = react_1.useState(function () {
|
|
38
|
+
var _a;
|
|
39
|
+
var fromStore = store_1.getFilterStore(ctxRef.current.store).getFilter(namespace);
|
|
40
|
+
// If the filter is already in the store, we have to make sure it ...
|
|
41
|
+
// - has both the filter and filterInfo
|
|
42
|
+
// - has all the fields the user passed to the hook
|
|
43
|
+
if (fromStore) {
|
|
44
|
+
var filterInfo_1 = buildDefaultFilterInfo(__assign(__assign({}, fromStore), { shouldRunImmediately: true, filter: __assign(__assign({}, (_a = options.defaultFilterInfo) === null || _a === void 0 ? void 0 : _a.filter), fromStore.filter) }));
|
|
45
|
+
return filterInfo_1;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
return buildDefaultFilterInfo(__assign(__assign({}, options.defaultFilterInfo), { shouldRunImmediately: true }));
|
|
49
|
+
}
|
|
50
|
+
}), filterInfo = _b[0], setFilterInfoState = _b[1];
|
|
39
51
|
var _c = react_1.useState(filterInfo), debouncedFilterInfo = _c[0], setDebouncedFilterInfo = _c[1];
|
|
40
52
|
// Not sure this is needed in simple mode?
|
|
41
53
|
var lastRefreshAtRef = react_1.useRef(-1);
|