@applicaster/zapp-react-native-utils 14.0.0-alpha.4517121861 → 14.0.0-alpha.4596155133

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.
Files changed (53) hide show
  1. package/actionsExecutor/ActionExecutorContext.tsx +60 -83
  2. package/actionsExecutor/ScreenActions.ts +163 -0
  3. package/actionsExecutor/StorageActions.ts +110 -0
  4. package/actionsExecutor/feedDecorator.ts +171 -0
  5. package/actionsExecutor/screenResolver.ts +11 -0
  6. package/analyticsUtils/AnalyticsEvents/helper.ts +1 -1
  7. package/analyticsUtils/AnalyticsEvents/sendHeaderClickEvent.ts +1 -1
  8. package/analyticsUtils/AnalyticsEvents/sendMenuClickEvent.ts +2 -1
  9. package/analyticsUtils/index.tsx +3 -4
  10. package/analyticsUtils/manager.ts +1 -1
  11. package/appUtils/HooksManager/Hook.ts +4 -4
  12. package/appUtils/HooksManager/index.ts +11 -1
  13. package/appUtils/accessibilityManager/index.ts +3 -3
  14. package/appUtils/contextKeysManager/contextResolver.ts +31 -1
  15. package/appUtils/focusManager/treeDataStructure/Tree/index.js +1 -1
  16. package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +0 -15
  17. package/appUtils/playerManager/useChapterMarker.tsx +0 -1
  18. package/appUtils/playerManager/usePlayerControllerSetup.tsx +16 -0
  19. package/arrayUtils/index.ts +1 -1
  20. package/componentsUtils/__tests__/isTabsScreen.test.ts +38 -0
  21. package/componentsUtils/index.ts +4 -1
  22. package/configurationUtils/__tests__/manifestKeyParser.test.ts +547 -0
  23. package/configurationUtils/manifestKeyParser.ts +57 -32
  24. package/index.d.ts +0 -9
  25. package/navigationUtils/__tests__/mapContentTypesToRivers.test.ts +130 -0
  26. package/navigationUtils/index.ts +6 -4
  27. package/package.json +2 -3
  28. package/playerUtils/index.ts +51 -0
  29. package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +15 -14
  30. package/reactHooks/cell-click/index.ts +8 -1
  31. package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +39 -88
  32. package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +20 -0
  33. package/reactHooks/feed/useBatchLoading.ts +8 -6
  34. package/reactHooks/feed/useFeedLoader.tsx +25 -12
  35. package/reactHooks/feed/usePipesCacheReset.ts +2 -2
  36. package/reactHooks/flatList/useSequentialRenderItem.tsx +3 -3
  37. package/reactHooks/layout/__tests__/index.test.tsx +3 -1
  38. package/reactHooks/layout/isTablet/index.ts +12 -5
  39. package/reactHooks/layout/useDimensions/__tests__/useDimensions.test.ts +34 -36
  40. package/reactHooks/layout/useDimensions/useDimensions.ts +2 -3
  41. package/reactHooks/layout/useLayoutVersion.ts +5 -5
  42. package/reactHooks/navigation/index.ts +7 -5
  43. package/reactHooks/navigation/useRoute.ts +7 -2
  44. package/reactHooks/navigation/useScreenStateStore.ts +8 -0
  45. package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +4 -0
  46. package/reactHooks/state/useRivers.ts +7 -8
  47. package/storage/ScreenSingleValueProvider.ts +201 -0
  48. package/storage/ScreenStateMultiSelectProvider.ts +290 -0
  49. package/storage/StorageMultiSelectProvider.ts +192 -0
  50. package/storage/StorageSingleSelectProvider.ts +108 -0
  51. package/testUtils/index.tsx +7 -8
  52. package/time/BackgroundTimer.ts +1 -1
  53. package/utils/index.ts +1 -0
