@applicaster/zapp-react-native-ui-components 14.0.7-rc.3 → 14.0.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.
@@ -9,10 +9,9 @@ import {
9
9
  import { isEmptyOrNil } from "@applicaster/zapp-react-native-utils/cellUtils";
10
10
  import { Categories } from "./logger";
11
11
  import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
12
- import { useRoute } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useRoute";
12
+ import { useScreenContext } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
13
13
 
14
14
  import {
15
- ZappPipesEntryContext,
16
15
  ZappPipesScreenContext,
17
16
  ZappPipesSearchContext,
18
17
  } from "@applicaster/zapp-react-native-ui-components/Contexts";
@@ -136,7 +135,6 @@ export const useCurationAPI = (
136
135
  [components]
137
136
  );
138
137
 
139
- const { pathname } = useRoute();
140
138
  const [searchContext] = ZappPipesSearchContext.useZappPipesContext();
141
139
  const [screenContext] = ZappPipesScreenContext.useZappPipesContext();
142
140
 
@@ -146,10 +144,12 @@ export const useCurationAPI = (
146
144
  screenContextType === TABS_SCREEN_TYPE ||
147
145
  screenContextType === QB_TABS_SCREEN_TYPE;
148
146
 
149
- const [entryContext] = ZappPipesEntryContext.useZappPipesContext(
150
- pathname,
151
- isNestedScreen
152
- );
147
+ const screenContextData = useScreenContext();
148
+
149
+ const entryContext = ((isNestedScreen && screenContextData?.nested?.entry
150
+ ? screenContextData?.nested?.entry
151
+ : (screenContextData?.entry?.payload ?? screenContextData?.entry)) ||
152
+ {}) as ZappEntry;
153
153
 
154
154
  const urlsMap = useMemo<{ [key: string]: string }>(() => {
155
155
  const map = {};
@@ -4,7 +4,7 @@ import { toNumberWithDefaultZero } from "@applicaster/zapp-react-native-utils/nu
4
4
  import { Button } from "./Button";
5
5
  import {
6
6
  getButtonsCount,
7
- memoizedGetPluginIdentifier,
7
+ getPluginIdentifier,
8
8
  mapSelfAlignment,
9
9
  } from "./utils";
10
10
 
@@ -80,11 +80,7 @@ export const TvActionButtons = ({
80
80
  prefix: independentStyles ? prefixSpecificButton : buttonId(1),
81
81
  value,
82
82
  platformValue,
83
- pluginIdentifier: memoizedGetPluginIdentifier(
84
- configuration,
85
- PREFIX,
86
- index
87
- ),
83
+ pluginIdentifier: getPluginIdentifier(configuration, PREFIX, index),
88
84
  suffixId: prefixSpecificButton,
89
85
  preferredFocus: index === 0,
90
86
  });
@@ -3,7 +3,7 @@ import { getPluginIdentifier } from "..";
3
3
  describe("getPluginIdentifier", () => {
4
4
  const prefix = "tv_buttons";
5
5
 
6
- it("returns the first valid plugin identifier", () => {
6
+ it("get first plugin identifier", () => {
7
7
  const configuration = {
8
8
  tv_buttons_button_1_other: "value",
9
9
  tv_buttons_button_1_assign_action:
@@ -13,12 +13,13 @@ describe("getPluginIdentifier", () => {
13
13
  };
14
14
 
15
15
  const index = 0;
16
+
16
17
  const result = getPluginIdentifier(configuration, prefix, index);
17
18
 
18
19
  expect(result).toEqual(configuration.tv_buttons_button_1_assign_action);
19
20
  });
20
21
 
21
- it("returns the second valid plugin identifier", () => {
22
+ it("get second plugin identifier", () => {
22
23
  const configuration = {
23
24
  tv_buttons_button_1_other: "value_1",
24
25
  tv_buttons_button_1_assign_action:
@@ -29,124 +30,24 @@ describe("getPluginIdentifier", () => {
29
30
  };
30
31
 
31
32
  const index = 1;
33
+
32
34
  const result = getPluginIdentifier(configuration, prefix, index);
33
35
 
34
36
  expect(result).toEqual(configuration.tv_buttons_button_2_assign_action);
35
37
  });
36
38
 
37
- it("returns undefined when there are no assign_action keys", () => {
39
+ it("get undefined if no assign_actions at all", () => {
38
40
  const configuration = {};
39
- const index = 0;
40
-
41
- const result = getPluginIdentifier(configuration, prefix, index);
42
-
43
- expect(result).toBeUndefined();
44
- });
45
-
46
- it("skips undefined values and returns the correct plugin identifier", () => {
47
- const configuration = {
48
- tv_buttons_button_1_assign_action: "tv_buttons_button_1_assign_action",
49
- tv_buttons_button_2_assign_action: undefined,
50
- tv_buttons_button_3_assign_action: "tv_buttons_button_3_assign_action",
51
- };
52
-
53
- const index = 1;
54
- const result = getPluginIdentifier(configuration, prefix, index);
55
-
56
- expect(result).toEqual(configuration.tv_buttons_button_3_assign_action);
57
- });
58
-
59
- it("handles missing intermediate keys and returns the correct plugin identifier", () => {
60
- const configuration = {
61
- tv_buttons_button_1_assign_action: "tv_buttons_button_1_assign_action",
62
- tv_buttons_button_3_assign_action: "tv_buttons_button_3_assign_action",
63
- };
64
-
65
- const index = 1;
66
- const result = getPluginIdentifier(configuration, prefix, index);
67
-
68
- expect(result).toEqual(configuration.tv_buttons_button_3_assign_action);
69
- });
70
-
71
- it("skips empty string values and returns the first non-empty assign_action", () => {
72
- const configuration = {
73
- tv_buttons_button_1_assign_action: "",
74
- tv_buttons_button_2_assign_action: "tv_buttons_button_2_assign_action",
75
- };
76
41
 
77
42
  const index = 0;
78
- const result = getPluginIdentifier(configuration, prefix, index);
79
-
80
- expect(result).toEqual(configuration.tv_buttons_button_2_assign_action);
81
- });
82
-
83
- it("returns undefined for negative index", () => {
84
- const configuration = {
85
- tv_buttons_button_1_assign_action: "a",
86
- tv_buttons_button_2_assign_action: "b",
87
- };
88
43
 
89
- const index = -1;
90
44
  const result = getPluginIdentifier(configuration, prefix, index);
91
45
 
92
46
  expect(result).toBeUndefined();
93
47
  });
94
-
95
- it("returns undefined for out-of-bounds index", () => {
96
- const configuration = {
97
- tv_buttons_button_1_assign_action: "a",
98
- tv_buttons_button_2_assign_action: "b",
99
- };
100
-
101
- const index = 5;
102
- const result = getPluginIdentifier(configuration, prefix, index);
103
-
104
- expect(result).toBeUndefined();
105
- });
106
-
107
- it("ignores keys with wrong prefix or format", () => {
108
- const configuration = {
109
- tv_buttons_button_1_assign_action: "a",
110
- tv_buttons_wrongprefix_2_assign_action: "b",
111
- tv_buttons_button_x_assign_action: "c",
112
- };
113
-
114
- const index = 1;
115
- const result = getPluginIdentifier(configuration, prefix, index);
116
-
117
- expect(result).toBeUndefined();
118
- });
119
-
120
- it("returns undefined if all assign_actions are null or empty", () => {
121
- const configuration = {
122
- tv_buttons_button_1_assign_action: null,
123
- tv_buttons_button_2_assign_action: undefined,
124
- tv_buttons_button_3_assign_action: "",
125
- };
126
-
127
- const index = 0;
128
- const result = getPluginIdentifier(configuration, prefix, index);
129
-
130
- expect(result).toBeUndefined();
131
- });
132
-
133
- it("handles non-string values correctly", () => {
134
- const configuration = {
135
- tv_buttons_button_1_assign_action: 123,
136
- tv_buttons_button_2_assign_action: true,
137
- tv_buttons_button_3_assign_action: { nested: "value" },
138
- };
139
-
140
- expect(getPluginIdentifier(configuration, prefix, 0)).toEqual(123);
141
- expect(getPluginIdentifier(configuration, prefix, 1)).toEqual(true);
142
-
143
- expect(getPluginIdentifier(configuration, prefix, 2)).toEqual({
144
- nested: "value",
145
- });
146
- });
147
48
  });
148
49
 
149
- describe("getPluginIdentifier - when configuration has duplicate values", () => {
50
+ describe("getPluginIdentifier - when configuration has same values for different keys", () => {
150
51
  const prefix = "tv_buttons";
151
52
 
152
53
  const configuration = {
@@ -154,15 +55,17 @@ describe("getPluginIdentifier - when configuration has duplicate values", () =>
154
55
  tv_buttons_button_2_assign_action: "navigation_action",
155
56
  };
156
57
 
157
- it("returns the first plugin identifier when values are identical", () => {
58
+ it("get first plugin identifier", () => {
158
59
  const index = 0;
60
+
159
61
  const result = getPluginIdentifier(configuration, prefix, index);
160
62
 
161
63
  expect(result).toEqual(configuration.tv_buttons_button_1_assign_action);
162
64
  });
163
65
 
164
- it("returns the second plugin identifier when values are identical", () => {
66
+ it("get second plugin identifier", () => {
165
67
  const index = 1;
68
+
166
69
  const result = getPluginIdentifier(configuration, prefix, index);
167
70
 
168
71
  expect(result).toEqual(configuration.tv_buttons_button_2_assign_action);
@@ -1,7 +1,7 @@
1
1
  import * as R from "ramda";
2
- import memoizee from "memoizee";
3
2
 
4
3
  import { isWeb } from "@applicaster/zapp-react-native-utils/reactUtils";
4
+ import { isNotNil } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
5
5
 
6
6
  export const getButtonsCount = (
7
7
  configuration: Record<string, unknown>,
@@ -21,28 +21,22 @@ export const getPluginIdentifier = (
21
21
  configuration: Record<string, unknown>,
22
22
  prefix: string,
23
23
  index: number
24
- ): string | undefined => {
25
- const re = new RegExp(`${prefix}_button_\\d_assign_action`);
26
- let count = 0;
27
-
28
- for (const [key, value] of Object.entries(configuration)) {
29
- if (
30
- key.startsWith(`${prefix}_button`) &&
31
- re.test(key) &&
32
- value != null &&
33
- value !== ""
34
- ) {
35
- if (count === index) return value as string;
36
- count++;
37
- }
38
- }
24
+ ): string => {
25
+ const match = `${prefix}_button_\\d_assign_action`;
26
+ const re = new RegExp(match);
39
27
 
40
- return undefined;
41
- };
28
+ const rejectNils = R.compose(R.path([index]), R.filter(isNotNil));
42
29
 
43
- export const memoizedGetPluginIdentifier = memoizee(getPluginIdentifier, {
44
- primitive: true,
45
- });
30
+ return rejectNils(
31
+ R.toPairs(configuration)
32
+ .filter(([key]) => R.startsWith(`${prefix}_button`, key))
33
+ .map(([key, value]) => {
34
+ const matched = key.match(re);
35
+
36
+ return matched ? value : undefined;
37
+ })
38
+ );
39
+ };
46
40
 
47
41
  type Label = {
48
42
  name: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-ui-components",
3
- "version": "14.0.7-rc.3",
3
+ "version": "14.0.7",
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.7-rc.3",
32
- "@applicaster/zapp-react-native-bridge": "14.0.7-rc.3",
33
- "@applicaster/zapp-react-native-redux": "14.0.7-rc.3",
34
- "@applicaster/zapp-react-native-utils": "14.0.7-rc.3",
31
+ "@applicaster/applicaster-types": "14.0.7",
32
+ "@applicaster/zapp-react-native-bridge": "14.0.7",
33
+ "@applicaster/zapp-react-native-redux": "14.0.7",
34
+ "@applicaster/zapp-react-native-utils": "14.0.7",
35
35
  "fast-json-stable-stringify": "^2.1.0",
36
36
  "promise": "^8.3.0",
37
37
  "url": "^0.11.0",