@applicaster/zapp-react-native-ui-components 13.0.0-alpha.5033140607 → 13.0.0-alpha.5304771702
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/Components/AppContainer/__tests__/__snapshots__/AppContainer.test.js.snap +1 -1
- package/Components/AudioPlayer/__tests__/__snapshots__/Runtime.test.js.snap +4 -4
- package/Components/AudioPlayer/__tests__/__snapshots__/artWork.test.js.snap +3 -3
- package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayer.test.js.snap +6 -6
- package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayerLayout.test.js.snap +7 -7
- package/Components/AudioPlayer/__tests__/__snapshots__/channel.test.js.snap +3 -3
- package/Components/AudioPlayer/__tests__/__snapshots__/summary.test.js.snap +2 -2
- package/Components/AudioPlayer/__tests__/__snapshots__/title.test.js.snap +2 -2
- package/Components/BaseFocusable/index.ios.ts +1 -1
- package/Components/BaseFocusable/index.tsx +66 -29
- package/Components/Cell/Cell.tsx +14 -9
- package/Components/Cell/CellWithFocusable.tsx +1 -1
- package/Components/Cell/TvOSCellComponent.tsx +3 -8
- package/Components/CellRendererResolver/__tests__/__snapshots__/cellRendererResolver.test.js.snap +20 -20
- package/Components/CellRendererResolver/__tests__/cellRendererResolver.test.js +5 -3
- package/Components/ComponentResolver/__tests__/__snapshots__/componentResolver.test.js.snap +5 -5
- package/Components/ComponentResolver/__tests__/componentResolver.test.js +11 -9
- package/Components/DisplayState/__tests__/__snapshots__/displayState.test.js.snap +2 -2
- package/Components/Focusable/Focusable.tsx +0 -54
- package/Components/Focusable/FocusableTvOS.tsx +1 -1
- package/Components/Focusable/Touchable.tsx +19 -20
- package/Components/FocusableList/index.tsx +0 -1
- package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +76 -7
- package/Components/GeneralContentScreen/utils/useCurationAPI.ts +53 -9
- package/Components/Layout/TV/__tests__/ScreenContainer.test.tsx +1 -0
- package/Components/Layout/TV/__tests__/__snapshots__/LayoutContainer.test.tsx.snap +1 -1
- package/Components/Layout/TV/__tests__/__snapshots__/NavBarContainer.test.tsx.snap +3 -3
- package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +9 -9
- package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +1 -1
- package/Components/Layout/TV/__tests__/index.test.tsx +7 -3
- package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx +66 -0
- package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +4 -1
- package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +6 -12
- package/Components/MasterCell/DefaultComponents/ImageBorderContainer/__tests__/index.test.ts +93 -0
- package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/__snapshots__/Image.test.tsx.snap +3 -3
- package/Components/MasterCell/DefaultComponents/SecondaryImage/utils.ts +1 -1
- package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
- package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/__snapshots__/index.test.tsx.snap +1 -1
- package/Components/MasterCell/__tests__/__snapshots__/dataAdapter.test.js.snap +180 -180
- package/Components/MasterCell/__tests__/__snapshots__/elementMapper.test.js.snap +7 -7
- package/Components/MasterCell/__tests__/__snapshots__/masterCell.test.js.snap +34 -34
- package/Components/MasterCell/hooks/useAsyncRendering/MasterCellAsyncRenderManager.ts +2 -2
- package/Components/MasterCell/hooks/useAsyncRendering/index.ts +2 -2
- package/Components/MasterCell/utils/index.ts +1 -1
- package/Components/ModalComponent/Header/index.tsx +3 -3
- package/Components/NativeFocusables/{index.js → index.ts} +4 -2
- package/Components/OfflineHandler/__tests__/__snapshots__/index.test.tsx.snap +7 -7
- package/Components/OfflineHandler/__tests__/index.test.tsx +28 -25
- package/Components/PlayerContainer/PlayerContainer.tsx +5 -11
- package/Components/PlayerContainer/PlayerContainerContext.tsx +9 -0
- package/Components/River/ComponentsMap/ComponentsMap.tsx +39 -65
- package/Components/River/ComponentsMap/hooks/useLoadingState.ts +78 -51
- package/Components/River/RefreshControl.tsx +1 -1
- package/Components/River/RiverFooter.tsx +39 -9
- package/Components/River/RiverItem.tsx +37 -2
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +114 -45
- package/Components/River/__tests__/__snapshots__/river.test.js.snap +12 -12
- package/Components/River/__tests__/componentsMap.test.js +64 -17
- package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +1 -1
- package/Components/RouteManager/__tests__/__snapshots__/testId.test.js.snap +1 -1
- package/Components/Screen/__tests__/Screen.test.tsx +41 -27
- package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +4 -4
- package/Components/Screen/index.tsx +1 -0
- package/Components/ScreenResolver/__tests__/__snapshots__/screenResolver.test.js.snap +2 -2
- package/Components/ScreenResolver/__tests__/screenResolver.test.js +31 -27
- package/Components/Tabs/Tab.tsx +7 -6
- package/Components/TextInputTv/__tests__/TextInputTv.test.js +42 -42
- package/Components/TextInputTv/__tests__/__snapshots__/TextInputTv.test.js.snap +7 -0
- package/Components/TextInputTv/index.tsx +4 -4
- package/Components/Touchable/__tests__/__snapshots__/touchable.test.tsx.snap +2 -2
- package/Components/Transitioner/AnimationManager.js +8 -8
- package/Components/Transitioner/Scene.tsx +52 -23
- package/Components/Transitioner/__tests__/__snapshots__/AnimationManager.test.js.snap +26 -26
- package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +62 -46
- package/Components/Transitioner/__tests__/__snapshots__/config.test.js.snap +20 -20
- package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +4 -4
- package/Components/Transitioner/index.js +8 -4
- package/Components/VideoLive/LiveImageManager.ts +27 -1
- package/Components/VideoLive/PlayerLiveImageComponent.tsx +29 -21
- package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +63 -8
- package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +5 -10
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +5 -1
- package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +5 -1
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +8 -7
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +4 -10
- package/Components/VideoModal/ModalAnimation/index.ts +2 -1
- package/Components/VideoModal/ModalAnimation/useModalAnimationContext.ts +6 -0
- package/Components/VideoModal/ModalAnimation/utils.ts +2 -2
- package/Components/VideoModal/OpaqueLayer.tsx +33 -0
- package/Components/VideoModal/PlayerWrapper.tsx +16 -35
- package/Components/VideoModal/VideoModal.tsx +14 -23
- package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +5 -2
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +13 -10
- package/Components/VideoModal/__tests__/__snapshots__/PlayerDetails.test.tsx.snap +4 -4
- package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +66 -156
- package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +89 -0
- package/Components/VideoModal/hooks/index.ts +7 -0
- package/Components/VideoModal/hooks/useDelayedPlayerDetails.ts +49 -0
- package/Components/VideoModal/hooks/utils/__tests__/showDetails.test.ts +91 -0
- package/Components/VideoModal/hooks/utils/index.ts +33 -0
- package/Components/VideoModal/utils.ts +3 -5
- package/Components/Viewport/ViewportAware/__tests__/__snapshots__/viewportAware.test.js.snap +2 -2
- package/Components/Viewport/ViewportTracker/__tests__/__snapshots__/viewportTracker.test.js.snap +1 -1
- package/Components/ZappUIComponent/__tests__/__snapshots__/ZappUIComponent.test.js.snap +11 -11
- package/Components/default-cell-renderer/__tests__/__snapshots__/defaultCellRenderer.test.tsx.snap +30 -30
- package/Contexts/ConfigutaionContext/__tests__/__snapshots__/ConfigurationProvider.test.tsx.snap +1 -1
- package/Contexts/ScreenContext/index.tsx +3 -2
- package/Decorators/Analytics/{index.js → index.tsx} +11 -11
- package/Decorators/Navigator/__tests__/__snapshots__/navigator.test.js.snap +2 -2
- package/Decorators/RiverFeedLoader/__tests__/__snapshots__/riverFeedLoader.test.tsx.snap +77 -77
- package/Decorators/RiverFeedLoader/__tests__/riverFeedLoader.test.tsx +34 -39
- package/Decorators/RiverFeedLoader/__tests__/utils.test.ts +0 -9
- package/Decorators/RiverFeedLoader/index.tsx +1 -1
- package/Decorators/RiverFeedLoader/utils/getDatasourceUrl.ts +39 -0
- package/Decorators/RiverFeedLoader/utils/index.ts +29 -0
- package/Decorators/RiverFeedLoader/utils/usePipesContexts.ts +40 -0
- package/Decorators/RiverResolver/__tests__/__snapshots__/riverResolver.test.tsx.snap +5 -5
- package/Decorators/RiverResolver/__tests__/riverResolver.test.tsx +16 -10
- package/Decorators/ZappPipesDataConnector/__tests__/Hero.js +1 -1
- package/Decorators/ZappPipesDataConnector/index.tsx +32 -2
- package/package.json +12 -6
- package/Decorators/RiverFeedLoader/utils.ts +0 -100
|
@@ -4,206 +4,206 @@ exports[`WithRiverFeedLoader renders correctly 1`] = `
|
|
|
4
4
|
<View
|
|
5
5
|
dispatch={[MockFunction]}
|
|
6
6
|
river={
|
|
7
|
-
|
|
7
|
+
{
|
|
8
8
|
"id": "A1234",
|
|
9
|
-
"ui_components":
|
|
10
|
-
|
|
11
|
-
"data":
|
|
9
|
+
"ui_components": [
|
|
10
|
+
{
|
|
11
|
+
"data": {
|
|
12
12
|
"source": "http://datasource0",
|
|
13
13
|
},
|
|
14
|
-
"rules":
|
|
14
|
+
"rules": {
|
|
15
15
|
"clear_cache_on_reload": false,
|
|
16
16
|
},
|
|
17
17
|
},
|
|
18
|
-
|
|
19
|
-
"data":
|
|
18
|
+
{
|
|
19
|
+
"data": {
|
|
20
20
|
"source": "http://datasource1",
|
|
21
21
|
},
|
|
22
|
-
"rules":
|
|
22
|
+
"rules": {
|
|
23
23
|
"clear_cache_on_reload": false,
|
|
24
24
|
},
|
|
25
25
|
},
|
|
26
|
-
|
|
27
|
-
"data":
|
|
26
|
+
{
|
|
27
|
+
"data": {
|
|
28
28
|
"source": "http://datasource2",
|
|
29
29
|
},
|
|
30
|
-
"rules":
|
|
30
|
+
"rules": {
|
|
31
31
|
"clear_cache_on_reload": false,
|
|
32
32
|
},
|
|
33
33
|
},
|
|
34
|
-
|
|
35
|
-
"data":
|
|
34
|
+
{
|
|
35
|
+
"data": {
|
|
36
36
|
"source": "http://datasource3",
|
|
37
37
|
},
|
|
38
|
-
"rules":
|
|
38
|
+
"rules": {
|
|
39
39
|
"clear_cache_on_reload": false,
|
|
40
40
|
},
|
|
41
41
|
},
|
|
42
|
-
|
|
43
|
-
"data":
|
|
42
|
+
{
|
|
43
|
+
"data": {
|
|
44
44
|
"source": "http://datasource4",
|
|
45
45
|
},
|
|
46
|
-
"rules":
|
|
46
|
+
"rules": {
|
|
47
47
|
"clear_cache_on_reload": false,
|
|
48
48
|
},
|
|
49
49
|
},
|
|
50
|
-
|
|
51
|
-
"data":
|
|
50
|
+
{
|
|
51
|
+
"data": {
|
|
52
52
|
"source": "http://datasource5",
|
|
53
53
|
},
|
|
54
|
-
"rules":
|
|
54
|
+
"rules": {
|
|
55
55
|
"clear_cache_on_reload": false,
|
|
56
56
|
},
|
|
57
57
|
},
|
|
58
|
-
|
|
59
|
-
"data":
|
|
58
|
+
{
|
|
59
|
+
"data": {
|
|
60
60
|
"source": "http://datasource6",
|
|
61
61
|
},
|
|
62
|
-
"rules":
|
|
62
|
+
"rules": {
|
|
63
63
|
"clear_cache_on_reload": false,
|
|
64
64
|
},
|
|
65
65
|
},
|
|
66
|
-
|
|
67
|
-
"data":
|
|
66
|
+
{
|
|
67
|
+
"data": {
|
|
68
68
|
"source": "http://datasource7",
|
|
69
69
|
},
|
|
70
|
-
"rules":
|
|
70
|
+
"rules": {
|
|
71
71
|
"clear_cache_on_reload": false,
|
|
72
72
|
},
|
|
73
73
|
},
|
|
74
|
-
|
|
75
|
-
"data":
|
|
74
|
+
{
|
|
75
|
+
"data": {
|
|
76
76
|
"source": "http://datasource8",
|
|
77
77
|
},
|
|
78
|
-
"rules":
|
|
78
|
+
"rules": {
|
|
79
79
|
"clear_cache_on_reload": false,
|
|
80
80
|
},
|
|
81
81
|
},
|
|
82
|
-
|
|
83
|
-
"data":
|
|
82
|
+
{
|
|
83
|
+
"data": {
|
|
84
84
|
"source": "http://datasource9",
|
|
85
85
|
},
|
|
86
|
-
"rules":
|
|
86
|
+
"rules": {
|
|
87
87
|
"clear_cache_on_reload": false,
|
|
88
88
|
},
|
|
89
89
|
},
|
|
90
|
-
|
|
91
|
-
"data":
|
|
90
|
+
{
|
|
91
|
+
"data": {
|
|
92
92
|
"source": "http://datasource10",
|
|
93
93
|
},
|
|
94
|
-
"rules":
|
|
94
|
+
"rules": {
|
|
95
95
|
"clear_cache_on_reload": false,
|
|
96
96
|
},
|
|
97
97
|
},
|
|
98
|
-
|
|
99
|
-
"data":
|
|
98
|
+
{
|
|
99
|
+
"data": {
|
|
100
100
|
"source": "http://datasource11",
|
|
101
101
|
},
|
|
102
|
-
"rules":
|
|
102
|
+
"rules": {
|
|
103
103
|
"clear_cache_on_reload": false,
|
|
104
104
|
},
|
|
105
105
|
},
|
|
106
|
-
|
|
107
|
-
"data":
|
|
106
|
+
{
|
|
107
|
+
"data": {
|
|
108
108
|
"source": "http://datasource12",
|
|
109
109
|
},
|
|
110
|
-
"rules":
|
|
110
|
+
"rules": {
|
|
111
111
|
"clear_cache_on_reload": true,
|
|
112
112
|
},
|
|
113
113
|
},
|
|
114
|
-
|
|
115
|
-
"data":
|
|
114
|
+
{
|
|
115
|
+
"data": {
|
|
116
116
|
"source": "http://datasource13",
|
|
117
117
|
},
|
|
118
|
-
"rules":
|
|
118
|
+
"rules": {
|
|
119
119
|
"clear_cache_on_reload": false,
|
|
120
120
|
},
|
|
121
121
|
},
|
|
122
|
-
|
|
123
|
-
"data":
|
|
122
|
+
{
|
|
123
|
+
"data": {
|
|
124
124
|
"source": "http://datasource14",
|
|
125
125
|
},
|
|
126
|
-
"rules":
|
|
126
|
+
"rules": {
|
|
127
127
|
"clear_cache_on_reload": false,
|
|
128
128
|
},
|
|
129
129
|
},
|
|
130
|
-
|
|
131
|
-
"data":
|
|
130
|
+
{
|
|
131
|
+
"data": {
|
|
132
132
|
"source": "http://datasource15",
|
|
133
133
|
},
|
|
134
|
-
"rules":
|
|
134
|
+
"rules": {
|
|
135
135
|
"clear_cache_on_reload": false,
|
|
136
136
|
},
|
|
137
137
|
},
|
|
138
|
-
|
|
139
|
-
"data":
|
|
138
|
+
{
|
|
139
|
+
"data": {
|
|
140
140
|
"source": "http://datasource16",
|
|
141
141
|
},
|
|
142
|
-
"rules":
|
|
142
|
+
"rules": {
|
|
143
143
|
"clear_cache_on_reload": false,
|
|
144
144
|
},
|
|
145
145
|
},
|
|
146
|
-
|
|
147
|
-
"data":
|
|
146
|
+
{
|
|
147
|
+
"data": {
|
|
148
148
|
"source": "http://datasource17",
|
|
149
149
|
},
|
|
150
|
-
"rules":
|
|
150
|
+
"rules": {
|
|
151
151
|
"clear_cache_on_reload": false,
|
|
152
152
|
},
|
|
153
153
|
},
|
|
154
|
-
|
|
155
|
-
"data":
|
|
154
|
+
{
|
|
155
|
+
"data": {
|
|
156
156
|
"source": "http://datasource18",
|
|
157
157
|
},
|
|
158
|
-
"rules":
|
|
158
|
+
"rules": {
|
|
159
159
|
"clear_cache_on_reload": false,
|
|
160
160
|
},
|
|
161
161
|
},
|
|
162
|
-
|
|
163
|
-
"data":
|
|
162
|
+
{
|
|
163
|
+
"data": {
|
|
164
164
|
"source": "http://datasource19",
|
|
165
165
|
},
|
|
166
|
-
"rules":
|
|
166
|
+
"rules": {
|
|
167
167
|
"clear_cache_on_reload": false,
|
|
168
168
|
},
|
|
169
169
|
},
|
|
170
|
-
|
|
171
|
-
"data":
|
|
170
|
+
{
|
|
171
|
+
"data": {
|
|
172
172
|
"source": "http://datasource20",
|
|
173
173
|
},
|
|
174
|
-
"rules":
|
|
174
|
+
"rules": {
|
|
175
175
|
"clear_cache_on_reload": true,
|
|
176
176
|
},
|
|
177
177
|
},
|
|
178
|
-
|
|
179
|
-
"data":
|
|
178
|
+
{
|
|
179
|
+
"data": {
|
|
180
180
|
"source": "http://datasource21",
|
|
181
181
|
},
|
|
182
|
-
"rules":
|
|
182
|
+
"rules": {
|
|
183
183
|
"clear_cache_on_reload": false,
|
|
184
184
|
},
|
|
185
185
|
},
|
|
186
|
-
|
|
187
|
-
"data":
|
|
186
|
+
{
|
|
187
|
+
"data": {
|
|
188
188
|
"source": "http://datasource22",
|
|
189
189
|
},
|
|
190
|
-
"rules":
|
|
190
|
+
"rules": {
|
|
191
191
|
"clear_cache_on_reload": false,
|
|
192
192
|
},
|
|
193
193
|
},
|
|
194
|
-
|
|
195
|
-
"data":
|
|
194
|
+
{
|
|
195
|
+
"data": {
|
|
196
196
|
"source": "http://datasource23",
|
|
197
197
|
},
|
|
198
|
-
"rules":
|
|
198
|
+
"rules": {
|
|
199
199
|
"clear_cache_on_reload": false,
|
|
200
200
|
},
|
|
201
201
|
},
|
|
202
|
-
|
|
203
|
-
"data":
|
|
202
|
+
{
|
|
203
|
+
"data": {
|
|
204
204
|
"source": "http://datasource24",
|
|
205
205
|
},
|
|
206
|
-
"rules":
|
|
206
|
+
"rules": {
|
|
207
207
|
"clear_cache_on_reload": false,
|
|
208
208
|
},
|
|
209
209
|
},
|
|
@@ -3,73 +3,68 @@ import * as R from "ramda";
|
|
|
3
3
|
import { View } from "react-native";
|
|
4
4
|
import { render } from "@testing-library/react-native";
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
entryContext,
|
|
8
|
-
navigator,
|
|
9
|
-
river,
|
|
10
|
-
riverDataSources,
|
|
11
|
-
screenContext,
|
|
12
|
-
screenData,
|
|
13
|
-
searchContext,
|
|
14
|
-
} from "./fixtures";
|
|
6
|
+
import * as mock_fixtures from "./fixtures";
|
|
15
7
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
const mockUsePipesContexts = () => ({
|
|
9
|
+
entry: mock_fixtures.entryContext,
|
|
10
|
+
screen: mock_fixtures.screenContext,
|
|
11
|
+
search: mock_fixtures.searchContext,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const mockGetDatasourceUrl = jest.fn(
|
|
15
|
+
R.curry((_, component) => component.data.source)
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
jest.mock(
|
|
19
|
+
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useRoute",
|
|
20
|
+
() => ({
|
|
21
|
+
useRoute: jest.fn(() => ({ screenData: mock_fixtures.screenData })),
|
|
22
|
+
})
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
jest.mock(
|
|
26
|
+
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation",
|
|
27
|
+
() => ({
|
|
28
|
+
useNavigation: jest.fn(() => mock_fixtures.navigator),
|
|
29
|
+
})
|
|
30
|
+
);
|
|
20
31
|
|
|
21
32
|
jest.mock("../utils", () => ({
|
|
22
|
-
|
|
33
|
+
...jest.requireActual("../utils"),
|
|
23
34
|
loadDatasources: jest.fn(),
|
|
24
|
-
getDatasourceUrl:
|
|
25
|
-
usePipesContexts:
|
|
26
|
-
entryContext,
|
|
27
|
-
searchContext,
|
|
28
|
-
screenContext,
|
|
29
|
-
})),
|
|
30
|
-
ignoreComponentsWithClearCacheFlag: R.reject(
|
|
31
|
-
R.pathEq(["rules", "clear_cache_on_reload"], true)
|
|
32
|
-
),
|
|
35
|
+
getDatasourceUrl: mockGetDatasourceUrl,
|
|
36
|
+
usePipesContexts: mockUsePipesContexts,
|
|
33
37
|
}));
|
|
34
38
|
|
|
35
|
-
const { WithRiverFeedLoader } = require("../index");
|
|
36
|
-
|
|
37
39
|
const River = function (props) {
|
|
38
40
|
return <View {...props} />;
|
|
39
41
|
};
|
|
40
42
|
|
|
41
43
|
const riverProps = {
|
|
42
|
-
river,
|
|
44
|
+
river: mock_fixtures.river,
|
|
43
45
|
dispatch: jest.fn(),
|
|
44
46
|
};
|
|
45
47
|
|
|
46
|
-
const DecoratedRiver = WithRiverFeedLoader(River);
|
|
47
|
-
|
|
48
48
|
const { loadDatasources, getDatasourceUrl } = require("../utils");
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
const getWrapper = () => render(<DecoratedRiver {...riverProps} />);
|
|
50
|
+
const { WithRiverFeedLoader } = require("..");
|
|
52
51
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
});
|
|
52
|
+
describe("WithRiverFeedLoader", () => {
|
|
53
|
+
const DecoratedRiver = WithRiverFeedLoader(River);
|
|
54
|
+
const wrapper = render(<DecoratedRiver {...riverProps} />);
|
|
57
55
|
|
|
58
56
|
it("renders correctly", () => {
|
|
59
|
-
const wrapper = getWrapper();
|
|
60
57
|
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
61
58
|
});
|
|
62
59
|
|
|
63
60
|
it("collects the datasources in the screen and loads them", () => {
|
|
64
|
-
getWrapper();
|
|
65
|
-
|
|
66
61
|
expect(getDatasourceUrl).toHaveBeenCalledTimes(1);
|
|
67
62
|
expect(loadDatasources).toHaveBeenCalledTimes(1);
|
|
68
63
|
|
|
69
64
|
expect(loadDatasources).toHaveBeenNthCalledWith(
|
|
70
65
|
1,
|
|
71
|
-
riverDataSources,
|
|
72
|
-
river.id,
|
|
66
|
+
mock_fixtures.riverDataSources,
|
|
67
|
+
mock_fixtures.river.id,
|
|
73
68
|
riverProps.dispatch
|
|
74
69
|
);
|
|
75
70
|
});
|
|
@@ -14,7 +14,6 @@ jest.mock("@applicaster/zapp-react-native-redux/ZappPipes", () => ({
|
|
|
14
14
|
}));
|
|
15
15
|
|
|
16
16
|
const {
|
|
17
|
-
DATASOURCE_CHUNKS,
|
|
18
17
|
loadDatasources,
|
|
19
18
|
riverIsCurrentRoute,
|
|
20
19
|
getDatasourceUrl,
|
|
@@ -27,14 +26,6 @@ const {
|
|
|
27
26
|
|
|
28
27
|
const dispatch = (value) => Promise.resolve(value);
|
|
29
28
|
|
|
30
|
-
describe("DATASOURCE_CHUNKS", () => {
|
|
31
|
-
const DEFAULT_DATASOURCE_CHUNKS = 10;
|
|
32
|
-
|
|
33
|
-
it("has the correct value", () => {
|
|
34
|
-
expect(DATASOURCE_CHUNKS).toBe(DEFAULT_DATASOURCE_CHUNKS);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
29
|
describe("loadDataSource", () => {
|
|
39
30
|
it("calls loadPipesData for each provided urls", async () => {
|
|
40
31
|
const urls = [
|
|
@@ -2,7 +2,7 @@ import React, { ComponentClass, FC, useEffect } from "react";
|
|
|
2
2
|
import * as R from "ramda";
|
|
3
3
|
import { DispatchProp } from "react-redux";
|
|
4
4
|
|
|
5
|
-
import { useRoute } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
5
|
+
import { useRoute } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useRoute";
|
|
6
6
|
|
|
7
7
|
import { mapAndSplit } from "@applicaster/zapp-react-native-utils/arrayUtils";
|
|
8
8
|
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as R from "ramda";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
getInflatedDataSourceUrl,
|
|
5
|
+
getSearchContext,
|
|
6
|
+
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
7
|
+
|
|
8
|
+
import { ZappPipesEntryContext } from "../../../Contexts";
|
|
9
|
+
|
|
10
|
+
export const getDatasourceUrl: (
|
|
11
|
+
contexts: {
|
|
12
|
+
screenData?: Record<string, any>;
|
|
13
|
+
entryContext: ReturnType<
|
|
14
|
+
typeof ZappPipesEntryContext.useZappPipesContext
|
|
15
|
+
>[0];
|
|
16
|
+
searchContext: string;
|
|
17
|
+
screenContext: ZappRiver;
|
|
18
|
+
},
|
|
19
|
+
component?: ZappUIComponent
|
|
20
|
+
) => string | null = R.curry(
|
|
21
|
+
(
|
|
22
|
+
{ screenData, entryContext, searchContext, screenContext },
|
|
23
|
+
component: ZappUIComponent
|
|
24
|
+
) => {
|
|
25
|
+
const { source, mapping } = R.propOr({}, ["data"], component);
|
|
26
|
+
|
|
27
|
+
if (mapping) {
|
|
28
|
+
const contexts = {
|
|
29
|
+
entry: entryContext,
|
|
30
|
+
screen: screenContext || screenData,
|
|
31
|
+
search: getSearchContext(searchContext, mapping),
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
return getInflatedDataSourceUrl({ source, mapping, contexts });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return source;
|
|
38
|
+
}
|
|
39
|
+
);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as R from "ramda";
|
|
2
|
+
import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
mapPromises,
|
|
6
|
+
reducePromises,
|
|
7
|
+
} from "@applicaster/zapp-react-native-utils/arrayUtils";
|
|
8
|
+
|
|
9
|
+
export { riverIsCurrentRoute, usePipesContexts } from "./usePipesContexts";
|
|
10
|
+
|
|
11
|
+
export { getDatasourceUrl } from "./getDatasourceUrl";
|
|
12
|
+
|
|
13
|
+
export const DATASOURCE_CHUNKS = 10;
|
|
14
|
+
|
|
15
|
+
export async function loadDatasources(urls: string[][], riverId, dispatch) {
|
|
16
|
+
return reducePromises<string, void>(
|
|
17
|
+
mapPromises<string, void>((url) => {
|
|
18
|
+
if (url) {
|
|
19
|
+
return dispatch(loadPipesData(url, { riverId }));
|
|
20
|
+
}
|
|
21
|
+
}),
|
|
22
|
+
undefined,
|
|
23
|
+
urls
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const ignoreComponentsWithClearCacheFlag = R.reject(
|
|
28
|
+
R.pathEq(["rules", "clear_cache_on_reload"], true)
|
|
29
|
+
);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as R from "ramda";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ZappPipesEntryContext,
|
|
5
|
+
ZappPipesScreenContext,
|
|
6
|
+
ZappPipesSearchContext,
|
|
7
|
+
} from "../../../Contexts";
|
|
8
|
+
|
|
9
|
+
export function riverIsCurrentRoute(riverId, route) {
|
|
10
|
+
const routeRiverId = R.compose(R.last, R.split("/"))(route);
|
|
11
|
+
|
|
12
|
+
return typeof riverId === "undefined" || routeRiverId === riverId;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function usePipesContexts(
|
|
16
|
+
riverId: string,
|
|
17
|
+
route: string
|
|
18
|
+
): {
|
|
19
|
+
entryContext: ReturnType<typeof ZappPipesEntryContext.useZappPipesContext>[0];
|
|
20
|
+
searchContext: string;
|
|
21
|
+
screenContext: ZappRiver;
|
|
22
|
+
} {
|
|
23
|
+
const isNestedScreen = !riverIsCurrentRoute(riverId, route);
|
|
24
|
+
|
|
25
|
+
const routeForEntry = isNestedScreen ? `${route}/river/${riverId}` : route;
|
|
26
|
+
|
|
27
|
+
const [entryContext] = ZappPipesEntryContext.useZappPipesContext(
|
|
28
|
+
routeForEntry,
|
|
29
|
+
isNestedScreen
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const [searchContext] = ZappPipesSearchContext.useZappPipesContext();
|
|
33
|
+
const [screenContext] = ZappPipesScreenContext.useZappPipesContext();
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
entryContext,
|
|
37
|
+
searchContext,
|
|
38
|
+
screenContext,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -4,22 +4,22 @@ exports[`withRiver HoC renders correctly 1`] = `
|
|
|
4
4
|
<mockConstructor
|
|
5
5
|
otherProp="otherProp"
|
|
6
6
|
river={
|
|
7
|
-
|
|
7
|
+
{
|
|
8
8
|
"id": "A123",
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
rivers={
|
|
12
|
-
|
|
13
|
-
"A123":
|
|
12
|
+
{
|
|
13
|
+
"A123": {
|
|
14
14
|
"id": "A123",
|
|
15
15
|
},
|
|
16
|
-
"B345":
|
|
16
|
+
"B345": {
|
|
17
17
|
"id": "B345",
|
|
18
18
|
},
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
screenData={
|
|
22
|
-
|
|
22
|
+
{
|
|
23
23
|
"id": "A123",
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { shallow } from "enzyme";
|
|
3
3
|
import { View } from "react-native";
|
|
4
4
|
import { shallowToJson } from "enzyme-to-json";
|
|
5
|
-
import * as
|
|
5
|
+
import * as usePathnameHooks from "@applicaster/zapp-react-native-utils/reactHooks/navigation/usePathname";
|
|
6
6
|
|
|
7
7
|
const rivers = {
|
|
8
8
|
A123: {
|
|
@@ -13,15 +13,21 @@ const rivers = {
|
|
|
13
13
|
},
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
jest.doMock(
|
|
17
|
-
usePickFromState
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
jest.doMock(
|
|
17
|
+
"@applicaster/zapp-react-native-redux/hooks/usePickFromState",
|
|
18
|
+
() => ({
|
|
19
|
+
usePickFromState: jest.fn(() => ({ rivers })),
|
|
20
|
+
})
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
jest.mock(
|
|
24
|
+
"@applicaster/zapp-react-native-utils/reactHooks/layout/useLayoutVersion",
|
|
25
|
+
() => ({
|
|
26
|
+
useLayoutVersion: jest.fn(() => true),
|
|
27
|
+
})
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
jest.spyOn(usePathnameHooks, "usePathname").mockReturnValue("/home");
|
|
25
31
|
|
|
26
32
|
// mocks useNavigator to return currentRoute: "/home"
|
|
27
33
|
jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/// <reference types="@applicaster/applicaster-types" />
|
|
2
2
|
/// <reference types="@applicaster/zapp-react-native-ui-components" />
|
|
3
3
|
import React, { useEffect, useMemo } from "react";
|
|
4
|
+
import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
|
|
5
|
+
|
|
4
6
|
import * as R from "ramda";
|
|
5
7
|
import { Platform } from "react-native";
|
|
6
8
|
import Url from "url";
|
|
7
|
-
|
|
9
|
+
import { ENDPOINT_TAGS } from "@applicaster/zapp-react-native-utils/types";
|
|
8
10
|
import { favoritesListener } from "@applicaster/zapp-react-native-bridge/Favorites";
|
|
9
11
|
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
10
12
|
import { useRoute } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
|
|
@@ -16,9 +18,15 @@ import {
|
|
|
16
18
|
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
17
19
|
|
|
18
20
|
import { ZappPipesSearchContext } from "@applicaster/zapp-react-native-ui-components/Contexts";
|
|
19
|
-
import { useScreenContext } from "@applicaster/zapp-react-native-utils/reactHooks/screen";
|
|
21
|
+
import { useScreenContext } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
|
|
20
22
|
|
|
21
23
|
import { isVerticalListOrGrid } from "./utils";
|
|
24
|
+
import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
|
|
25
|
+
import {
|
|
26
|
+
findEndpointForURL,
|
|
27
|
+
HTTP_METHODS,
|
|
28
|
+
} from "@applicaster/zapp-pipes-v2-client";
|
|
29
|
+
import { getNamespaceAndKey } from "@applicaster/zapp-react-native-utils/appUtils/contextKeysManager/utils";
|
|
22
30
|
|
|
23
31
|
type Props = {
|
|
24
32
|
component: ZappUIComponent;
|
|
@@ -291,6 +299,28 @@ export function zappPipesDataConnector(
|
|
|
291
299
|
if (addListener) {
|
|
292
300
|
return addListener(reloadData);
|
|
293
301
|
}
|
|
302
|
+
} else {
|
|
303
|
+
const pipesEndpoints = appStore.get("pipesEndpoints");
|
|
304
|
+
|
|
305
|
+
const endpointURL = findEndpointForURL(
|
|
306
|
+
dataSourceUrl,
|
|
307
|
+
pipesEndpoints,
|
|
308
|
+
HTTP_METHODS.GET
|
|
309
|
+
);
|
|
310
|
+
|
|
311
|
+
const endpoint = pipesEndpoints?.[endpointURL];
|
|
312
|
+
|
|
313
|
+
if (endpoint?.tags?.includes(ENDPOINT_TAGS.observe_storage)) {
|
|
314
|
+
const subscriptions: (() => void)[] = endpoint.context_obj.map(
|
|
315
|
+
(data: Record<string, any>) => {
|
|
316
|
+
const { namespace, key } = getNamespaceAndKey(data.key);
|
|
317
|
+
|
|
318
|
+
return localStorage.addListener({ key, namespace }, reloadData);
|
|
319
|
+
}
|
|
320
|
+
);
|
|
321
|
+
|
|
322
|
+
return () => subscriptions.forEach((listener) => listener());
|
|
323
|
+
}
|
|
294
324
|
}
|
|
295
325
|
}, [dataSourceUrl, reloadData]);
|
|
296
326
|
|