@@ -0,0 +1,130 @@
1
+ import { mapContentTypesToRivers } from "../index";
2
+
3
+ describe("mapContentTypesToRivers", () => {
4
+ it("should return the correct content types mapped to rivers", () => {
5
+ const state = {
6
+ rivers: {
7
+ "river-1": {
8
+ plugin_type: "river",
9
+ },
10
+ },
11
+ contentTypes: {
12
+ "content-type-1": {
13
+ screen_id: "river-1",
14
+ },
15
+ },
16
+ };
17
+
18
+ const result = mapContentTypesToRivers(state);
19
+
20
+ expect(result).toEqual({
21
+ "content-type-1": {
22
+ screenType: "river",
23
+ screen_id: "river-1",
24
+ },
25
+ });
26
+ });
27
+
28
+ it("should return null if contentTypes is undefined", () => {
29
+ const state = {
30
+ rivers: {
31
+ "river-1": {
32
+ plugin_type: "river",
33
+ },
34
+ },
35
+ // contentTypes is missing
36
+ };
37
+
38
+ const result = mapContentTypesToRivers(state);
39
+
40
+ expect(result).toBeNull();
41
+ });
42
+
43
+ it("should skip content types whose screen does not exist in rivers", () => {
44
+ const state = {
45
+ rivers: {
46
+ "river-1": {
47
+ plugin_type: "river",
48
+ },
49
+ },
50
+ contentTypes: {
51
+ "content-type-1": {
52
+ screen_id: "river-1",
53
+ },
54
+ "content-type-2": {
55
+ screen_id: "river-2", // river-2 does not exist
56
+ },
57
+ },
58
+ };
59
+
60
+ const result = mapContentTypesToRivers(state);
61
+
62
+ expect(result).toEqual({
63
+ "content-type-1": {
64
+ screenType: "river",
65
+ screen_id: "river-1",
66
+ },
67
+ });
68
+
69
+ // result is not null, but may be undefined for missing keys
70
+ expect(result && result["content-type-2"]).toBeUndefined();
71
+ });
72
+
73
+ it("should use 'type' if 'plugin_type' is not present in river", () => {
74
+ const state = {
75
+ rivers: {
76
+ "river-1": {
77
+ type: "custom-type",
78
+ },
79
+ },
80
+ contentTypes: {
81
+ "content-type-1": {
82
+ screen_id: "river-1",
83
+ },
84
+ },
85
+ };
86
+
87
+ const result = mapContentTypesToRivers(state);
88
+
89
+ expect(result).toEqual({
90
+ "content-type-1": {
91
+ screenType: "custom-type",
92
+ screen_id: "river-1",
93
+ },
94
+ });
95
+ });
96
+
97
+ it("should skip content types if neither plugin_type nor type is present in river", () => {
98
+ const state = {
99
+ rivers: {
100
+ "river-1": {
101
+ // no plugin_type or type
102
+ },
103
+ },
104
+ contentTypes: {
105
+ "content-type-1": {
106
+ screen_id: "river-1",
107
+ },
108
+ },
109
+ };
110
+
111
+ const result = mapContentTypesToRivers(state);
112
+
113
+ expect(result).toEqual({});
114
+ });
115
+
116
+ it("should handle empty contentTypes object", () => {
117
+ const state = {
118
+ rivers: {
119
+ "river-1": {
120
+ plugin_type: "river",
121
+ },
122
+ },
123
+ contentTypes: {},
124
+ };
125
+
126
+ const result = mapContentTypesToRivers(state);
127
+
128
+ expect(result).toEqual({});
129
+ });
130
+ });
@@ -13,6 +13,7 @@ import {
13
13
  isPlayable,
14
14
  isV2River,
15
15
  } from "./itemTypeMatchers";
16
+ import { RootState } from "@applicaster/zapp-react-native-redux/store";
16
17
 
