@applicaster/zapp-react-native-utils 13.0.0-rc.1 → 13.0.0-rc.100
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.
- package/README.md +0 -10
- package/actionsExecutor/ActionExecutor.ts +16 -9
- package/actionsExecutor/ActionExecutorContext.tsx +174 -11
- package/alertUtils/alert.ts +148 -0
- package/alertUtils/index.ts +1 -148
- package/analyticsUtils/AnalyticPlayerListener.ts +18 -1
- package/analyticsUtils/__tests__/__snapshots__/analyticsManagerNoModule.test.js.snap +9 -9
- package/analyticsUtils/currentScreenProperities.ts +6 -4
- package/analyticsUtils/helpers/hooks.ts +1 -1
- package/appUtils/HooksManager/{Hook.js → Hook.ts} +39 -23
- package/appUtils/HooksManager/__tests__/__snapshots__/hook.test.js.snap +10 -8
- package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +693 -0
- package/appUtils/HooksManager/__tests__/hook.test.js +196 -184
- package/appUtils/HooksManager/__tests__/hooksManager.test.js +96 -99
- package/appUtils/HooksManager/{constants.js → constants.ts} +1 -1
- package/appUtils/HooksManager/{index.js → index.ts} +124 -113
- package/appUtils/HooksManager/types.ts +119 -0
- package/appUtils/RiverFocusManager/index.js +17 -12
- package/appUtils/accessibilityManager/index.ts +42 -1
- package/appUtils/contextKeysManager/contextResolver.ts +66 -0
- package/appUtils/contextKeysManager/index.ts +2 -2
- package/appUtils/contextKeysManager/utils/index.ts +2 -1
- package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +8 -6
- package/appUtils/focusManager/index.ts +108 -69
- package/appUtils/focusManager/treeDataStructure/Tree/index.js +25 -3
- package/appUtils/focusManager/treeDataStructure/Utils/index.js +1 -3
- package/appUtils/focusManager/utils/enums.ts +4 -0
- package/appUtils/focusManagerAux/utils/index.ts +4 -3
- package/appUtils/{index.js → index.ts} +1 -1
- package/appUtils/keyCodes/__tests__/__snapshots__/keyCodes.test.js.snap +2 -2
- package/appUtils/keyCodes/__tests__/keyCodes.test.js +4 -4
- package/appUtils/keyCodes/{index.js → index.ts} +13 -7
- package/appUtils/keyCodes/keys/index.ts +3 -0
- package/appUtils/keyCodes/{keys.android.js → keys/keyEventMapper.ts} +0 -19
- package/appUtils/keyCodes/keys/keys.android.ts +18 -0
- package/appUtils/keyCodes/keys/keys.ios.ts +25 -0
- package/appUtils/keyCodes/keys/keys.ts +15 -0
- package/appUtils/keyCodes/{keysByPlatform.js → keys/keysByPlatform.ts} +4 -0
- package/appUtils/keyCodes/keysByPlatform.ts +8 -0
- package/appUtils/keyInputHandler/KeyInputHandler.ts +68 -0
- package/appUtils/{localizationsHelper.js → localizationsHelper.ts} +23 -0
- package/appUtils/orientationHelper.ts +11 -13
- package/appUtils/platform/const.ts +14 -0
- package/appUtils/platform/platformUtils.ts +47 -18
- package/appUtils/playerManager/index.ts +7 -3
- package/appUtils/playerManager/player.ts +42 -18
- package/appUtils/playerManager/playerFactory.ts +5 -4
- package/appUtils/playerManager/playerNative.ts +18 -2
- package/appUtils/playerManager/usePlayerControllerSetup.tsx +3 -3
- package/appUtils/playerManager/usePlayerTitleSummaryOverlay.tsx +7 -1
- package/arrayUtils/__tests__/__snapshots__/arrayUtils.test.ts.snap +4 -4
- package/componentsUtils/__tests__/isFirstComponentGallery.test.ts +33 -0
- package/componentsUtils/__tests__/isFirstComponentScreenPicker.test.ts +33 -0
- package/componentsUtils/__tests__/isGallery.test.ts +33 -0
- package/componentsUtils/__tests__/isScreenPicker.test.ts +33 -0
- package/componentsUtils/index.ts +32 -0
- package/dateUtils/index.ts +19 -0
- package/domUtils/{cookieManager.js → cookieManager.ts} +1 -2
- package/equalUtils/__tests__/isEqual/combination.test.ts +263 -0
- package/equalUtils/index.ts +49 -30
- package/focusManager/FocusManager.ts +14 -2
- package/focusManager/index.ts +23 -4
- package/functionUtils/__tests__/__snapshots__/functionUtils.test.js.snap +4 -4
- package/functionUtils/index.ts +61 -19
- package/idleUtils/__tests__/withTimeout$.test.ts +37 -0
- package/idleUtils/index.ts +1 -1
- package/idleUtils/withTimeout.ts +15 -2
- package/index.d.ts +0 -12
- package/localizationUtils/index.ts +5 -10
- package/logger/const.ts +9 -67
- package/manifestUtils/__tests__/createConfig.test.js +16 -16
- package/manifestUtils/defaultManifestConfigurations/player.js +14 -0
- package/manifestUtils/fonts/index.js +5 -6
- package/manifestUtils/sharedConfiguration/screenPicker/__tests__/utils.test.js +304 -0
- package/manifestUtils/sharedConfiguration/screenPicker/stylesFields.js +875 -0
- package/manifestUtils/sharedConfiguration/screenPicker/utils.js +130 -0
- package/modalState/__tests__/index.test.ts +51 -0
- package/modalState/index.ts +33 -7
- package/navigationUtils/__tests__/__snapshots__/navigationUtils.test.js.snap +7 -6
- package/navigationUtils/__tests__/itemTypes.test.js +2 -2
- package/navigationUtils/__tests__/navigationUtils.test.js +2 -2
- package/navigationUtils/index.ts +20 -9
- package/numberUtils/__tests__/toPositiveNumberWithDefault.test.ts +23 -3
- package/numberUtils/index.ts +11 -5
- package/package.json +5 -10
- package/playerUtils/configurationGenerator.ts +14 -0
- package/reactHooks/advertising/index.ts +5 -5
- package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +1 -1
- package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +6 -8
- package/reactHooks/autoscrolling/useTrackedView.ts +12 -1
- package/reactHooks/cell-click/__tests__/index.test.js +10 -2
- package/reactHooks/cell-click/index.ts +7 -1
- package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +4 -4
- package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +20 -13
- package/reactHooks/feed/useFeedLoader.tsx +28 -15
- package/reactHooks/feed/usePipesCacheReset.ts +5 -5
- package/reactHooks/flatList/__tests__/index.test.tsx +30 -21
- package/reactHooks/hookModal/hooks/useHookModalScreenData.ts +39 -0
- package/reactHooks/layout/__tests__/index.test.tsx +10 -10
- package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.native.test.js +14 -28
- package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.test.js +1 -1
- package/reactHooks/layout/useDimensions/useDimensions.ts +8 -0
- package/reactHooks/navigation/__mocks__/useNavigation.ts +3 -0
- package/reactHooks/navigation/__tests__/index.test.tsx +6 -21
- package/reactHooks/navigation/index.ts +41 -240
- package/reactHooks/navigation/useGetBottomTabBarHeight.ts +12 -0
- package/reactHooks/navigation/useGetNavBarTopBorderWidth.ts +14 -0
- package/reactHooks/navigation/useGetTabBarHeight.ts +10 -0
- package/reactHooks/navigation/useIsScreenActive.ts +17 -0
- package/reactHooks/navigation/useNavigationPluginData.ts +15 -0
- package/reactHooks/navigation/useNavigationType.ts +15 -0
- package/reactHooks/navigation/usePathname.ts +4 -0
- package/reactHooks/navigation/useProfilerLogging.ts +15 -0
- package/reactHooks/navigation/useRoute.ts +98 -0
- package/reactHooks/navigation/useUniqueRouteSuffix.ts +41 -0
- package/reactHooks/player/TVSeekControlller/ISeekController.ts +32 -0
- package/reactHooks/player/TVSeekControlller/LongPressSeekController.ts +71 -0
- package/reactHooks/player/TVSeekControlller/TVSeekController.ts +258 -0
- package/reactHooks/player/TVSeekControlller/TapSeekController.ts +53 -0
- package/reactHooks/player/__tests__/{useAutoSeek.test.tsx → useAutoSeek._test.tsx} +2 -3
- package/reactHooks/player/const.ts +0 -4
- package/reactHooks/player/index.ts +0 -6
- package/reactHooks/state/useRefWithInitialValue.ts +14 -0
- package/reactHooks/state/useStateFromSubscribe.ts +23 -0
- package/reactHooks/usePluginConfiguration.ts +1 -1
- package/reactHooks/useSubscriberFor.ts +4 -3
- package/reactHooks/utils/index.ts +13 -0
- package/reactUtils/__tests__/__snapshots__/reactUtilsHelpers.test.js.snap +16 -4
- package/reactUtils/__tests__/reactUtils.test.js +1 -37
- package/reactUtils/__tests__/reactUtilsHelpers.test.js +72 -71
- package/reactUtils/createContext/__tests__/__snapshots__/helpers.test.js.snap +13 -79
- package/reactUtils/createContext/__tests__/__snapshots__/{index.test.js.snap → index.test.ts.snap} +2 -2
- package/reactUtils/createContext/__tests__/__snapshots__/provider.test.js.snap +3 -28
- package/reactUtils/createContext/__tests__/__snapshots__/withConsumer.test.js.snap +3 -4
- package/reactUtils/createContext/__tests__/__snapshots__/withProvider.test.js.snap +7 -3
- package/reactUtils/createContext/__tests__/helpers.test.js +107 -121
- package/reactUtils/createContext/__tests__/{index.test.js → index.test.ts} +2 -2
- package/reactUtils/createContext/__tests__/provider.test.js +4 -6
- package/reactUtils/createContext/__tests__/withConsumer.test.js +12 -12
- package/reactUtils/createContext/__tests__/withProvider.test.js +4 -4
- package/reactUtils/createContext/helpers.ts +6 -1
- package/reactUtils/createContext/index.ts +11 -25
- package/reactUtils/index.ts +0 -25
- package/screenState/index.ts +24 -10
- package/services/js2native.ts +673 -0
- package/testUtils/index.tsx +0 -10
- package/theme/__mocks__/index.ts +4 -0
- package/theme/index.ts +1 -1
- package/time/BackgroundTimer.ts +55 -0
- package/time/Timer.ts +9 -6
- package/types.ts +1 -0
- package/utils/README.md +30 -0
- package/utils/chunk.ts +5 -0
- package/utils/index.ts +5 -0
- package/utils/times.ts +5 -0
- package/zappFrameworkUtils/localStorageHelper.ts +6 -0
- package/zappFrameworkUtils/loginPluginUtils.ts +6 -2
- package/zappFrameworkUtils/presentPluginOneTime.ts +2 -3
- package/zappFrameworkUtils/types.ts +11 -0
- package/appUtils/keyCodes/keys.ios.js +0 -46
- package/reactHooks/player/useAutoSeek.tsx +0 -87
- package/reactHooks/player/useSeek.tsx +0 -66
- package/reactHooks/player/useTapSeek.tsx +0 -58
- package/reactUtils/createContext/__tests__/index-no-react.test.js +0 -27
- /package/appUtils/HooksManager/{logger.js → logger.ts} +0 -0
- /package/appUtils/{directionHelper.js → directionHelper.ts} +0 -0
- /package/appUtils/keyCodes/{androidTVKeys.js → androidTVKeys.ts} +0 -0
- /package/appUtils/keyCodes/{keys.web.js → keys/keys.web.ts} +0 -0
- /package/domUtils/{logger.js → logger.ts} +0 -0
- /package/reactHooks/player/__tests__/{useTapSeek.test.ts → useTapSeek._test.ts} +0 -0
|
@@ -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
|
|
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: () =>
|
|
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
|
-
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
17
|
+
const mockLogger = {
|
|
17
18
|
warning: jest.fn(),
|
|
18
19
|
log: jest.fn(),
|
|
19
20
|
info: jest.fn(),
|
|
20
21
|
};
|
|
21
22
|
|
|
22
|
-
const
|
|
23
|
+
const mockNavigator: any = {
|
|
23
24
|
currentRoute: "/river/A1234",
|
|
24
25
|
getStack: jest.fn(() => []),
|
|
25
26
|
};
|
|
26
27
|
|
|
27
|
-
const
|
|
28
|
+
const mockRouteData: any = {
|
|
28
29
|
screenData: {},
|
|
29
30
|
pathname: "/river/A1234",
|
|
30
31
|
};
|
|
31
32
|
|
|
32
|
-
jest.
|
|
33
|
+
jest.doMock("../../logger", () => ({
|
|
33
34
|
reactHooksLogger: {
|
|
34
|
-
addSubsystem: jest.fn(() =>
|
|
35
|
+
addSubsystem: jest.fn(() => mockLogger),
|
|
35
36
|
},
|
|
36
37
|
}));
|
|
37
38
|
|
|
38
39
|
jest
|
|
39
40
|
.spyOn(useNavigationHooks, "useNavigation")
|
|
40
|
-
.mockImplementation(() =>
|
|
41
|
+
.mockImplementation(() => mockNavigator);
|
|
41
42
|
|
|
42
|
-
jest.spyOn(
|
|
43
|
-
|
|
44
|
-
const { useFeedLoader } = require("../useFeedLoader");
|
|
43
|
+
jest.spyOn(useRouteHook, "useRoute").mockImplementation(() => mockRouteData);
|
|
45
44
|
|
|
46
45
|
const mockZappPipesData = {
|
|
47
46
|
data: {
|
|
@@ -135,7 +134,11 @@ describe("useFeedLoader", () => {
|
|
|
135
134
|
);
|
|
136
135
|
|
|
137
136
|
expect(result.current.data).toBeNull();
|
|
138
|
-
|
|
137
|
+
|
|
138
|
+
expect(loadPipesDataSpy).toBeCalledWith(feedUrl, {
|
|
139
|
+
clearCache: true,
|
|
140
|
+
riverId: undefined,
|
|
141
|
+
});
|
|
139
142
|
|
|
140
143
|
const store2 = mockStore({
|
|
141
144
|
plugins: [],
|
|
@@ -172,7 +175,11 @@ describe("useFeedLoader", () => {
|
|
|
172
175
|
);
|
|
173
176
|
|
|
174
177
|
expect(result.current.data).toBeNull();
|
|
175
|
-
|
|
178
|
+
|
|
179
|
+
expect(loadPipesDataSpy).toBeCalledWith(feedUrl, {
|
|
180
|
+
clearCache: true,
|
|
181
|
+
riverId: undefined,
|
|
182
|
+
});
|
|
176
183
|
|
|
177
184
|
const store2 = mockStore({
|
|
178
185
|
plugins: [],
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import React, { useEffect } from "react";
|
|
2
|
-
import { path } from "ramda";
|
|
3
2
|
import { useDispatch } from "react-redux";
|
|
4
3
|
|
|
5
4
|
import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
|
|
6
5
|
import { useZappPipesFeed } from "@applicaster/zapp-react-native-redux/hooks";
|
|
7
6
|
|
|
8
7
|
import { reactHooksLogger } from "../logger";
|
|
9
|
-
import { useIsInitialRender } from "../utils";
|
|
8
|
+
import { shouldDispatchData, useIsInitialRender } from "../utils";
|
|
10
9
|
import { useInflatedUrl } from "./useInflatedUrl";
|
|
11
10
|
import { useRoute } from "../navigation";
|
|
12
11
|
|
|
@@ -21,6 +20,7 @@ type Props = {
|
|
|
21
20
|
silentRefresh?: boolean;
|
|
22
21
|
method?: "get" | "post";
|
|
23
22
|
bodyParams?: Record<string, unknown>;
|
|
23
|
+
skipLoading?: boolean;
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
26
|
|
|
@@ -56,9 +56,9 @@ export const useFeedLoader = ({
|
|
|
56
56
|
|
|
57
57
|
const currentFeed = useZappPipesFeed(callableFeedUrl);
|
|
58
58
|
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
const riverId =
|
|
60
|
+
(screenData as LegacyNavigationScreenData)?.targetScreen?.id ??
|
|
61
|
+
screenData?.id;
|
|
62
62
|
|
|
63
63
|
const reloadData = React.useCallback<ReloadDataFunction>(
|
|
64
64
|
(silentRefresh = true, callback) => {
|
|
@@ -90,33 +90,47 @@ export const useFeedLoader = ({
|
|
|
90
90
|
);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
}, [callableFeedUrl, currentFeed?.data]);
|
|
93
|
+
}, [callableFeedUrl, currentFeed?.data?.next]);
|
|
94
94
|
|
|
95
|
-
// If feed doesn't exist, load it
|
|
96
95
|
useEffect(() => {
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
if (
|
|
97
|
+
shouldDispatchData(callableFeedUrl, currentFeed, pipesOptions.clearCache)
|
|
98
|
+
) {
|
|
99
|
+
if (callableFeedUrl && !pipesOptions.skipLoading) {
|
|
100
|
+
dispatch(
|
|
101
|
+
loadPipesData(callableFeedUrl, {
|
|
102
|
+
...pipesOptions,
|
|
103
|
+
clearCache: true,
|
|
104
|
+
riverId,
|
|
105
|
+
})
|
|
106
|
+
);
|
|
107
|
+
} else if (!callableFeedUrl) {
|
|
101
108
|
logger.info({
|
|
102
109
|
message:
|
|
103
110
|
"Feed is not defined or not inflated, skipping loading. \nMake sure you have correct feedUrl and mapping.",
|
|
104
111
|
jsOnly: true,
|
|
105
112
|
});
|
|
113
|
+
} else {
|
|
114
|
+
logger.info({
|
|
115
|
+
message:
|
|
116
|
+
"Loading skipped as per pipesOptions.skipLoading configuration.",
|
|
117
|
+
data: { url: callableFeedUrl },
|
|
118
|
+
jsOnly: true,
|
|
119
|
+
});
|
|
106
120
|
}
|
|
107
121
|
} else {
|
|
108
122
|
logger.info({
|
|
109
123
|
message:
|
|
110
|
-
"Feed already
|
|
124
|
+
"Feed already exists, skipping loading. \nCall reloadData() if you want to refresh data.",
|
|
111
125
|
data: { url: callableFeedUrl },
|
|
112
126
|
jsOnly: true,
|
|
113
127
|
});
|
|
114
128
|
}
|
|
115
129
|
}, []);
|
|
116
130
|
|
|
117
|
-
// Reload feed when feedUrl changes
|
|
131
|
+
// Reload feed when feedUrl changes, unless skipLoading is true
|
|
118
132
|
useEffect(() => {
|
|
119
|
-
if (!isInitialRender && callableFeedUrl) {
|
|
133
|
+
if (!isInitialRender && callableFeedUrl && !pipesOptions.skipLoading) {
|
|
120
134
|
dispatch(loadPipesData(callableFeedUrl, { ...pipesOptions, riverId }));
|
|
121
135
|
}
|
|
122
136
|
}, [callableFeedUrl]);
|
|
@@ -152,7 +166,6 @@ export const useFeedLoader = ({
|
|
|
152
166
|
currentFeed?.data,
|
|
153
167
|
currentFeed?.error,
|
|
154
168
|
currentFeed?.loading,
|
|
155
|
-
|
|
156
169
|
reloadData,
|
|
157
170
|
loadNext,
|
|
158
171
|
]);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { useDispatch } from "react-redux";
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
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
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { renderHook, act } from "@testing-library/react-
|
|
3
|
-
import { render } from "@testing-library/react-native";
|
|
2
|
+
import { renderHook, render, act } from "@testing-library/react-native";
|
|
4
3
|
import { View } from "react-native";
|
|
5
4
|
|
|
6
5
|
import { useSequentialLoader, useSequentialRenderItem } from "..";
|
|
@@ -66,26 +65,28 @@ describe("flatList hooks", () => {
|
|
|
66
65
|
|
|
67
66
|
expect(result.current.allLoaded).toBe(false);
|
|
68
67
|
|
|
69
|
-
|
|
70
|
-
(
|
|
71
|
-
onLoadFinished
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
act(() => {
|
|
69
|
+
result.current.renderItem(
|
|
70
|
+
({ onLoadFinished }) => {
|
|
71
|
+
onLoadFinished();
|
|
72
|
+
},
|
|
73
|
+
{ index: 1 }
|
|
74
|
+
);
|
|
75
|
+
});
|
|
75
76
|
|
|
76
77
|
expect(result.current.allLoaded).toBe(true);
|
|
77
78
|
});
|
|
78
79
|
});
|
|
79
80
|
|
|
80
81
|
describe("Rendering wrapper", () => {
|
|
81
|
-
it("wraps the elements in the View with display: none style", () => {
|
|
82
|
+
it("wraps the elements in the View with display: none style", async () => {
|
|
82
83
|
const element1 = { id: 1 };
|
|
83
84
|
const element2 = { id: 2 };
|
|
84
85
|
const mockData = [element1, element2];
|
|
85
86
|
|
|
86
87
|
const { result } = renderHook(() => useSequentialRenderItem(mockData));
|
|
87
88
|
|
|
88
|
-
const
|
|
89
|
+
const res = render(
|
|
89
90
|
result.current.renderItem(
|
|
90
91
|
() => {
|
|
91
92
|
return <View testID={"test"} />;
|
|
@@ -94,7 +95,9 @@ describe("flatList hooks", () => {
|
|
|
94
95
|
)
|
|
95
96
|
);
|
|
96
97
|
|
|
97
|
-
const element =
|
|
98
|
+
const element = res.root.findByProps({
|
|
99
|
+
testID: "sequential-river-wrapper-1",
|
|
100
|
+
});
|
|
98
101
|
|
|
99
102
|
expect(element.props.style.display).toEqual("none");
|
|
100
103
|
});
|
|
@@ -106,14 +109,16 @@ describe("flatList hooks", () => {
|
|
|
106
109
|
|
|
107
110
|
const { result } = renderHook(() => useSequentialRenderItem(mockData));
|
|
108
111
|
|
|
109
|
-
|
|
110
|
-
(
|
|
111
|
-
onLoadFinished
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
act(() => {
|
|
113
|
+
result.current.renderItem(
|
|
114
|
+
({ onLoadFinished }) => {
|
|
115
|
+
onLoadFinished();
|
|
116
|
+
},
|
|
117
|
+
{ item: element1, index: 0 }
|
|
118
|
+
);
|
|
119
|
+
});
|
|
115
120
|
|
|
116
|
-
const {
|
|
121
|
+
const { root } = render(
|
|
117
122
|
result.current.renderItem(
|
|
118
123
|
({ onLoadFinished }) => {
|
|
119
124
|
onLoadFinished();
|
|
@@ -124,7 +129,9 @@ describe("flatList hooks", () => {
|
|
|
124
129
|
)
|
|
125
130
|
);
|
|
126
131
|
|
|
127
|
-
const element =
|
|
132
|
+
const element = root.findByProps({
|
|
133
|
+
testID: "sequential-river-wrapper-1",
|
|
134
|
+
});
|
|
128
135
|
|
|
129
136
|
expect(element.props.style.display).toEqual("flex");
|
|
130
137
|
});
|
|
@@ -136,7 +143,7 @@ describe("flatList hooks", () => {
|
|
|
136
143
|
|
|
137
144
|
const { result } = renderHook(() => useSequentialRenderItem(mockData));
|
|
138
145
|
|
|
139
|
-
const {
|
|
146
|
+
const { root } = render(
|
|
140
147
|
result.current.renderItem(
|
|
141
148
|
({ onLoadFinished }) => {
|
|
142
149
|
onLoadFinished();
|
|
@@ -147,7 +154,9 @@ describe("flatList hooks", () => {
|
|
|
147
154
|
)
|
|
148
155
|
);
|
|
149
156
|
|
|
150
|
-
const element =
|
|
157
|
+
const element = root.findByProps({
|
|
158
|
+
testID: "sequential-river-wrapper-1",
|
|
159
|
+
});
|
|
151
160
|
|
|
152
161
|
expect(element.props.style.display).toEqual("none");
|
|
153
162
|
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { reactHooksLogger } from "../../logger";
|
|
2
|
+
import { useZappHooksModalState } from "@applicaster/zapp-react-dom-ui-components/Components/ZappHooksModal/hooks/useZappHooksModalState";
|
|
3
|
+
|
|
4
|
+
const logger = reactHooksLogger.addSubsystem("useHookModalScreenData");
|
|
5
|
+
|
|
6
|
+
type VariousScreenData = LegacyNavigationScreenData | ZappRiver | ZappEntry;
|
|
7
|
+
|
|
8
|
+
export const useHookModalScreenData = (): VariousScreenData | undefined => {
|
|
9
|
+
const hookModalState = useZappHooksModalState();
|
|
10
|
+
|
|
11
|
+
if (!hookModalState.state?.screenData) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
const screenData = hookModalState.state.screenData?.payload;
|
|
17
|
+
const hookPlugin = hookModalState.state.screenData.hookPlugin;
|
|
18
|
+
|
|
19
|
+
if (hookPlugin?.screen_id) {
|
|
20
|
+
return {
|
|
21
|
+
...screenData,
|
|
22
|
+
targetScreen: hookPlugin,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return hookModalState.state.screenData?.payload;
|
|
27
|
+
} catch (error) {
|
|
28
|
+
logger.error({
|
|
29
|
+
message: "Hook modal screen data creation failed",
|
|
30
|
+
data: {
|
|
31
|
+
error,
|
|
32
|
+
hookModalState,
|
|
33
|
+
},
|
|
34
|
+
jsOnly: true,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return hookModalState.state.screenData?.payload;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
@@ -14,10 +14,10 @@ const mocked_return_value = (tv) => ({
|
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
const platform = "android";
|
|
17
|
-
let
|
|
17
|
+
let mock_tv_flag = false;
|
|
18
18
|
|
|
19
19
|
ReactNative.Dimensions.get = jest.fn(
|
|
20
|
-
(context) => mocked_return_value(
|
|
20
|
+
(context) => mocked_return_value(mock_tv_flag)[context]
|
|
21
21
|
);
|
|
22
22
|
|
|
23
23
|
const mockRemoveFn = jest.fn();
|
|
@@ -43,7 +43,7 @@ jest.mock("react-native-safe-area-context", () => ({
|
|
|
43
43
|
|
|
44
44
|
jest.mock("../../../reactUtils", () => ({
|
|
45
45
|
platformSelect: jest.fn((specs) => specs[platform] || specs.default),
|
|
46
|
-
isTV: jest.fn(() =>
|
|
46
|
+
isTV: jest.fn(() => mock_tv_flag),
|
|
47
47
|
}));
|
|
48
48
|
|
|
49
49
|
jest.mock("../../navigation", () => ({
|
|
@@ -134,20 +134,20 @@ describe("useDimensions", () => {
|
|
|
134
134
|
|
|
135
135
|
describe("it applies the scale to the width & height if needed", () => {
|
|
136
136
|
it("applies the scale on TV, and screen context", () => {
|
|
137
|
-
|
|
138
|
-
const { screen } = mocked_return_value(
|
|
137
|
+
mock_tv_flag = true;
|
|
138
|
+
const { screen } = mocked_return_value(mock_tv_flag);
|
|
139
139
|
const { dimensions } = testHook("screen");
|
|
140
140
|
|
|
141
141
|
expect(dimensions).toHaveProperty("height", screen.height * screen.scale);
|
|
142
142
|
expect(dimensions).toHaveProperty("width", screen.width * screen.scale);
|
|
143
143
|
expect(dimensions).toHaveProperty("scale", 1);
|
|
144
144
|
|
|
145
|
-
|
|
145
|
+
mock_tv_flag = false;
|
|
146
146
|
});
|
|
147
147
|
|
|
148
148
|
it("doesn't apply the scale on mobile with screen context", () => {
|
|
149
|
-
|
|
150
|
-
const { screen } = mocked_return_value(
|
|
149
|
+
mock_tv_flag = false;
|
|
150
|
+
const { screen } = mocked_return_value(mock_tv_flag);
|
|
151
151
|
const { dimensions } = testHook("screen");
|
|
152
152
|
|
|
153
153
|
expect(dimensions).toHaveProperty("height", screen.height);
|
|
@@ -156,8 +156,8 @@ describe("useDimensions", () => {
|
|
|
156
156
|
});
|
|
157
157
|
|
|
158
158
|
it("doesn't apply the scale on TV with window context", () => {
|
|
159
|
-
|
|
160
|
-
const { window } = mocked_return_value(
|
|
159
|
+
mock_tv_flag = true;
|
|
160
|
+
const { window } = mocked_return_value(mock_tv_flag);
|
|
161
161
|
const { dimensions } = testHook("window");
|
|
162
162
|
|
|
163
163
|
expect(dimensions).toHaveProperty("height", window.height);
|
package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.native.test.js
CHANGED
|
@@ -1,25 +1,14 @@
|
|
|
1
1
|
import * as ReactNative from "react-native";
|
|
2
|
+
import NativeDeviceInfo from "react-native/Libraries/Utilities/NativeDeviceInfo";
|
|
2
3
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
screen: { width: 360, height: 540 },
|
|
8
|
-
}[type])
|
|
9
|
-
);
|
|
4
|
+
const mockDimensions = {
|
|
5
|
+
window: { width: 1, height: 1 },
|
|
6
|
+
screen: { width: 360, height: 540 },
|
|
7
|
+
};
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const mockGetConstants = jest.fn().mockReturnValue({
|
|
14
|
-
Dimensions: {
|
|
15
|
-
window: { width: 360, height: 540 },
|
|
16
|
-
screen: { width: 360, height: 540 },
|
|
17
|
-
},
|
|
18
|
-
});
|
|
9
|
+
const mockDimensionsGet = jest.fn((type) => mockDimensions[type]);
|
|
19
10
|
|
|
20
|
-
|
|
21
|
-
getConstants: mockGetConstants,
|
|
22
|
-
}));
|
|
11
|
+
ReactNative.Dimensions.get = mockDimensionsGet;
|
|
23
12
|
|
|
24
13
|
const { Platform, Dimensions } = ReactNative;
|
|
25
14
|
|
|
@@ -34,27 +23,24 @@ describe("useDimensions > helpers ( native )", () => {
|
|
|
34
23
|
|
|
35
24
|
it("should call Dimensions.get for window context", () => {
|
|
36
25
|
getInitialDimensions("window");
|
|
37
|
-
expect(Dimensions.get).
|
|
26
|
+
expect(Dimensions.get).toHaveBeenCalled();
|
|
38
27
|
});
|
|
39
28
|
|
|
40
29
|
it("should call Dimensions.get for screen context", () => {
|
|
41
30
|
getInitialDimensions("screen");
|
|
42
|
-
expect(Dimensions.get).
|
|
31
|
+
expect(Dimensions.get).toHaveBeenCalled();
|
|
43
32
|
});
|
|
44
33
|
|
|
45
34
|
it("should call NativeDeviceInfo.getConstants for ios when width === height", () => {
|
|
46
35
|
Platform.OS = "ios";
|
|
47
36
|
|
|
48
|
-
jest
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
screen: { width: 360, height: 540 },
|
|
52
|
-
},
|
|
53
|
-
});
|
|
37
|
+
const mockGetConstants = jest
|
|
38
|
+
.spyOn(NativeDeviceInfo, "getConstants")
|
|
39
|
+
.mockReturnValue({ Dimensions: mockDimensions });
|
|
54
40
|
|
|
55
41
|
getInitialDimensions("window");
|
|
56
42
|
|
|
57
|
-
expect(Dimensions.get).
|
|
58
|
-
expect(mockGetConstants).
|
|
43
|
+
expect(Dimensions.get).toHaveBeenCalled();
|
|
44
|
+
expect(mockGetConstants).toHaveBeenCalled();
|
|
59
45
|
});
|
|
60
46
|
});
|
|
@@ -52,6 +52,14 @@ export const useDimensions: UseDimensions = (
|
|
|
52
52
|
? { fullDimensions }
|
|
53
53
|
: { ...fullDimensions };
|
|
54
54
|
|
|
55
|
+
if (options.updateForInactiveScreens === undefined) {
|
|
56
|
+
options.updateForInactiveScreens = true;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (options.fullDimensions === undefined) {
|
|
60
|
+
options.fullDimensions = false;
|
|
61
|
+
}
|
|
62
|
+
|
|
55
63
|
const [dimensions, setDimensions] = useState(getInitialDimensions(context));
|
|
56
64
|
const deviceInfo = useRef(getDeviceInfo(dimensions, appData));
|
|
57
65
|
|