@applicaster/zapp-react-native-utils 13.0.0-alpha.1909212433 → 13.0.0-alpha.1918049654

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 (109) hide show
  1. package/actionsExecutor/ActionExecutor.ts +16 -9
  2. package/actionsExecutor/ActionExecutorContext.tsx +74 -9
  3. package/alertUtils/alert.ts +148 -0
  4. package/alertUtils/index.ts +1 -148
  5. package/analyticsUtils/AnalyticPlayerListener.ts +18 -1
  6. package/analyticsUtils/__tests__/__snapshots__/analyticsManagerNoModule.test.js.snap +9 -9
  7. package/analyticsUtils/helpers/hooks.ts +1 -1
  8. package/appUtils/HooksManager/{Hook.js → Hook.ts} +35 -23
  9. package/appUtils/HooksManager/__tests__/__snapshots__/hook.test.js.snap +10 -8
  10. package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +693 -0
  11. package/appUtils/HooksManager/__tests__/hook.test.js +196 -184
  12. package/appUtils/HooksManager/__tests__/hooksManager.test.js +96 -99
  13. package/appUtils/HooksManager/{constants.js → constants.ts} +1 -1
  14. package/appUtils/HooksManager/{index.js → index.ts} +121 -112
  15. package/appUtils/HooksManager/types.ts +119 -0
  16. package/appUtils/RiverFocusManager/index.js +17 -12
  17. package/appUtils/accessibilityManager/index.ts +42 -1
  18. package/appUtils/contextKeysManager/contextResolver.ts +73 -0
  19. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +6 -6
  20. package/appUtils/focusManager/index.ts +90 -63
  21. package/appUtils/focusManager/treeDataStructure/Tree/index.js +25 -3
  22. package/appUtils/focusManager/treeDataStructure/Utils/index.js +1 -3
  23. package/appUtils/focusManager/utils/enums.ts +4 -0
  24. package/appUtils/focusManagerAux/utils/index.ts +4 -3
  25. package/appUtils/{index.js → index.ts} +1 -1
  26. package/appUtils/keyCodes/__tests__/__snapshots__/keyCodes.test.js.snap +2 -2
  27. package/appUtils/keyCodes/__tests__/keyCodes.test.js +4 -4
  28. package/appUtils/keyCodes/{index.js → index.ts} +2 -0
  29. package/appUtils/keyCodes/keys/index.ts +3 -0
  30. package/appUtils/keyCodes/{keys.android.js → keys/keyEventMapper.ts} +0 -19
  31. package/appUtils/keyCodes/keys/keys.android.ts +18 -0
  32. package/appUtils/keyCodes/keys/keys.ios.ts +25 -0
  33. package/appUtils/keyCodes/keys/keys.ts +15 -0
  34. package/appUtils/keyCodes/{keysByPlatform.js → keys/keysByPlatform.ts} +4 -0
  35. package/appUtils/keyCodes/keysByPlatform.ts +8 -0
  36. package/appUtils/keyInputHandler/KeyInputHandler.ts +68 -0
  37. package/appUtils/orientationHelper.ts +1 -1
  38. package/appUtils/platform/const.ts +14 -0
  39. package/appUtils/platform/platformUtils.ts +17 -15
  40. package/appUtils/playerManager/player.ts +17 -5
  41. package/appUtils/playerManager/playerNative.ts +3 -2
  42. package/appUtils/playerManager/usePlayerControllerSetup.tsx +3 -3
  43. package/arrayUtils/__tests__/__snapshots__/arrayUtils.test.ts.snap +4 -4
  44. package/domUtils/{cookieManager.js → cookieManager.ts} +1 -2
  45. package/functionUtils/__tests__/__snapshots__/functionUtils.test.js.snap +4 -4
  46. package/functionUtils/index.ts +15 -11
  47. package/idleUtils/__tests__/withTimeout$.test.ts +37 -0
  48. package/idleUtils/index.ts +1 -1
  49. package/idleUtils/withTimeout.ts +15 -2
  50. package/logger/const.ts +9 -67
  51. package/manifestUtils/__tests__/createConfig.test.js +18 -16
  52. package/modalState/index.ts +1 -5
  53. package/navigationUtils/__tests__/__snapshots__/navigationUtils.test.js.snap +7 -6
  54. package/navigationUtils/__tests__/itemTypes.test.js +2 -2
  55. package/navigationUtils/__tests__/navigationUtils.test.js +2 -2
  56. package/navigationUtils/index.ts +17 -6
  57. package/package.json +3 -2
  58. package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +1 -1
  59. package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +1 -1
  60. package/reactHooks/cell-click/__tests__/index.test.js +10 -2
  61. package/reactHooks/cell-click/index.ts +7 -1
  62. package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +4 -4
  63. package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +10 -11
  64. package/reactHooks/feed/useFeedLoader.tsx +14 -7
  65. package/reactHooks/feed/usePipesCacheReset.ts +5 -5
  66. package/reactHooks/flatList/__tests__/index.test.tsx +30 -21
  67. package/reactHooks/layout/__tests__/index.test.tsx +10 -10
  68. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.native.test.js +14 -28
  69. package/reactHooks/navigation/__tests__/index.test.tsx +0 -4
  70. package/reactHooks/navigation/index.ts +29 -218
  71. package/reactHooks/navigation/useGetBottomTabBarHeight.ts +12 -0
  72. package/reactHooks/navigation/useGetNavBarTopBorderWidth.ts +14 -0
  73. package/reactHooks/navigation/useGetTabBarHeight.ts +12 -0
  74. package/reactHooks/navigation/useIsScreenActive.ts +17 -0
  75. package/reactHooks/navigation/useNavigationPluginData.ts +15 -0
  76. package/reactHooks/navigation/useNavigationType.ts +15 -0
  77. package/reactHooks/navigation/usePathname.ts +4 -0
  78. package/reactHooks/navigation/useRoute.ts +100 -0
  79. package/reactHooks/navigation/useUniqueRouteSuffix.ts +41 -0
  80. package/reactHooks/player/TVSeekControlller/ISeekController.ts +32 -0
  81. package/reactHooks/player/TVSeekControlller/LongPressSeekController.ts +71 -0
  82. package/reactHooks/player/TVSeekControlller/TVSeekController.ts +258 -0
  83. package/reactHooks/player/TVSeekControlller/TapSeekController.ts +53 -0
  84. package/reactHooks/player/__tests__/{useAutoSeek.test.tsx → useAutoSeek._test.tsx} +2 -3
  85. package/reactHooks/player/const.ts +0 -4
  86. package/reactHooks/player/index.ts +0 -6
  87. package/reactUtils/__tests__/reactUtils.test.js +10 -28
  88. package/reactUtils/createContext/__tests__/__snapshots__/helpers.test.js.snap +19 -19
  89. package/reactUtils/createContext/__tests__/__snapshots__/index.test.js.snap +2 -2
  90. package/reactUtils/createContext/__tests__/__snapshots__/provider.test.js.snap +3 -3
  91. package/reactUtils/createContext/__tests__/helpers.test.js +8 -8
  92. package/reactUtils/index.ts +0 -14
  93. package/theme/__mocks__/index.ts +4 -0
  94. package/time/Timer.ts +1 -1
  95. package/types.ts +1 -0
  96. package/appUtils/keyCodes/keys.ios.js +0 -46
  97. package/manifestUtils/sharedConfiguration/screenPicker/__tests__/utils.test.js +0 -304
  98. package/manifestUtils/sharedConfiguration/screenPicker/stylesFields.js +0 -875
  99. package/manifestUtils/sharedConfiguration/screenPicker/utils.js +0 -130
  100. package/reactHooks/player/useAutoSeek.tsx +0 -87
  101. package/reactHooks/player/useSeek.tsx +0 -66
  102. package/reactHooks/player/useTapSeek.tsx +0 -58
  103. /package/appUtils/HooksManager/{logger.js → logger.ts} +0 -0
  104. /package/appUtils/{directionHelper.js → directionHelper.ts} +0 -0
  105. /package/appUtils/keyCodes/{androidTVKeys.js → androidTVKeys.ts} +0 -0
  106. /package/appUtils/keyCodes/{keys.web.js → keys/keys.web.ts} +0 -0
  107. /package/appUtils/{localizationsHelper.js → localizationsHelper.ts} +0 -0
  108. /package/domUtils/{logger.js → logger.ts} +0 -0
  109. /package/reactHooks/player/__tests__/{useTapSeek.test.ts → useTapSeek._test.ts} +0 -0