17
18
  type PathAttribute = {
18
19
  screenType: string;
@@ -377,10 +378,11 @@ export const usesVideoModal = (
377
378
  return targetScreenConfiguration?.styles?.use_video_modal;
378
379
  };
379
380
 
380
- export const mapContentTypesToRivers = ({
381
- rivers,
382
- contentTypes,
383
- }): ZappContentTypesMapped | null => {
381
+ export const mapContentTypesToRivers = (
382
+ state: Partial<RootState>
383
+ ): ZappContentTypesMapped | null => {
384
+ const { rivers, contentTypes } = state;
385
+
384
386
  if (!contentTypes) {
385
387
  return null;
386
388
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "14.0.0-alpha.4517121861",
3
+ "version": "14.0.0-alpha.4596155133",
4
4
  "description": "Applicaster Zapp React Native utilities package",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "homepage": "https://github.com/applicaster/quickbrick#readme",
29
29
  "dependencies": {
30
- "@applicaster/applicaster-types": "14.0.0-alpha.4517121861",
30
+ "@applicaster/applicaster-types": "14.0.0-alpha.4596155133",
31
31
  "buffer": "^5.2.1",
32
32
  "camelize": "^1.0.0",
33
33
  "dayjs": "^1.11.10",
@@ -38,7 +38,6 @@
38
38
  "peerDependencies": {
39
39
  "@applicaster/zapp-pipes-v2-client": "*",
40
40
  "@react-native-community/netinfo": "*",
41
- "immer": "*",
42
41
  "react": "*",
43
42
  "react-native": "*",
44
43
  "uglify-js": "*",
@@ -5,6 +5,7 @@ import { isFilledArray } from "@applicaster/zapp-react-native-utils/arrayUtils";
5
5
  import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
6
6
 
7
7
  import { getBoolFromConfigValue } from "../configurationUtils";
8
+ import { Dimensions } from "react-native";
8
9
 
9
10
  export { getPlayerActionButtons } from "./getPlayerActionButtons";
10
11
 
@@ -97,3 +98,53 @@ export const isAudioItem = (item: Option<ZappEntry>) => {
97
98
  export const isInlineTV = (screenData) => {
98
99
  return isTV() && isFilledArray(screenData?.ui_components);
99
100
  };
101
+
102
+ const isPercentage = (value: string | number): boolean => {
103
+ if (typeof value === "string") {
104
+ return value.includes("%");
105
+ }
106
+
107
+ return false;
108
+ };
109
+
110
+ const getPercentageOf = (percent: string, value: number) => {
111
+ const percentageValue = parseFloat(percent.replace("%", ""));
112
+
113
+ if (isNaN(percentageValue)) {
114
+ return value;
115
+ }
116
+
117
+ return (value * percentageValue) / 100;
118
+ };
119
+
120
+ type DimensionsT = {
121
+ width: number | string;
122
+ height: number | string | undefined;
123
+ aspectRatio?: number;
124
+ };
125
+
126
+ export const getTabletWidth = (
127
+ tablet_landscape_sidebar_width,
128
+ dimensions: DimensionsT
129
+ ) => {
130
+ const { width: SCREEN_WIDTH } = Dimensions.get("screen");
131
+
132
+ const { width } = dimensions;
133
+ let widthValue = Number(width);
134
+
135
+ if (isPercentage(width)) {
136
+ widthValue = getPercentageOf(width.toString(), SCREEN_WIDTH);
137
+ }
138
+
139
+ const sidebarWidth = Number(tablet_landscape_sidebar_width?.replace("%", ""));
140
+
141
+ if (tablet_landscape_sidebar_width?.includes("%")) {
142
+ return widthValue * (1 - sidebarWidth / 100);
143
+ }
144
+
145
+ if (Number.isNaN(sidebarWidth)) {
146
+ return widthValue * 0.65;
147
+ }
148
+
149
+ return widthValue - sidebarWidth;
150
+ };
@@ -1,27 +1,31 @@
1
1
  import React from "react";
2
2
 
3
- import { act, renderHook } from "@testing-library/react-hooks";
3
+ import { renderHook } from "@testing-library/react-hooks";
4
+ import { act, waitFor } from "@testing-library/react-native";
4
5
  import { Provider } from "react-redux";
5
6
  import configureStore from "redux-mock-store";
7
+ import { useTrackedView } from "../useTrackedView";
6
8
 
7
9
  const mockUpdateComponentsPositions = jest.fn();
8
10
 
9
11
  jest.mock(
10
12
  "@applicaster/zapp-react-native-ui-components/Contexts/ScreenTrackedViewPositionsContext",
11
13
  () => ({
12
- useScreenTrackedViewPositionsContext: jest.fn().mockReturnValue({
14
+ useScreenTrackedViewPositionsContext: jest.fn(() => ({
13
15
  updateComponentsPositions: mockUpdateComponentsPositions,
14
16
  value: {
15
17
  "123": { componentId: "123", centerX: 0.4, centerY: 0.5 },
16
18
  "124": { componentId: "124", centerX: 0.2, centerY: 0.3 },
17
19
  },
18
- }),
20
+ })),
19
21
  })
20
22
  );
21
23
 
22
- jest.useFakeTimers({ legacyFakeTimers: true });
24
+ jest.useFakeTimers();
23
25
 
24
- jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation");
26
+ jest.mock(
27
+ "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation"
28
+ );
25
29
 
26
30
  const mockStore = configureStore();
27
31
 
@@ -32,10 +36,8 @@ const Wrapper = ({ children }: { children: React.ReactChild }) => (
32
36
  <Provider store={store}>{children}</Provider>
33
37
  );
34
38
 
35
- const { useTrackedView } = require("../useTrackedView");
36
-
37
39
  describe("useTrackCurrentAutoScrollingElement", () => {
38
- it("should update position for selected component - onViewportEnter", () => {
40
+ it("should update position for selected component - onViewportEnter", async () => {
39
41
  const { result } = renderHook(() => useTrackedView("123"), {
40
42
  wrapper: Wrapper,
41
43
  });
@@ -46,14 +48,13 @@ describe("useTrackCurrentAutoScrollingElement", () => {
46
48
  rect: { left: 1, right: 1, top: 1, bottom: 1 },
47
49
  };
48
50
 
49
- act(async () => {
50
- await result.current.onPositionUpdated(mockRect);
51
+ act(() => {
52
+ result.current.onPositionUpdated(mockRect);
51
53
  });
52
54
 
53
- // Fast-forward until all timers have been executed
54
- jest.runAllTimers();
55
-
56
- expect(result.current.inViewPort).toBe(true);
55
+ await waitFor(() => {
56
+ expect(result.current.inViewPort).toBe(true);
57
+ });
57
58
 
58
59
  expect(mockUpdateComponentsPositions).toHaveBeenCalledWith(
59
60
  "123",
@@ -16,7 +16,8 @@ import { ActionExecutorContext } from "@applicaster/zapp-react-native-utils/acti
16
16
  import { isFunction, noop } from "../../functionUtils";
17
17
  import { useSendAnalyticsOnPress } from "../analytics";
18
18
  import { logOnPress, warnEmptyContentType } from "./helpers";
19
- import { useCurrentScreenData } from "../screen";
19
+ import { useCurrentScreenData, useScreenContext } from "../screen";
20
+ import { useScreenStateStore } from "../navigation/useScreenStateStore";
20
21
 
21
22
  /**
22
23
  * If onCellTap is defined execute the function and
@@ -42,10 +43,12 @@ export const useCellClick = ({
42
43
  }: Props): onPressReturnFn => {
43
44
  const { push, currentRoute } = useNavigation();
44
45
  const { pathname } = useRoute();
46
+ const screenStateStore = useScreenStateStore();
45
47
 
46
48
  const onCellTap: Option<Function> = React.useContext(CellTapContext);
47
49
  const actionExecutor = React.useContext(ActionExecutorContext);
48
50
  const screenData = useCurrentScreenData();
51
+ const screenState = useScreenContext()?.options;
49
52
 
50
53
  const cellSelectable = toBooleanWithDefaultTrue(
51
54
  component?.rules?.component_cells_selectable
@@ -83,6 +86,9 @@ export const useCellClick = ({
83
86
  await actionExecutor?.handleEntryActions(selectedItem, {
84
87
  component,
85
88
  screenData,
89
+ screenState,
90
+ screenRoute: pathname,
91
+ screenStateStore,
86
92
  });
87
93
  }
88
94
 
@@ -117,6 +123,7 @@ export const useCellClick = ({
117
123
  push,
118
124
  sendAnalyticsOnPress,
119
125
  screenData,
126
+ screenState,
120
127
  ]
121
128
  );
122
129
 
@@ -1,8 +1,7 @@
1
1
  import { renderHook } from "@testing-library/react-hooks";
2
- import * as reduxMockStore from "redux-mock-store";
3
- import thunk from "redux-thunk";
4
- import React from "react";
5
- import * as ReactRedux from "react-redux";
2
+ import { allFeedsIsReady, useBatchLoading } from "../useBatchLoading";
3
+ import { WrappedWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
4
+ import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
6
5
 
7
6
  jest.mock("../../navigation");
8
7
 
@@ -13,17 +12,18 @@ jest.mock(
13
12
  })
14
13
  );
15
14
 
16
- const useBatchLoading = require("../useBatchLoading").useBatchLoading;
17
- const allFeedsIsReady = require("../useBatchLoading").allFeedsIsReady;
18
-
19
- const mockStore = reduxMockStore.default([thunk]);
20
-
21
- const wrapper: React.FC<any> = ({ children, store }) => (
22
- <ReactRedux.Provider store={store}>{children}</ReactRedux.Provider>
23
- );
15
+ const wrapper = WrappedWithProviders;
24
16
 
25
17
  describe("useBatchLoading", () => {
26
- const useDispatchSpy = jest.spyOn(ReactRedux, "useDispatch");
18
+ const data = [
19
+ { data: { source: "url1" }, component_type: "any" },
20
+ { data: { source: "url2" }, component_type: "any" },
21
+ { data: { source: "url3" }, component_type: "any" },
22
+ { data: { source: "url4" }, component_type: "any" },
23
+ { data: { source: "url5" }, component_type: "any" },
24
+ { data: { source: "url6" }, component_type: "any" },
25
+ // ... more items
26
+ ];
27
27
 
28
28
  beforeAll(() => {
29
29
  jest.useFakeTimers();
@@ -34,7 +34,7 @@ describe("useBatchLoading", () => {
34
34
  });
35
35
 
36
36
  it("loadPipesData start loading not started requests", () => {
37
- const store = mockStore({
37
+ const store = {
38
38
  zappPipes: {
39
39
  url1: {
40
40
  loading: true,
@@ -53,29 +53,17 @@ describe("useBatchLoading", () => {
53
53
  },
54
54
  },
55
55
  test: "true",
56
- });
57
-
58
- useDispatchSpy.mockReturnValue(store.dispatch);
56
+ };
59
57
 
60
58
  const initialBatchSize = 3;
61
59
  const riverId = "123";
62
60
 
63
- const data = [
64
- { data: { source: "url1" } },
65
- { data: { source: "url2" } },
66
- { data: { source: "url3" } },
67
- { data: { source: "url4" } },
68
- { data: { source: "url5" } },
69
- { data: { source: "url6" } },
70
- // ... more items
71
- ];
72
-
73
61
  renderHook(() => useBatchLoading(data, { initialBatchSize, riverId }), {
74
62
  wrapper,
75
63
  initialProps: { store },
76
64
  });
77
65
 
78
- const actions = store.getActions();
66
+ const actions = (appStore.getStore() as any).getActions();
79
67
 
80
68
  expect(actions).toHaveLength(2);
81
69
 
@@ -91,7 +79,7 @@ describe("useBatchLoading", () => {
91
79
  });
92
80
 
93
81
  it("loadPipesData start loading new feed when 1 feed is done loading and 1 is in loading state", () => {
94
- const store = mockStore({
82
+ const store = {
95
83
  zappPipes: {
96
84
  url1: {
97
85
  loading: false,
@@ -110,31 +98,17 @@ describe("useBatchLoading", () => {
110
98
  },
111
99
  },
112
100
  test: "true",
113
- });
114
-
115
- useDispatchSpy.mockReturnValue(store.dispatch);
101
+ };
116
102
 
117
103
  const initialBatchSize = 3;
118
104
  const riverId = "123";
119
105
 
120
- const data = [
121
- { data: { source: "url1" } },
122
- { data: { source: "url2" } },
123
- { data: { source: "url3" } },
124
- { data: { source: "url4" } },
125
- { data: { source: "url5" } },
126
- { data: { source: "url6" } },
127
- // ... more items
128
- ];
129
-
130
- expect(useDispatchSpy).toBeCalledTimes(0);
131
-
132
106
  renderHook(() => useBatchLoading(data, { initialBatchSize, riverId }), {
133
107
  wrapper,
134
108
  initialProps: { store },
135
109
  });
136
110
 
137
- const actions = store.getActions();
111
+ const actions = (appStore.getStore() as any).getActions();
138
112
 
139
113
  expect(actions).toHaveLength(1);
140
114
 
@@ -145,38 +119,26 @@ describe("useBatchLoading", () => {
145
119
  });
146
120
 
147
121
  it("loadPipesData has been called when no data cached", () => {
148
- const store = mockStore({
122
+ const store = {
149
123
  zappPipes: {},
150
124
  test: "true",
151
- });
152
-
153
- useDispatchSpy.mockReturnValue(store.dispatch);
125
+ };
154
126
 
155
127
  const initialBatchSize = 3;
156
128
  const riverId = "123";
157
129
 
158
- const data = [
159
- { data: { source: "url1" } },
160
- { data: { source: "url2" } },
161
- { data: { source: "url3" } },
162
- { data: { source: "url4" } },
163
- { data: { source: "url5" } },
164
- { data: { source: "url6" } },
165
- // ... more items
166
- ];
167
-
168
130
  renderHook(() => useBatchLoading(data, { initialBatchSize, riverId }), {
169
131
  wrapper,
170
132
  initialProps: { store },
171
133
  });
172
134
 
173
- const actions = store.getActions();
135
+ const actions = (appStore.getStore() as any).getActions();
174
136
 
175
137
  expect(actions).toHaveLength(3);
176
138
  });
177
139
 
178
140
  it("initial batch ready when all initial items loaded", () => {
179
- const store = mockStore({
141
+ const store = {
180
142
  zappPipes: {
181
143
  url1: {
182
144
  loading: false,
@@ -194,19 +156,11 @@ describe("useBatchLoading", () => {
194
156
  data: {},
195
157
  },
196
158
  },
197
- });
198
-
199
- useDispatchSpy.mockReturnValue(store.dispatch);
159
+ };
200
160
 
201
161
  const initialBatchSize = 3;
202
162
  const riverId = "123";
203
163
 
204
- const data: Partial<ZappUIComponent>[] = [
205
- { data: { source: "url1" } },
206
- { data: { source: "url2" } },
207
- { data: { source: "url3" } },
208
- ];
209
-
210
164
  const { result } = renderHook(
211
165
  () => useBatchLoading(data, { initialBatchSize, riverId }),
212
166
  { wrapper, initialProps: { store } }
@@ -216,12 +170,10 @@ describe("useBatchLoading", () => {
216
170
  });
217
171
 
218
172
  it("gallery-qb: loadPipesData should be called only once for first component in the gallery", () => {
219
- const store = mockStore({
173
+ const store = {
220
174
  zappPipes: {},
221
175
  test: "true",
222
- });
223
-
224
- useDispatchSpy.mockReturnValue(store.dispatch);
176
+ };
225
177
 
226
178
  const initialBatchSize = 3;
227
179
  const riverId = "123";
@@ -231,11 +183,11 @@ describe("useBatchLoading", () => {
231
183
  component_type: "gallery-qb",
232
184
  ui_components: [{ data: { source: "url1" } }],
233
185
  },
234
- { data: { source: "url2" } },
235
- { data: { source: "url3" } },
236
- { data: { source: "url4" } },
237
- { data: { source: "url5" } },
238
- { data: { source: "url6" } },
186
+ { data: { source: "url2" }, component_type: "any" },
187
+ { data: { source: "url3" }, component_type: "any" },
188
+ { data: { source: "url4" }, component_type: "any" },
189
+ { data: { source: "url5" }, component_type: "any" },
190
+ { data: { source: "url6" }, component_type: "any" },
239
191
  // ... more items
240
192
  ];
241
193
 
@@ -244,13 +196,13 @@ describe("useBatchLoading", () => {
244
196
  initialProps: { store },
245
197
  });
246
198
 
247
- const actions = store.getActions();
199
+ const actions = (appStore.getStore() as any).getActions();
248
200
 
249
201
  expect(actions).toHaveLength(1);
250
202
  });
251
203
 
252
204
  it("gallery-qb: initial batch ready when all initial items loaded", () => {
253
- const store = mockStore({
205
+ const store = {
254
206
  zappPipes: {
255
207
  url1: {
256
208
  loading: false,
@@ -258,20 +210,19 @@ describe("useBatchLoading", () => {
258
210
  data: {},
259
211
  },
260
212
  },
261
- });
262
-
263
- useDispatchSpy.mockReturnValue(store.dispatch);
213
+ };
264
214
 
265
215
  const initialBatchSize = 3;
266
216
  const riverId = "123";
267
217
 
268
- const data: Partial<ZappUIComponent>[] = [
218
+ const data = [
269
219
  {
270
220
  component_type: "gallery-qb",
271
- ui_components: [{ data: { source: "url1" } }],
221
+ data: {},
222
+ ui_components: [{ data: { source: "url1" } }] as any,
272
223
  },
273
- { data: { source: "url2" } },
274
- { data: { source: "url3" } },
224
+ { data: { source: "url2" }, component_type: "any" },
225
+ { data: { source: "url3" }, component_type: "any" },
275
226
  ];
276
227
 
277
228
  const { result } = renderHook(
@@ -138,6 +138,11 @@ describe("useFeedLoader", () => {
138
138
  expect(loadPipesDataSpy).toBeCalledWith(feedUrl, {
139
139
  clearCache: true,
140
140
  riverId: undefined,
141
+ resolvers: {
142
+ screen: {
143
+ screenStateStore: undefined,
144
+ },
145
+ },
141
146
  });
142
147
 
143
148
  const store2 = mockStore({
@@ -179,6 +184,11 @@ describe("useFeedLoader", () => {
179
184
  expect(loadPipesDataSpy).toBeCalledWith(feedUrl, {
180
185
  clearCache: true,
181
186
  riverId: undefined,
187
+ resolvers: {
188
+ screen: {
189
+ screenStateStore: undefined,
190
+ },
191
+ },
182
192
  });
183
193
 
184
194
  const store2 = mockStore({
@@ -228,6 +238,11 @@ describe("useFeedLoader", () => {
228
238
  expect(loadPipesDataSpy).toBeCalledWith(feedUrl, {
229
239
  clearCache: true,
230
240
  silentRefresh: true,
241
+ resolvers: {
242
+ screen: {
243
+ screenStateStore: undefined,
244
+ },
245
+ },
231
246
  });
232
247
 
233
248
  loadPipesDataSpy.mockRestore();
@@ -267,6 +282,11 @@ describe("useFeedLoader", () => {
267
282
  expect(loadPipesDataSpy).toBeCalledWith(nextUrl, {
268
283
  parentFeed: feedUrlWithNext,
269
284
  silentRefresh: true,
285
+ resolvers: {
286
+ screen: {
287
+ screenStateStore: undefined,
288
+ },
289
+ },
270
290
  });
271
291
 
272
292
  loadPipesDataSpy.mockRestore();
@@ -1,8 +1,10 @@
1
1
  import { complement, compose, isNil, map, min, prop, take, uniq } from "ramda";
2
- import { useDispatch } from "react-redux";
3
2
  import * as React from "react";
4
- import { useZappPipesFeeds } from "@applicaster/zapp-react-native-redux/hooks";
5
- import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
3
+ import {
4
+ ZappPipes,
5
+ useAppDispatch,
6
+ useZappPipesFeed,
7
+ } from "@applicaster/zapp-react-native-redux";
6
8
  import { isNilOrEmpty } from "../../reactUtils/helpers";
7
9
  import { ZappPipesSearchContext } from "@applicaster/zapp-react-native-ui-components/Contexts";
8
10
  import {
@@ -63,7 +65,7 @@ export const useBatchLoading = (
63
65
  componentsToRender: { data?: ZappDataSource; component_type: string }[],
64
66
  options: Options
65
67
  ) => {
66
- const dispatch = useDispatch();
68
+ const dispatch = useAppDispatch();
67
69
  const { screen: screenContext, entry: entryContext } = useScreenContext();
68
70
  const [searchContext] = ZappPipesSearchContext.useZappPipesContext();
69
71
  const [hasEverBeenReady, setHasEverBeenReady] = React.useState(false);
@@ -118,7 +120,7 @@ export const useBatchLoading = (
118
120
  []
119
121
  );
120
122
 
121
- const feeds = useZappPipesFeeds(feedUrls);
123
+ const feeds = useZappPipesFeed(feedUrls);
122
124
 
123
125
  // dispatch loadPipesData for each feed that is not loaded
124
126
  const runBatchLoading = React.useCallback(() => {
@@ -139,7 +141,7 @@ export const useBatchLoading = (
139
141
  if (mappedFeedUrl) {
140
142
  // 4. load data
141
143
  return dispatch(
142
- loadPipesData(mappedFeedUrl, { riverId: options.riverId })
144
+ ZappPipes.loadPipesData(mappedFeedUrl, { riverId: options.riverId })
143
145
  );
144
146
  }
145
147
  }