@applicaster/zapp-react-native-ui-components 13.0.9-alpha.9185626032 → 13.0.9-rc.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.
|
@@ -17,9 +17,11 @@ import {
|
|
|
17
17
|
|
|
18
18
|
import { ZappPipesSearchContext } from "@applicaster/zapp-react-native-ui-components/Contexts";
|
|
19
19
|
import { useScreenContext } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
|
|
20
|
+
import { useScreenStateStore } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useScreenStateStore";
|
|
21
|
+
import { subscribeForKeyChanges } from "@applicaster/zapp-pipes-v2-client";
|
|
20
22
|
|
|
21
23
|
import { isVerticalListOrGrid } from "./utils";
|
|
22
|
-
import {
|
|
24
|
+
import { useFilter } from "./utils/useFilter";
|
|
23
25
|
|
|
24
26
|
type Props = {
|
|
25
27
|
component: ZappUIComponent;
|
|
@@ -204,7 +206,7 @@ export function zappPipesDataConnector(
|
|
|
204
206
|
Component: React.FC<any> | React.ComponentClass<any>
|
|
205
207
|
) {
|
|
206
208
|
return function WrappedWithZappPipesData(props: Props) {
|
|
207
|
-
const { screenData } = useRoute();
|
|
209
|
+
const { pathname, screenData } = useRoute();
|
|
208
210
|
const { plugins } = usePickFromState(["plugins"]);
|
|
209
211
|
|
|
210
212
|
const screenContextData = useScreenContext();
|
|
@@ -286,6 +288,8 @@ export function zappPipesDataConnector(
|
|
|
286
288
|
componentIndex
|
|
287
289
|
);
|
|
288
290
|
|
|
291
|
+
const screenStateStore = useScreenStateStore();
|
|
292
|
+
|
|
289
293
|
useEffect(() => {
|
|
290
294
|
if (dataSourceUrl?.includes("pipesv2://") && reloadData) {
|
|
291
295
|
const addListener = getListenerFromPlugin(dataSourceUrl, plugins);
|
|
@@ -294,9 +298,14 @@ export function zappPipesDataConnector(
|
|
|
294
298
|
return addListener(reloadData);
|
|
295
299
|
}
|
|
296
300
|
} else {
|
|
297
|
-
return
|
|
301
|
+
return subscribeForKeyChanges({
|
|
302
|
+
url: dataSourceUrl,
|
|
303
|
+
pathname,
|
|
304
|
+
screenStateStore,
|
|
305
|
+
callback: reloadData,
|
|
306
|
+
});
|
|
298
307
|
}
|
|
299
|
-
}, [dataSourceUrl, reloadData]);
|
|
308
|
+
}, [dataSourceUrl, reloadData, pathname, screenStateStore]);
|
|
300
309
|
|
|
301
310
|
useEffect(() => {
|
|
302
311
|
if (type === FAVORITES_TYPE && reloadData) {
|
|
@@ -316,12 +325,17 @@ export function zappPipesDataConnector(
|
|
|
316
325
|
[staticFeed?.loading, staticFeed?.data, data?.next, loading, data]
|
|
317
326
|
);
|
|
318
327
|
|
|
328
|
+
const applyItemFilter = useFilter({ url, loading, data, error }, component);
|
|
329
|
+
|
|
319
330
|
const zappPipesDataProps = useMemo(() => {
|
|
320
331
|
const loadNextData =
|
|
321
332
|
!isLast && isVerticalListOrGrid(component) ? undefined : loadNext;
|
|
322
333
|
|
|
323
334
|
return {
|
|
324
|
-
zappPipesData: applyItemLimit(
|
|
335
|
+
zappPipesData: applyItemLimit(
|
|
336
|
+
applyItemFilter(getZappPipesData()),
|
|
337
|
+
component
|
|
338
|
+
),
|
|
325
339
|
reloadData,
|
|
326
340
|
loadNextData,
|
|
327
341
|
};
|
|
@@ -335,6 +349,7 @@ export function zappPipesDataConnector(
|
|
|
335
349
|
data,
|
|
336
350
|
isLast,
|
|
337
351
|
component,
|
|
352
|
+
applyItemFilter,
|
|
338
353
|
]);
|
|
339
354
|
|
|
340
355
|
useFeedRefresh({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useCallback } from "react";
|
|
1
|
+
import React, { useCallback, useEffect } from "react";
|
|
2
2
|
|
|
3
3
|
import { filterObjects } from "./mongoFilter";
|
|
4
4
|
import { getNamespaceAndKey } from "@applicaster/zapp-react-native-utils/appUtils/contextKeysManager/utils";
|
|
@@ -15,7 +15,7 @@ import { useScreenStateStore } from "@applicaster/zapp-react-native-utils/reactH
|
|
|
15
15
|
import { useRoute } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
16
16
|
import { useScreenResolvers } from "@applicaster/zapp-react-native-utils/actionsExecutor/screenResolver";
|
|
17
17
|
|
|
18
|
-
const { log_error } = createLogger({
|
|
18
|
+
const { log_debug, log_error } = createLogger({
|
|
19
19
|
subsystem: "General",
|
|
20
20
|
category: "UseFilter",
|
|
21
21
|
});
|
|
@@ -33,27 +33,35 @@ export const useFilter: (
|
|
|
33
33
|
const [inflatedFilter, setInflatedFilter] = React.useState(null);
|
|
34
34
|
const screenResolvers = useScreenResolvers();
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
useEffect(() => {
|
|
37
37
|
if (!filter) {
|
|
38
38
|
setInflatedFilter(null);
|
|
39
39
|
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
.then((resolvedFilter) => {
|
|
45
|
-
setInflatedFilter(resolvedFilter);
|
|
46
|
-
})
|
|
47
|
-
.catch((error) => {
|
|
48
|
-
log_error(`Error resolving filter values: ${error.message}`);
|
|
49
|
-
setInflatedFilter(null);
|
|
50
|
-
});
|
|
43
|
+
const atValues = extractAtValues(filter);
|
|
51
44
|
|
|
52
|
-
|
|
45
|
+
log_debug("Extracted @ values from filter", { atValues });
|
|
46
|
+
|
|
47
|
+
if (!atValues.length) {
|
|
48
|
+
// no dynamic values - can apply right now
|
|
49
|
+
setInflatedFilter(filter);
|
|
50
|
+
} else {
|
|
51
|
+
const rebuildFilter = () =>
|
|
52
|
+
resolveObjectValues(filter, screenResolvers)
|
|
53
|
+
.then((resolvedFilter) => {
|
|
54
|
+
log_debug("Resolved filter values", { resolvedFilter });
|
|
55
|
+
setInflatedFilter(resolvedFilter);
|
|
56
|
+
})
|
|
57
|
+
.catch((error) => {
|
|
58
|
+
log_error(`Error resolving filter values: ${error.message}`);
|
|
59
|
+
setInflatedFilter(null);
|
|
60
|
+
});
|
|
53
61
|
|
|
54
|
-
|
|
62
|
+
rebuildFilter(); // have dynamic values - need to resolve before applying
|
|
55
63
|
|
|
56
|
-
|
|
64
|
+
// subscribe for future changes of dynamic values
|
|
57
65
|
const screenSubscriptions: (() => void)[] = atValues
|
|
58
66
|
.filter((data) => data.startsWith("screen/"))
|
|
59
67
|
.map((data: string) => {
|
|
@@ -66,6 +74,8 @@ export const useFilter: (
|
|
|
66
74
|
);
|
|
67
75
|
|
|
68
76
|
const subscription = provider.getObservable().subscribe((value) => {
|
|
77
|
+
log_debug("Screen context value changed", { keyName, value });
|
|
78
|
+
|
|
69
79
|
if (value !== undefined) {
|
|
70
80
|
rebuildFilter();
|
|
71
81
|
}
|
|
@@ -96,6 +106,8 @@ export const useFilter: (
|
|
|
96
106
|
(zappPipesData: ZappPipesData) => {
|
|
97
107
|
const { data } = zappPipesData;
|
|
98
108
|
|
|
109
|
+
log_debug("Applying filter to data", { filter, inflatedFilter });
|
|
110
|
+
|
|
99
111
|
if (!data || !data.entry) {
|
|
100
112
|
return zappPipesData;
|
|
101
113
|
}
|
|
@@ -103,8 +115,19 @@ export const useFilter: (
|
|
|
103
115
|
const noResultBehavior =
|
|
104
116
|
data?.extensions?.filter?.no_result_behavior || "show_nothing";
|
|
105
117
|
|
|
106
|
-
|
|
107
|
-
|
|
118
|
+
const filterExpression = data?.extensions?.filter?.expression;
|
|
119
|
+
|
|
120
|
+
if (filterExpression) {
|
|
121
|
+
setFilter(filterExpression);
|
|
122
|
+
|
|
123
|
+
// if there is a filter, but it is not inflated yet,
|
|
124
|
+
// and the behavior is "show_nothing" - return no results
|
|
125
|
+
if (noResultBehavior === "show_nothing" && !inflatedFilter) {
|
|
126
|
+
return {
|
|
127
|
+
...zappPipesData,
|
|
128
|
+
data: { ...data, entry: [] },
|
|
129
|
+
} as ZappPipesData;
|
|
130
|
+
}
|
|
108
131
|
}
|
|
109
132
|
|
|
110
133
|
if (!inflatedFilter) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-ui-components",
|
|
3
|
-
"version": "13.0.9-
|
|
3
|
+
"version": "13.0.9-rc.1",
|
|
4
4
|
"description": "Applicaster Zapp React Native ui components for the Quick Brick App",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"redux-mock-store": "^1.5.3"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@applicaster/applicaster-types": "13.0.9-
|
|
35
|
-
"@applicaster/zapp-react-native-bridge": "13.0.9-
|
|
36
|
-
"@applicaster/zapp-react-native-redux": "13.0.9-
|
|
37
|
-
"@applicaster/zapp-react-native-utils": "13.0.9-
|
|
34
|
+
"@applicaster/applicaster-types": "13.0.9-rc.1",
|
|
35
|
+
"@applicaster/zapp-react-native-bridge": "13.0.9-rc.1",
|
|
36
|
+
"@applicaster/zapp-react-native-redux": "13.0.9-rc.1",
|
|
37
|
+
"@applicaster/zapp-react-native-utils": "13.0.9-rc.1",
|
|
38
38
|
"promise": "^8.3.0",
|
|
39
39
|
"react-router-native": "^5.1.2",
|
|
40
40
|
"url": "^0.11.0",
|