@applicaster/zapp-react-native-ui-components 14.0.0-alpha.2893452677 → 14.0.0-alpha.3011001369
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.
|
@@ -49,7 +49,9 @@ function getAssetValue(asset, flavour, fallbackAsset = null) {
|
|
|
49
49
|
return asset.src || fallbackAsset;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
export
|
|
52
|
+
export const ActionButton = React.memo(function ActionButtonComponent(
|
|
53
|
+
props: Props
|
|
54
|
+
) {
|
|
53
55
|
const { item, action, asset, flavour = "flavour_1", cellUUID } = props;
|
|
54
56
|
const actionContext = useActions(action?.identifier);
|
|
55
57
|
|
|
@@ -120,4 +122,4 @@ export function ActionButton(props: Props) {
|
|
|
120
122
|
)}
|
|
121
123
|
</TouchableOpacity>
|
|
122
124
|
);
|
|
123
|
-
}
|
|
125
|
+
});
|
|
@@ -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) => {
|
|
@@ -103,14 +111,27 @@ export const useFilter: (
|
|
|
103
111
|
const noResultBehavior =
|
|
104
112
|
data?.extensions?.filter?.no_result_behavior || "show_nothing";
|
|
105
113
|
|
|
106
|
-
|
|
107
|
-
|
|
114
|
+
const filterExpression = data?.extensions?.filter?.expression;
|
|
115
|
+
|
|
116
|
+
if (filterExpression) {
|
|
117
|
+
setFilter(filterExpression);
|
|
118
|
+
|
|
119
|
+
// if there is a filter, but it is not inflated yet,
|
|
120
|
+
// and the behavior is "show_nothing" - return no results
|
|
121
|
+
if (noResultBehavior === "show_nothing" && !inflatedFilter) {
|
|
122
|
+
return {
|
|
123
|
+
...zappPipesData,
|
|
124
|
+
data: { ...data, entry: [] },
|
|
125
|
+
} as ZappPipesData;
|
|
126
|
+
}
|
|
108
127
|
}
|
|
109
128
|
|
|
110
129
|
if (!inflatedFilter) {
|
|
111
130
|
return zappPipesData;
|
|
112
131
|
}
|
|
113
132
|
|
|
133
|
+
log_debug("Applying filter to data", { filter, inflatedFilter });
|
|
134
|
+
|
|
114
135
|
const filteredEntries = filterObjects(data.entry, inflatedFilter);
|
|
115
136
|
|
|
116
137
|
if (!filteredEntries.length && noResultBehavior === "show_all") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-ui-components",
|
|
3
|
-
"version": "14.0.0-alpha.
|
|
3
|
+
"version": "14.0.0-alpha.3011001369",
|
|
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",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@applicaster/applicaster-types": "14.0.0-alpha.
|
|
32
|
-
"@applicaster/zapp-react-native-bridge": "14.0.0-alpha.
|
|
33
|
-
"@applicaster/zapp-react-native-redux": "14.0.0-alpha.
|
|
34
|
-
"@applicaster/zapp-react-native-utils": "14.0.0-alpha.
|
|
31
|
+
"@applicaster/applicaster-types": "14.0.0-alpha.3011001369",
|
|
32
|
+
"@applicaster/zapp-react-native-bridge": "14.0.0-alpha.3011001369",
|
|
33
|
+
"@applicaster/zapp-react-native-redux": "14.0.0-alpha.3011001369",
|
|
34
|
+
"@applicaster/zapp-react-native-utils": "14.0.0-alpha.3011001369",
|
|
35
35
|
"promise": "^8.3.0",
|
|
36
36
|
"url": "^0.11.0",
|
|
37
37
|
"uuid": "^3.3.2"
|