package/logger/const.ts CHANGED
@@ -1,6 +1,3 @@
1
- /* eslint-disable unused-imports/no-unused-vars */
2
- import * as R from "ramda";
3
-
4
1
  enum XRayLogLevel {
5
2
  verbose = 0,
6
3
  debug = 1,
@@ -11,51 +8,9 @@ enum XRayLogLevel {
11
8
  off = 100,
12
9
  }
13
10
 
14
- enum ToastLogLevel {
15
- off = "off",
16
- verbose = "verbose",
17
- debug = "debug",
18
- info = "info",
19
- warning = "warning",
20
- error = "error",
21
- }
22
-
23
- const toastLevelToLogLevel = (toastLogLevel: ToastLogLevel): XRayLogLevel => {
24
- if (R.isNil(toastLogLevel)) {
25
- return XRayLogLevel.off;
26
- }
27
-
28
- switch (toastLogLevel) {
29
- case ToastLogLevel.verbose:
30
- return XRayLogLevel.verbose;
31
- case ToastLogLevel.debug:
32
- return XRayLogLevel.debug;
33
- case ToastLogLevel.info:
34
- return XRayLogLevel.info;
35
- case ToastLogLevel.error:
36
- return XRayLogLevel.error;
37
- default:
38
- return XRayLogLevel.off;
39
- }
40
- };
41
-
42
- const PLUGIN_IDENTIFIER = "xray_logging_plugin";
43
-
44
- const wrapInObject = (obj, name) => {};
45
-
46
- const applyConditions = (wrappedObj) => {};
47
-
48
- const sanitizeEventPayload = () => {};
11
+ const wrapInObject = (_ctx: unknown, _key: string) => {};
49
12
 
50
- const __isRunningRepoTests = () => {};
51
-
52
- const isWeb = () => {};
53
-
54
- const isDOMApp = () => {};
55
-
56
- const isBrowser = () => {};
57
-
58
- const eventAllowed = () => {};
13
+ const applyConditions = (_fn: unknown) => {};
59
14
 
60
15
  /**
61
16
  * This is the mocked version of XRayLogger
@@ -90,34 +45,21 @@ export default class XRayLogger {
90
45
  );
91
46
  };
92
47
 
93
- log = (event: string | XRayEventData) => {
94
- const logEvent = typeof event === "string" ? { message: event } : event;
95
- };
48
+ log = (_event) => {};
96
49
 
97
- debug = (event: string | XRayEventData) => {
98
- const logEvent = typeof event === "string" ? { message: event } : event;
99
- };
50
+ debug = (_event) => {};
100
51
 
101
- info = (event: string | XRayEventData) => {
102
- const logEvent = typeof event === "string" ? { message: event } : event;
103
- };
52
+ info = (_event) => {};
104
53
 
105
- warning = (event: string | XRayEventData) => {
106
- const logEvent = typeof event === "string" ? { message: event } : event;
107
- };
54
+ warning = (_event) => {};
108
55
 
109
- warn = (event: string | XRayEventData) => {
56
+ warn = (_event) => {
110
57
  this.warning(event);
111
58
  };
112
59
 
113
- error = (event: Error | XRayEventData) => {
114
- const logEvent: XRayEventData =
115
- event instanceof Error
116
- ? { exception: event as Error, message: event.message }
117
- : (event as XRayEventData);
118
- };
60
+ error = (_event) => {};
119
61
 
120
- sendEvent = (event, eventData) => {};
62
+ sendEvent = (_event, _eventData) => {};
121
63
 
122
64
  // To be used by QuickBrick Hook events
123
65
  sendAudienceEvent = (event, eventData = null) => {
@@ -1,11 +1,9 @@
1
- import { createConfig } from "../createConfig";
2
-
3
- const styles = {
1
+ const mockStyles = {
4
2
  fields: [{ key: "field_1", initial_value: 1 }],
5
3
  label: "styles",
6
4
  };
7
5
 
8
- const stylesWithGroup = {
6
+ const mockStylesWithGroup = {
9
7
  fields: [
10
8
  {
11
9
  group: true,
@@ -15,26 +13,28 @@ const stylesWithGroup = {
15
13
  ],
16
14
  };
17
15
 
18
- const generators = {
19
- styles: jest.fn(() => ({ styles })),
16
+ const mockGenerators = {
17
+ styles: jest.fn(() => ({ styles: mockStyles })),
20
18
  stylesGroup: jest.fn(() => ({
21
- styles: stylesWithGroup,
19
+ styles: mockStylesWithGroup,
22
20
  })),
23
- customConfiguration: jest.fn(() => ({ custom_configuration: [styles] })),
21
+ customConfiguration: jest.fn(() => ({ custom_configuration: [mockStyles] })),
24
22
  customConfigurationGroup: jest.fn(() => ({
25
- custom_configuration: [stylesWithGroup],
23
+ custom_configuration: [mockStylesWithGroup],
26
24
  })),
27
25
  };
28
26
 
29
- jest.mock("../defaultManifestConfigurations", () => ({
27
+ jest.doMock("../defaultManifestConfigurations", () => ({
30
28
  defaultConfigurations: {
31
- styles: generators.styles,
32
- stylesGroup: generators.stylesGroup,
33
- customConfiguration: generators.customConfiguration,
34
- customConfigurationGroup: generators.customConfigurationGroup,
29
+ styles: mockGenerators.styles,
30
+ stylesGroup: mockGenerators.stylesGroup,
31
+ customConfiguration: mockGenerators.customConfiguration,
32
+ customConfigurationGroup: mockGenerators.customConfigurationGroup,
35
33
  },
36
34
  }));
37
35
 
36
+ const { createConfig } = require("../createConfig");
37
+
38
38
  describe("createConfig", () => {
39
39
  it("should return a function", () => {
40
40
  const currentResult = createConfig(jest.fn());
@@ -78,7 +78,9 @@ describe("createConfig", () => {
78
78
  extend: "styles",
79
79
  })(props);
80
80
 
81
- expect(generators.styles).toBeCalledWith(props);
81
+ console.log(mockGenerators.styles.mock.calls);
82
+
83
+ expect(mockGenerators.styles).toBeCalledWith(props);
82
84
  });
83
85
 
84
86
  it("should return base configuration if manifest is not provided", () => {
@@ -88,7 +90,7 @@ describe("createConfig", () => {
88
90
  extend: "styles",
89
91
  })({});
90
92
 
91
- expect(currentResult).toEqual({ styles });
93
+ expect(currentResult).toEqual({ styles: mockStyles });
92
94
  });
93
95
 
94
96
  describe("Data merging", () => {
@@ -31,11 +31,7 @@ export const useModalStore = create<ModalStore>((set) => ({
31
31
  set((state) => ({
32
32
  modalState: { ...state.modalState, ...newState },
33
33
  })),
34
- openModal: ({
35
- item,
36
- options = {},
37
- props = { screenData: {} },
38
- }: OpenModalArg) =>
34
+ openModal: ({ item, options = {}, props }: OpenModalArg) =>
39
35
  set({
40
36
  modalState: {
41
37
  visible: true,
@@ -1,19 +1,20 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`getNavigationProps returns the props otherwise 1`] = `
4
- Object {
5
- "assets": Object {
4
+ {
5
+ "assets": {
6
6
  "appLogo": "appLogo.png",
7
7
  },
8
+ "data": undefined,
8
9
  "home": false,
9
- "nav_items": Array [
10
- Object {
10
+ "nav_items": [
11
+ {
11
12
  "type": "label",
12
13
  },
13
14
  ],
14
- "rules": Object {},
15
+ "rules": {},
15
16
  "selected": "A1234",
16
- "styles": Object {
17
+ "styles": {
17
18
  "style": "foo",
18
19
  },
19
20
  "title": "testTitle",
@@ -61,8 +61,8 @@ describe("getTypeMatcher", () => {
61
61
 
62
62
  describe("isItemOfType", () => {
63
63
  it("is a curried function", () => {
64
- expect(itemIsOfType(river, SCREEN_TYPES.RIVER)).toBeBoolean();
65
- expect(itemIsOfType(river)).toBeFunction();
64
+ expect(itemIsOfType(river, SCREEN_TYPES.RIVER)).toBeTruthy();
65
+ expect(itemIsOfType(river)).toBeInstanceOf(Function);
66
66
  });
67
67
 
68
68
  it("returns true if the item is of the given type", () => {
@@ -243,7 +243,7 @@ describe("getTargetRoute", () => {
243
243
  it("returns a valid path when initial pathname is /", () => {
244
244
  const targetRoute = getTargetRoute(river, "/", { layoutVersion });
245
245
  expect(targetRoute).toEqual(`/river/${river.id}`);
246
- expect(targetRoute).not.toInclude("//");
246
+ expect(targetRoute).not.toContainEntry("//");
247
247
  });
248
248
  });
249
249
 
@@ -273,7 +273,7 @@ describe("getTargetRoute", () => {
273
273
  it("returns a valid path when initial pathname is /", () => {
274
274
  const targetRoute = getTargetRoute(river, "/", { layoutVersion });
275
275
  expect(targetRoute).toEqual(`/river/${river.id}`);
276
- expect(targetRoute).not.toInclude("//");
276
+ expect(targetRoute).not.toContainEntry("//");
277
277
  });
278
278
  });
279
279
  });
@@ -111,6 +111,7 @@ export function getNavigationProps({
111
111
  assets: ZappNavBarAssets;
112
112
  rules: ZappNavBarRules;
113
113
  nav_items: NavBarItem[];
114
+ data: MenuItemDataProperties;
114
115
  } | null {
115
116
  const { activeRiver } = navigator;
116
117
  const { navigations, id: selected, home } = activeRiver; // use useRiver hook instead
@@ -124,7 +125,7 @@ export function getNavigationProps({
124
125
  return null;
125
126
  }
126
127
 
127
- const { styles, assets, nav_items, rules } = navigation;
128
+ const { styles, assets, nav_items, rules, data } = navigation;
128
129
 
129
130
  return {
130
131
  selected,
@@ -134,6 +135,7 @@ export function getNavigationProps({
134
135
  assets: assets as ZappNavBarAssets,
135
136
  nav_items: nav_items as any as NavBarItem[],
136
137
  rules: rules as any as ZappNavBarRules,
138
+ data: data as MenuItemDataProperties,
137
139
  };
138
140
  }
139
141
 
@@ -324,7 +326,13 @@ export function getPathAttributes({
324
326
  * @param {object} rivers
325
327
  * @returns {object}
326
328
  */
327
- export function getRiverFromRoute({ route, rivers }) {
329
+ export function getRiverFromRoute({
330
+ route,
331
+ rivers,
332
+ }: {
333
+ route: string;
334
+ rivers: Record<string, ZappRiver>;
335
+ }) {
328
336
  if (!route) {
329
337
  return null;
330
338
  }
@@ -437,7 +445,7 @@ export const runZappHooksForEntry = async (
437
445
 
438
446
  let success;
439
447
  let payload;
440
- const rivers = appStore.get("rivers");
448
+ const rivers: Record<string, ZappRiver> = appStore.get("rivers");
441
449
  const plugins = appStore.get("plugins");
442
450
  const appData = appStore.get("appData");
443
451
 
@@ -492,13 +500,16 @@ export const runZappHooksForEntry = async (
492
500
  payload = _payload;
493
501
  };
494
502
 
495
- HooksManager(hooksOptions)
503
+ const hooksManager = HooksManager(hooksOptions);
504
+
505
+ hooksManager.subscriber
496
506
  .on(HOOKS_EVENTS.PRESENT_SCREEN_HOOK, handleHookPresent)
497
507
  .on(HOOKS_EVENTS.START_BACKGROUND_HOOK, handleBackgroundHook)
498
508
  .on(HOOKS_EVENTS.ERROR, onFinished(false))
499
509
  .on(HOOKS_EVENTS.CANCEL, onFinished(false))
500
- .on(HOOKS_EVENTS.COMPLETE, onFinished(true))
501
- .handleHooks(entry);
510
+ .on(HOOKS_EVENTS.COMPLETE, onFinished(true));
511
+
512
+ hooksManager.handleHooks(entry);
502
513
 
503
514
  // eslint-disable-next-line no-unmodified-loop-condition
504
515
  while (success === undefined) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "13.0.0-alpha.1909212433",
3
+ "version": "13.0.0-alpha.1918049654",
4
4
  "description": "Applicaster Zapp React Native utilities package",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "homepage": "https://github.com/applicaster/quickbrick#readme",
30
30
  "dependencies": {
31
- "@applicaster/applicaster-types": "13.0.0-alpha.1909212433",
31
+ "@applicaster/applicaster-types": "13.0.0-alpha.1918049654",
32
32
  "buffer": "^5.2.1",
33
33
  "camelize": "^1.0.0",
34
34
  "create-react-context": "^0.2.3",
@@ -44,6 +44,7 @@
44
44
  "immer": "*",
45
45
  "react": "17.0.2",
46
46
  "react-native": "0.68.6",
47
+ "uglify-js": "*",
47
48
  "validate-color": "*",
48
49
  "zustand": "*"
49
50
  },
@@ -14,7 +14,7 @@ jest.mock(
14
14
 
15
15
  jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation");
16
16
 
17
- jest.useFakeTimers();
17
+ jest.useFakeTimers({ legacyFakeTimers: true });
18
18
 
19
19
  const {
20
20
  useTrackCurrentAutoScrollingElement,
@@ -19,7 +19,7 @@ jest.mock(
19
19
  })
20
20
  );
21
21
 
22
- jest.useFakeTimers();
22
+ jest.useFakeTimers({ legacyFakeTimers: true });
23
23
 
24
24
  jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation");
25
25
 
@@ -5,14 +5,14 @@ import { ActionExecutorContext } from "@applicaster/zapp-react-native-utils/acti
5
5
 
6
6
  import { waitFor } from "@testing-library/react-native";
7
7
 
8
- const navigator = {
8
+ const mockNavigator = {
9
9
  getPathname: () => "pathnameMock",
10
10
  push: jest.fn(),
11
11
  data: {},
12
12
  };
13
13
 
14
14
  jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
15
- useNavigation: () => navigator,
15
+ useNavigation: () => mockNavigator,
16
16
  useRoute: () => ({ pathname: "pathnameMock" }),
17
17
  useProfilerLogging: () => {
18
18
  return jest.fn();
@@ -25,7 +25,15 @@ jest.mock("@applicaster/zapp-react-native-utils/analyticsUtils/", () => ({
25
25
  }),
26
26
  }));
27
27
 
28
+ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/screen", () => ({
29
+ useTargetScreenData: jest.fn(() => ({})),
30
+ useCurrentScreenData: jest.fn(() => ({})),
31
+ }));
32
+
28
33
  jest.mock("@applicaster/zapp-react-native-ui-components/Contexts", () => ({
34
+ ...jest.requireActual(
35
+ "@applicaster/zapp-react-native-ui-components/Contexts"
36
+ ),
29
37
  ZappPipesEntryContext: {
30
38
  useZappPipesContext: jest.fn(() => [undefined, jest.fn()]),
31
39
  },
@@ -16,6 +16,7 @@ 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
20
 
20
21
  /**
21
22
  * If onCellTap is defined execute the function and
@@ -44,6 +45,7 @@ export const useCellClick = ({
44
45
 
45
46
  const onCellTap: Option<Function> = React.useContext(CellTapContext);
46
47
  const actionExecutor = React.useContext(ActionExecutorContext);
48
+ const screenData = useCurrentScreenData();
47
49
 
48
50
  const cellSelectable = toBooleanWithDefaultTrue(
49
51
  component?.rules?.component_cells_selectable
@@ -78,7 +80,10 @@ export const useCellClick = ({
78
80
  logOnPress(selectedItem, pathname, component, onCellTap);
79
81
 
80
82
  if (selectedItem) {
81
- await actionExecutor?.handleEntryActions(selectedItem);
83
+ await actionExecutor?.handleEntryActions(selectedItem, {
84
+ component,
85
+ screenData,
86
+ });
82
87
  }
83
88
 
84
89
  if (selectedItem?.type?.value === "action") {
@@ -111,6 +116,7 @@ export const useCellClick = ({
111
116
  pathname,
112
117
  push,
113
118
  sendAnalyticsOnPress,
119
+ screenData,
114
120
  ]
115
121
  );
116
122
 
@@ -7,12 +7,12 @@ const appData = {
7
7
  sdk_version: "2.0.0",
8
8
  };
9
9
 
10
- let INFLATED_URL;
10
+ const mockUseInflatedUrl = jest.fn();
11
11
 
12
12
  jest.mock(
13
13
  "@applicaster/zapp-react-native-utils/reactHooks/feed/useInflatedUrl",
14
14
  () => ({
15
- useInflatedUrl: () => INFLATED_URL,
15
+ useInflatedUrl: mockUseInflatedUrl,
16
16
  })
17
17
  );
18
18
 
@@ -20,7 +20,7 @@ const { useBuildPipesUrl } = require("../useBuildPipesUrl");
20
20
 
21
21
  describe("useBuildPipesUrl", () => {
22
22
  it("returns the proper url", async () => {
23
- INFLATED_URL = "http://foo.com/show/show-1";
23
+ mockUseInflatedUrl.mockReturnValue("http://foo.com/show/show-1");
24
24
  const url = "http://foo.com/show/{{showId}}";
25
25
 
26
26
  const mapping = {
@@ -65,7 +65,7 @@ describe("useBuildPipesUrl", () => {
65
65
  });
66
66
 
67
67
  it("returns empty object if url is not in endpoints", async () => {
68
- INFLATED_URL = "http://foobar.com/show-1";
68
+ mockUseInflatedUrl.mockReturnValue("http://foobar.com/show-1");
69
69
  const url = "http://foobar.com/{{showId}}";
70
70
 
71
71
  const mapping = {
@@ -6,42 +6,41 @@ import { Provider } from "react-redux";
6
6
  import * as React from "react";
7
7
  import configureStore from "redux-mock-store";
8
8
  import thunk from "redux-thunk";
9
- import * as navigationHooks from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
9
+ import * as useRouteHook from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useRoute";
10
10
  import * as useNavigationHooks from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
11
+ import { useFeedLoader } from "../useFeedLoader";
11
12
 
12
13
  const mockStore = configureStore([thunk]);
13
14
 
14
- jest.useFakeTimers();
15
+ jest.useFakeTimers({ legacyFakeTimers: true });
15
16
 
16
- const logger = {
17
+ const mockLogger = {
17
18
  warning: jest.fn(),
18
19
  log: jest.fn(),
19
20
  info: jest.fn(),
20
21
  };
21
22
 
22
- const navigator = {
23
+ const mockNavigator: any = {
23
24
  currentRoute: "/river/A1234",
24
25
  getStack: jest.fn(() => []),
25
26
  };
26
27
 
27
- const routeData = {
28
+ const mockRouteData: any = {
28
29
  screenData: {},
29
30
  pathname: "/river/A1234",
30
31
  };
31
32
 
32
- jest.mock("../../logger", () => ({
33
+ jest.doMock("../../logger", () => ({
33
34
  reactHooksLogger: {
34
- addSubsystem: jest.fn(() => logger),
35
+ addSubsystem: jest.fn(() => mockLogger),
35
36
  },
36
37
  }));
37
38
 
38
39
  jest
39
40
  .spyOn(useNavigationHooks, "useNavigation")
40
- .mockImplementation(() => navigator);
41
+ .mockImplementation(() => mockNavigator);
41
42
 
42
- jest.spyOn(navigationHooks, "useRoute").mockImplementation(() => routeData);
43
-
44
- const { useFeedLoader } = require("../useFeedLoader");
43
+ jest.spyOn(useRouteHook, "useRoute").mockImplementation(() => mockRouteData);
45
44
 
46
45
  const mockZappPipesData = {
47
46
  data: {
@@ -20,6 +20,7 @@ type Props = {
20
20
  silentRefresh?: boolean;
21
21
  method?: "get" | "post";
22
22
  bodyParams?: Record<string, unknown>;
23
+ skipLoading?: boolean;
23
24
  };
24
25
  };
25
26
 
@@ -87,13 +88,13 @@ export const useFeedLoader = ({
87
88
  );
88
89
  }
89
90
  }
90
- }, [callableFeedUrl, currentFeed?.data]);
91
+ }, [callableFeedUrl, currentFeed?.data?.next]);
91
92
 
92
93
  useEffect(() => {
93
94
  if (
94
95
  shouldDispatchData(callableFeedUrl, currentFeed, pipesOptions.clearCache)
95
96
  ) {
96
- if (callableFeedUrl) {
97
+ if (callableFeedUrl && !pipesOptions.skipLoading) {
97
98
  dispatch(
98
99
  loadPipesData(callableFeedUrl, {
99
100
  ...pipesOptions,
@@ -101,26 +102,33 @@ export const useFeedLoader = ({
101
102
  riverId,
102
103
  })
103
104
  );
104
- } else {
105
+ } else if (!callableFeedUrl) {
105
106
  logger.info({
106
107
  message:
107
108
  "Feed is not defined or not inflated, skipping loading. \nMake sure you have correct feedUrl and mapping.",
108
109
  jsOnly: true,
109
110
  });
111
+ } else {
112
+ logger.info({
113
+ message:
114
+ "Loading skipped as per pipesOptions.skipLoading configuration.",
115
+ data: { url: callableFeedUrl },
116
+ jsOnly: true,
117
+ });
110
118
  }
111
119
  } else {
112
120
  logger.info({
113
121
  message:
114
- "Feed already exist, skipping loading. \nCall reloadData() if you want to refresh data.",
122
+ "Feed already exists, skipping loading. \nCall reloadData() if you want to refresh data.",
115
123
  data: { url: callableFeedUrl },
116
124
  jsOnly: true,
117
125
  });
118
126
  }
119
127
  }, []);
120
128
 
121
- // Reload feed when feedUrl changes
129
+ // Reload feed when feedUrl changes, unless skipLoading is true
122
130
  useEffect(() => {
123
- if (!isInitialRender && callableFeedUrl) {
131
+ if (!isInitialRender && callableFeedUrl && !pipesOptions.skipLoading) {
124
132
  dispatch(loadPipesData(callableFeedUrl, { ...pipesOptions, riverId }));
125
133
  }
126
134
  }, [callableFeedUrl]);
@@ -156,7 +164,6 @@ export const useFeedLoader = ({
156
164
  currentFeed?.data,
157
165
  currentFeed?.error,
158
166
  currentFeed?.loading,
159
-
160
167
  reloadData,
161
168
  loadNext,
162
169
  ]);
@@ -1,12 +1,12 @@
1
1
  import React from "react";
2
2
  import { useDispatch } from "react-redux";
3
- import { useRoute } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
4
- import {
5
- getDatasourceUrl,
6
- usePipesContexts,
7
- } from "@applicaster/zapp-react-native-ui-components/Decorators/RiverFeedLoader/utils";
3
+
4
+ import { getDatasourceUrl } from "@applicaster/zapp-react-native-ui-components/Decorators/RiverFeedLoader/utils/getDatasourceUrl";
5
+ import { usePipesContexts } from "@applicaster/zapp-react-native-ui-components/Decorators/RiverFeedLoader/utils/usePipesContexts";
8
6
  import { clearPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
9
7
 
8
+ import { useRoute } from "../navigation/useRoute";
9
+
10
10
  /**
11
11
  * reset river components cache when screen is unmounted
12
12
  * @param {string} riverId screen id