@applicaster/zapp-react-native-ui-components 15.0.0-alpha.8680244503 → 15.0.0-alpha.9102777840
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/BaseFocusable/index.ios.ts +12 -2
- package/Components/Cell/Cell.tsx +6 -0
- package/Components/Cell/CellWithFocusable.tsx +9 -0
- package/Components/Cell/FocusableWrapper.tsx +3 -0
- package/Components/Cell/TvOSCellComponent.tsx +5 -0
- package/Components/Focusable/Focusable.tsx +4 -2
- package/Components/Focusable/FocusableTvOS.tsx +18 -1
- package/Components/Focusable/__tests__/__snapshots__/FocusableTvOS.test.tsx.snap +1 -0
- package/Components/FocusableGroup/FocusableTvOS.tsx +32 -1
- package/Components/GeneralContentScreen/GeneralContentScreen.tsx +3 -8
- package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +1 -1
- package/Components/GeneralContentScreen/utils/useCurationAPI.ts +22 -6
- package/Components/HandlePlayable/HandlePlayable.tsx +16 -29
- package/Components/HandlePlayable/utils.ts +31 -0
- package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +40 -39
- package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/Image.test.tsx +95 -0
- package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/__snapshots__/Image.test.tsx.snap +86 -0
- package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/index.test.ts +141 -0
- package/Components/MasterCell/DefaultComponents/SecondaryImage/hooks/__tests__/useGetImageDimensions.test.ts +7 -6
- package/Components/MasterCell/DefaultComponents/SecondaryImage/index.ts +1 -1
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/index.ts +6 -2
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/__tests__/getPluginIdentifier.test.ts +233 -11
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/index.ts +19 -15
- package/Components/MasterCell/hoc/__tests__/withAsyncRender.test.tsx +219 -0
- package/Components/MasterCell/hoc/withAsyncRender.tsx +9 -7
- package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +17 -9
- package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +16 -8
- package/Components/OfflineHandler/NotificationView/utils.ts +34 -0
- package/Components/PlayerContainer/PlayerContainer.tsx +40 -47
- package/Components/River/ComponentsMap/ComponentsMap.tsx +16 -0
- package/Components/River/ComponentsMap/hooks/__tests__/useLoadingState.test.ts +1 -1
- package/Components/River/RefreshControl.tsx +9 -3
- package/Components/River/TV/River.tsx +31 -14
- package/Components/River/TV/index.tsx +8 -4
- package/Components/River/TV/utils/__tests__/toStringOrEmpty.test.ts +30 -0
- package/Components/River/TV/utils/index.ts +4 -0
- package/Components/River/TV/withFocusableGroupForContent.tsx +71 -0
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +2 -0
- package/Components/River/__tests__/componentsMap.test.js +38 -0
- package/Components/Screen/__tests__/Screen.test.tsx +1 -0
- package/Components/Screen/hooks.ts +73 -3
- package/Components/Screen/index.tsx +7 -1
- package/Components/Screen/orientationHandler.ts +7 -10
- package/Components/ScreenResolver/index.tsx +14 -10
- package/Components/Tabs/TabContent.tsx +7 -4
- package/Components/Transitioner/Scene.tsx +9 -15
- package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +15 -7
- package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +0 -2
- package/Components/Viewport/ViewportAware/index.tsx +16 -7
- package/Components/Viewport/ViewportEvents/__tests__/viewportEvents.test.js +1 -1
- package/Contexts/ScreenContext/index.tsx +54 -19
- package/Contexts/ScreenTrackedViewPositionsContext/__tests__/index.test.tsx +1 -1
- package/Contexts/ZappHookModalContext/index.tsx +37 -61
- package/Contexts/ZappPipesContext/ZappPipesContextFactory.tsx +18 -7
- package/Contexts/index.ts +0 -2
- package/Decorators/ConfigurationWrapper/__tests__/__snapshots__/withConfigurationProvider.test.tsx.snap +1 -0
- package/Decorators/ConfigurationWrapper/const.ts +1 -0
- package/Decorators/ZappPipesDataConnector/ResolverSelector.tsx +25 -7
- package/Decorators/ZappPipesDataConnector/__tests__/ResolverSelector.test.tsx +212 -5
- package/Decorators/ZappPipesDataConnector/__tests__/UrlFeedResolver.test.tsx +39 -21
- package/Decorators/ZappPipesDataConnector/__tests__/zappPipesDataConnector.test.js +1 -1
- package/Decorators/ZappPipesDataConnector/resolvers/UrlFeedResolver.tsx +18 -7
- package/events/index.ts +3 -0
- package/events/scrollEndReached.ts +15 -0
- package/package.json +5 -5
- package/Components/PlayerContainer/ErrorDisplay/ErrorDisplay.tsx +0 -57
- package/Components/PlayerContainer/ErrorDisplay/index.ts +0 -9
- package/Components/River/TV/withTVEventHandler.tsx +0 -27
|
@@ -7,15 +7,30 @@ import { UrlFeedResolver } from "../resolvers/UrlFeedResolver";
|
|
|
7
7
|
import { NullFeedResolver } from "../resolvers/NullFeedResolver";
|
|
8
8
|
|
|
9
9
|
jest.mock("../resolvers/StaticFeedResolver", () => ({
|
|
10
|
-
StaticFeedResolver: jest.fn(() =>
|
|
10
|
+
StaticFeedResolver: jest.fn(({ children }) =>
|
|
11
|
+
children({
|
|
12
|
+
zappPipesData: { loading: true, data: null, error: null },
|
|
13
|
+
reloadData: jest.fn(),
|
|
14
|
+
})
|
|
15
|
+
),
|
|
11
16
|
}));
|
|
12
17
|
|
|
13
18
|
jest.mock("../resolvers/UrlFeedResolver", () => ({
|
|
14
|
-
UrlFeedResolver: jest.fn(() =>
|
|
19
|
+
UrlFeedResolver: jest.fn(({ children }) =>
|
|
20
|
+
children({
|
|
21
|
+
zappPipesData: { loading: true, data: null, error: null },
|
|
22
|
+
reloadData: jest.fn(),
|
|
23
|
+
})
|
|
24
|
+
),
|
|
15
25
|
}));
|
|
16
26
|
|
|
17
27
|
jest.mock("../resolvers/NullFeedResolver", () => ({
|
|
18
|
-
NullFeedResolver: jest.fn(() =>
|
|
28
|
+
NullFeedResolver: jest.fn(({ children }) =>
|
|
29
|
+
children({
|
|
30
|
+
zappPipesData: { loading: false, data: null, error: null },
|
|
31
|
+
reloadData: jest.fn(),
|
|
32
|
+
})
|
|
33
|
+
),
|
|
19
34
|
}));
|
|
20
35
|
|
|
21
36
|
const testPlugin = {
|
|
@@ -52,7 +67,7 @@ describe("ResolverSelector", () => {
|
|
|
52
67
|
expect.objectContaining({
|
|
53
68
|
getStaticComponentFeed: props.getStaticComponentFeed,
|
|
54
69
|
component: mockComponent,
|
|
55
|
-
children:
|
|
70
|
+
children: expect.any(Function),
|
|
56
71
|
}),
|
|
57
72
|
expect.anything()
|
|
58
73
|
);
|
|
@@ -151,7 +166,10 @@ describe("ResolverSelector", () => {
|
|
|
151
166
|
render(<ResolverSelector {...props} />);
|
|
152
167
|
|
|
153
168
|
expect(StaticFeedResolver).toHaveBeenCalledWith(
|
|
154
|
-
expect.objectContaining(
|
|
169
|
+
expect.objectContaining({
|
|
170
|
+
...props,
|
|
171
|
+
children: expect.any(Function),
|
|
172
|
+
}),
|
|
155
173
|
expect.anything()
|
|
156
174
|
);
|
|
157
175
|
});
|
|
@@ -202,4 +220,193 @@ describe("ResolverSelector", () => {
|
|
|
202
220
|
expect(UrlFeedResolver).not.toHaveBeenCalled();
|
|
203
221
|
expect(NullFeedResolver).not.toHaveBeenCalled();
|
|
204
222
|
});
|
|
223
|
+
|
|
224
|
+
describe("Fallback Logic", () => {
|
|
225
|
+
it("should fallback to UrlFeedResolver when StaticFeedResolver returns null and feedUrl is present", () => {
|
|
226
|
+
const props = {
|
|
227
|
+
getStaticComponentFeed: jest.fn(),
|
|
228
|
+
feedUrl: "https://example.com/feed",
|
|
229
|
+
component: mockComponent,
|
|
230
|
+
children: mockChildren,
|
|
231
|
+
riverId: "test-river",
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
(StaticFeedResolver as jest.Mock).mockImplementation(({ children }) =>
|
|
235
|
+
children({
|
|
236
|
+
zappPipesData: { loading: false, data: null, error: null },
|
|
237
|
+
reloadData: jest.fn(),
|
|
238
|
+
})
|
|
239
|
+
);
|
|
240
|
+
|
|
241
|
+
render(<ResolverSelector {...props} />);
|
|
242
|
+
|
|
243
|
+
expect(StaticFeedResolver).toHaveBeenCalled();
|
|
244
|
+
|
|
245
|
+
expect(UrlFeedResolver).toHaveBeenCalledWith(
|
|
246
|
+
expect.objectContaining({
|
|
247
|
+
feedUrl: props.feedUrl,
|
|
248
|
+
component: mockComponent,
|
|
249
|
+
children: mockChildren,
|
|
250
|
+
}),
|
|
251
|
+
expect.anything()
|
|
252
|
+
);
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
it("should fallback to UrlFeedResolver when StaticFeedResolver returns null and component.data.source is present", () => {
|
|
256
|
+
const componentWithSource = {
|
|
257
|
+
...mockComponent,
|
|
258
|
+
data: {
|
|
259
|
+
source: "data-source",
|
|
260
|
+
},
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
const props = {
|
|
264
|
+
getStaticComponentFeed: jest.fn(),
|
|
265
|
+
component: componentWithSource,
|
|
266
|
+
children: mockChildren,
|
|
267
|
+
riverId: "test-river",
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
(StaticFeedResolver as jest.Mock).mockImplementation(({ children }) =>
|
|
271
|
+
children({
|
|
272
|
+
zappPipesData: { loading: false, data: null, error: null },
|
|
273
|
+
reloadData: jest.fn(),
|
|
274
|
+
})
|
|
275
|
+
);
|
|
276
|
+
|
|
277
|
+
render(<ResolverSelector {...props} />);
|
|
278
|
+
|
|
279
|
+
expect(StaticFeedResolver).toHaveBeenCalled();
|
|
280
|
+
|
|
281
|
+
expect(UrlFeedResolver).toHaveBeenCalledWith(
|
|
282
|
+
expect.objectContaining({
|
|
283
|
+
component: componentWithSource,
|
|
284
|
+
children: mockChildren,
|
|
285
|
+
}),
|
|
286
|
+
expect.anything()
|
|
287
|
+
);
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
it("should fallback to NullFeedResolver when StaticFeedResolver returns null and no feedUrl/source is present", () => {
|
|
291
|
+
const props = {
|
|
292
|
+
getStaticComponentFeed: jest.fn(),
|
|
293
|
+
component: mockComponent,
|
|
294
|
+
children: mockChildren,
|
|
295
|
+
riverId: "test-river",
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
(StaticFeedResolver as jest.Mock).mockImplementation(({ children }) =>
|
|
299
|
+
children({
|
|
300
|
+
zappPipesData: { loading: false, data: null, error: null },
|
|
301
|
+
reloadData: jest.fn(),
|
|
302
|
+
})
|
|
303
|
+
);
|
|
304
|
+
|
|
305
|
+
render(<ResolverSelector {...props} />);
|
|
306
|
+
|
|
307
|
+
expect(StaticFeedResolver).toHaveBeenCalled();
|
|
308
|
+
expect(UrlFeedResolver).not.toHaveBeenCalled();
|
|
309
|
+
|
|
310
|
+
expect(NullFeedResolver).toHaveBeenCalledWith(
|
|
311
|
+
expect.objectContaining({
|
|
312
|
+
children: mockChildren,
|
|
313
|
+
}),
|
|
314
|
+
expect.anything()
|
|
315
|
+
);
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
it("should NOT fallback and call children with static data when StaticFeedResolver returns data", () => {
|
|
319
|
+
const staticData = { entry: [{ id: "1" }] };
|
|
320
|
+
|
|
321
|
+
const props = {
|
|
322
|
+
getStaticComponentFeed: jest.fn(),
|
|
323
|
+
feedUrl: "https://example.com/feed",
|
|
324
|
+
component: mockComponent,
|
|
325
|
+
children: mockChildren,
|
|
326
|
+
riverId: "test-river",
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
(StaticFeedResolver as jest.Mock).mockImplementation(({ children }) =>
|
|
330
|
+
children({
|
|
331
|
+
zappPipesData: { loading: false, data: staticData, error: null },
|
|
332
|
+
reloadData: jest.fn(),
|
|
333
|
+
})
|
|
334
|
+
);
|
|
335
|
+
|
|
336
|
+
render(<ResolverSelector {...props} />);
|
|
337
|
+
|
|
338
|
+
expect(StaticFeedResolver).toHaveBeenCalled();
|
|
339
|
+
expect(UrlFeedResolver).not.toHaveBeenCalled();
|
|
340
|
+
|
|
341
|
+
expect(mockChildren).toHaveBeenCalledWith(
|
|
342
|
+
expect.objectContaining({
|
|
343
|
+
zappPipesData: expect.objectContaining({
|
|
344
|
+
data: staticData,
|
|
345
|
+
}),
|
|
346
|
+
})
|
|
347
|
+
);
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
it("should NOT fallback and call children with loading state when StaticFeedResolver is loading", () => {
|
|
351
|
+
const props = {
|
|
352
|
+
getStaticComponentFeed: jest.fn(),
|
|
353
|
+
feedUrl: "https://example.com/feed",
|
|
354
|
+
component: mockComponent,
|
|
355
|
+
children: mockChildren,
|
|
356
|
+
riverId: "test-river",
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
(StaticFeedResolver as jest.Mock).mockImplementation(({ children }) =>
|
|
360
|
+
children({
|
|
361
|
+
zappPipesData: { loading: true, data: null, error: null },
|
|
362
|
+
reloadData: jest.fn(),
|
|
363
|
+
})
|
|
364
|
+
);
|
|
365
|
+
|
|
366
|
+
render(<ResolverSelector {...props} />);
|
|
367
|
+
|
|
368
|
+
expect(StaticFeedResolver).toHaveBeenCalled();
|
|
369
|
+
expect(UrlFeedResolver).not.toHaveBeenCalled();
|
|
370
|
+
|
|
371
|
+
expect(mockChildren).toHaveBeenCalledWith(
|
|
372
|
+
expect.objectContaining({
|
|
373
|
+
zappPipesData: expect.objectContaining({
|
|
374
|
+
loading: true,
|
|
375
|
+
}),
|
|
376
|
+
})
|
|
377
|
+
);
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
it("should NOT fallback and call children with error when StaticFeedResolver returns error", () => {
|
|
381
|
+
const error = new Error("Static error");
|
|
382
|
+
|
|
383
|
+
const props = {
|
|
384
|
+
getStaticComponentFeed: jest.fn(),
|
|
385
|
+
feedUrl: "https://example.com/feed",
|
|
386
|
+
component: mockComponent,
|
|
387
|
+
children: mockChildren,
|
|
388
|
+
riverId: "test-river",
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
(StaticFeedResolver as jest.Mock).mockImplementation(({ children }) =>
|
|
392
|
+
children({
|
|
393
|
+
zappPipesData: { loading: false, data: null, error },
|
|
394
|
+
reloadData: jest.fn(),
|
|
395
|
+
})
|
|
396
|
+
);
|
|
397
|
+
|
|
398
|
+
render(<ResolverSelector {...props} />);
|
|
399
|
+
|
|
400
|
+
expect(StaticFeedResolver).toHaveBeenCalled();
|
|
401
|
+
expect(UrlFeedResolver).not.toHaveBeenCalled();
|
|
402
|
+
|
|
403
|
+
expect(mockChildren).toHaveBeenCalledWith(
|
|
404
|
+
expect.objectContaining({
|
|
405
|
+
zappPipesData: expect.objectContaining({
|
|
406
|
+
error,
|
|
407
|
+
}),
|
|
408
|
+
})
|
|
409
|
+
);
|
|
410
|
+
});
|
|
411
|
+
});
|
|
205
412
|
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import * as useFeedLoaderModule from "@applicaster/zapp-react-native-utils/reactHooks/feed/useFeedLoader";
|
|
3
|
-
import * as useFeedRefreshModule from "@applicaster/zapp-react-native-utils/reactHooks/feed/useFeedRefresh";
|
|
4
3
|
import { favoritesListener } from "@applicaster/zapp-react-native-bridge/Favorites";
|
|
5
4
|
import { UrlFeedResolver } from "../resolvers/UrlFeedResolver";
|
|
6
5
|
import { renderWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
|
|
@@ -14,10 +13,6 @@ jest
|
|
|
14
13
|
|
|
15
14
|
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/feed/useFeedLoader");
|
|
16
15
|
|
|
17
|
-
jest.mock(
|
|
18
|
-
"@applicaster/zapp-react-native-utils/reactHooks/feed/useFeedRefresh"
|
|
19
|
-
);
|
|
20
|
-
|
|
21
16
|
jest.mock("@applicaster/zapp-pipes-v2-client");
|
|
22
17
|
|
|
23
18
|
jest.mock("@applicaster/zapp-react-native-bridge/Favorites", () => ({
|
|
@@ -62,6 +57,9 @@ describe("UrlFeedResolver", () => {
|
|
|
62
57
|
component: { ...componentRequiredKeys } as any,
|
|
63
58
|
children: mockChildren,
|
|
64
59
|
riverId: "test-river",
|
|
60
|
+
screenContext: {
|
|
61
|
+
id: "screenId",
|
|
62
|
+
},
|
|
65
63
|
};
|
|
66
64
|
|
|
67
65
|
renderWithProviders(<UrlFeedResolver {...props} />);
|
|
@@ -82,6 +80,9 @@ describe("UrlFeedResolver", () => {
|
|
|
82
80
|
} as any,
|
|
83
81
|
children: mockChildren,
|
|
84
82
|
riverId: "test-river",
|
|
83
|
+
screenContext: {
|
|
84
|
+
id: "screenId",
|
|
85
|
+
},
|
|
85
86
|
};
|
|
86
87
|
|
|
87
88
|
renderWithProviders(<UrlFeedResolver {...props} />);
|
|
@@ -103,6 +104,9 @@ describe("UrlFeedResolver", () => {
|
|
|
103
104
|
} as any,
|
|
104
105
|
children: mockChildren,
|
|
105
106
|
riverId: "test-river",
|
|
107
|
+
screenContext: {
|
|
108
|
+
id: "screenId",
|
|
109
|
+
},
|
|
106
110
|
};
|
|
107
111
|
|
|
108
112
|
renderWithProviders(<UrlFeedResolver {...props} />);
|
|
@@ -132,6 +136,9 @@ describe("UrlFeedResolver", () => {
|
|
|
132
136
|
} as any,
|
|
133
137
|
children: mockChildren,
|
|
134
138
|
riverId: "test-river",
|
|
139
|
+
screenContext: {
|
|
140
|
+
id: "screenId",
|
|
141
|
+
},
|
|
135
142
|
};
|
|
136
143
|
|
|
137
144
|
renderWithProviders(<UrlFeedResolver {...props} />);
|
|
@@ -155,6 +162,9 @@ describe("UrlFeedResolver", () => {
|
|
|
155
162
|
children: mockChildren,
|
|
156
163
|
riverId: "test-river",
|
|
157
164
|
plugins: [],
|
|
165
|
+
screenContext: {
|
|
166
|
+
id: "screenId",
|
|
167
|
+
},
|
|
158
168
|
};
|
|
159
169
|
|
|
160
170
|
renderWithProviders(<UrlFeedResolver {...props} />);
|
|
@@ -173,6 +183,9 @@ describe("UrlFeedResolver", () => {
|
|
|
173
183
|
component: { ...componentRequiredKeys } as any,
|
|
174
184
|
children: mockChildren,
|
|
175
185
|
riverId: "test-river",
|
|
186
|
+
screenContext: {
|
|
187
|
+
id: "screenId",
|
|
188
|
+
},
|
|
176
189
|
};
|
|
177
190
|
|
|
178
191
|
renderWithProviders(<UrlFeedResolver {...props} />);
|
|
@@ -197,6 +210,9 @@ describe("UrlFeedResolver", () => {
|
|
|
197
210
|
},
|
|
198
211
|
},
|
|
199
212
|
] as any,
|
|
213
|
+
screenContext: {
|
|
214
|
+
id: "screenId",
|
|
215
|
+
},
|
|
200
216
|
};
|
|
201
217
|
|
|
202
218
|
renderWithProviders(<UrlFeedResolver {...props} />);
|
|
@@ -215,6 +231,9 @@ describe("UrlFeedResolver", () => {
|
|
|
215
231
|
} as any,
|
|
216
232
|
children: mockChildren,
|
|
217
233
|
riverId: "test-river",
|
|
234
|
+
screenContext: {
|
|
235
|
+
id: "screenId",
|
|
236
|
+
},
|
|
218
237
|
};
|
|
219
238
|
|
|
220
239
|
(useFeedLoaderModule.useFeedLoader as jest.Mock).mockReturnValue({
|
|
@@ -250,6 +269,9 @@ describe("UrlFeedResolver", () => {
|
|
|
250
269
|
children: mockChildren,
|
|
251
270
|
riverId: "test-river",
|
|
252
271
|
isLast: true,
|
|
272
|
+
screenContext: {
|
|
273
|
+
id: "screenId",
|
|
274
|
+
},
|
|
253
275
|
};
|
|
254
276
|
|
|
255
277
|
renderWithProviders(<UrlFeedResolver {...props1} />);
|
|
@@ -272,6 +294,9 @@ describe("UrlFeedResolver", () => {
|
|
|
272
294
|
children: mockChildren,
|
|
273
295
|
riverId: "test-river",
|
|
274
296
|
isLast: false,
|
|
297
|
+
screenContext: {
|
|
298
|
+
id: "screenId",
|
|
299
|
+
},
|
|
275
300
|
};
|
|
276
301
|
|
|
277
302
|
renderWithProviders(<UrlFeedResolver {...props2} />);
|
|
@@ -294,6 +319,9 @@ describe("UrlFeedResolver", () => {
|
|
|
294
319
|
children: mockChildren,
|
|
295
320
|
riverId: "test-river",
|
|
296
321
|
isLast: false,
|
|
322
|
+
screenContext: {
|
|
323
|
+
id: "screenId",
|
|
324
|
+
},
|
|
297
325
|
};
|
|
298
326
|
|
|
299
327
|
renderWithProviders(<UrlFeedResolver {...props3} />);
|
|
@@ -311,6 +339,9 @@ describe("UrlFeedResolver", () => {
|
|
|
311
339
|
component: { ...componentRequiredKeys } as any,
|
|
312
340
|
children: mockChildren,
|
|
313
341
|
riverId: "test-river",
|
|
342
|
+
screenContext: {
|
|
343
|
+
id: "screenId",
|
|
344
|
+
},
|
|
314
345
|
};
|
|
315
346
|
|
|
316
347
|
renderWithProviders(<UrlFeedResolver {...props} />);
|
|
@@ -327,22 +358,6 @@ describe("UrlFeedResolver", () => {
|
|
|
327
358
|
});
|
|
328
359
|
});
|
|
329
360
|
|
|
330
|
-
it("should apply feed refresh hook", () => {
|
|
331
|
-
const props = {
|
|
332
|
-
feedUrl: "https://example.com/feed",
|
|
333
|
-
component: { ...componentRequiredKeys } as any,
|
|
334
|
-
children: mockChildren,
|
|
335
|
-
riverId: "test-river",
|
|
336
|
-
};
|
|
337
|
-
|
|
338
|
-
renderWithProviders(<UrlFeedResolver {...props} />);
|
|
339
|
-
|
|
340
|
-
expect(useFeedRefreshModule.useFeedRefresh).toHaveBeenCalledWith({
|
|
341
|
-
reloadData: mockReloadData,
|
|
342
|
-
component: props.component,
|
|
343
|
-
});
|
|
344
|
-
});
|
|
345
|
-
|
|
346
361
|
it("should clean up listeners on unmount", () => {
|
|
347
362
|
const props = {
|
|
348
363
|
component: {
|
|
@@ -354,6 +369,9 @@ describe("UrlFeedResolver", () => {
|
|
|
354
369
|
} as any,
|
|
355
370
|
children: mockChildren,
|
|
356
371
|
riverId: "test-river",
|
|
372
|
+
screenContext: {
|
|
373
|
+
id: "screenId",
|
|
374
|
+
},
|
|
357
375
|
};
|
|
358
376
|
|
|
359
377
|
const { unmount } = renderWithProviders(<UrlFeedResolver {...props} />);
|
|
@@ -3,7 +3,7 @@ import { renderWithProviders } from "@applicaster/zapp-react-native-utils/testUt
|
|
|
3
3
|
|
|
4
4
|
import * as zappPipesRedux from "@applicaster/zapp-react-native-redux/ZappPipes";
|
|
5
5
|
import configureStore from "redux-mock-store";
|
|
6
|
-
import thunk from "redux-thunk";
|
|
6
|
+
import { thunk } from "redux-thunk";
|
|
7
7
|
|
|
8
8
|
import { zappPipesDataConnector } from "../index";
|
|
9
9
|
|
|
@@ -9,9 +9,9 @@ import {
|
|
|
9
9
|
getInflatedDataSourceUrl,
|
|
10
10
|
getSearchContext,
|
|
11
11
|
useFeedLoader,
|
|
12
|
-
useFeedRefresh,
|
|
13
12
|
useRoute,
|
|
14
13
|
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
14
|
+
import { refreshCoordinator } from "@applicaster/zapp-react-native-utils/refreshUtils/RefreshCoordinator";
|
|
15
15
|
|
|
16
16
|
import { ComponentDataSourceContext, ZappPipesDataProps } from "../types";
|
|
17
17
|
import { useScreenStateStore } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useScreenStateStore";
|
|
@@ -199,6 +199,8 @@ export function UrlFeedResolver({
|
|
|
199
199
|
const { pathname } = useRoute();
|
|
200
200
|
const screenStateStore = useScreenStateStore();
|
|
201
201
|
|
|
202
|
+
const screenId = (screenContext?.id || "unknown_screen_id") as string;
|
|
203
|
+
|
|
202
204
|
// Setup listeners for data source URL
|
|
203
205
|
useEffect(() => {
|
|
204
206
|
if (!reloadData) {
|
|
@@ -214,10 +216,19 @@ export function UrlFeedResolver({
|
|
|
214
216
|
url: dataSourceUrl,
|
|
215
217
|
pathname,
|
|
216
218
|
screenStateStore,
|
|
219
|
+
component,
|
|
220
|
+
screenId,
|
|
217
221
|
callback: reloadData,
|
|
218
222
|
});
|
|
219
223
|
}
|
|
220
|
-
}, [
|
|
224
|
+
}, [
|
|
225
|
+
dataSourceUrl,
|
|
226
|
+
reloadData,
|
|
227
|
+
pathname,
|
|
228
|
+
screenStateStore,
|
|
229
|
+
component,
|
|
230
|
+
screenId,
|
|
231
|
+
]);
|
|
221
232
|
|
|
222
233
|
// Setup favorites listener
|
|
223
234
|
useEffect(() => {
|
|
@@ -230,11 +241,11 @@ export function UrlFeedResolver({
|
|
|
230
241
|
}
|
|
231
242
|
}, [type, reloadData]);
|
|
232
243
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
});
|
|
244
|
+
useEffect(() => {
|
|
245
|
+
const unregister = refreshCoordinator.register(component, screenId);
|
|
246
|
+
|
|
247
|
+
return () => unregister();
|
|
248
|
+
}, [component, screenId]);
|
|
238
249
|
|
|
239
250
|
const loadNextData = useMemo(
|
|
240
251
|
() => (!isLast && isVerticalListOrGrid(component) ? undefined : loadNext),
|
package/events/index.ts
CHANGED
|
@@ -5,4 +5,7 @@ export enum QBUIComponentEvents {
|
|
|
5
5
|
scrollVerticallyToInitialOffset = "scrollVerticallyToInitialOffset",
|
|
6
6
|
focusOnSelectedTab = "focusOnSelectedTab",
|
|
7
7
|
focusOnSelectedTopMenuItem = "focusOnSelectedTopMenuItem",
|
|
8
|
+
scrollToTopForScreenWrappedInContainer = "scrollToTopForScreenWrappedInContainer",
|
|
8
9
|
}
|
|
10
|
+
|
|
11
|
+
export { scrollEndReached$, emitScrollEndReached } from "./scrollEndReached";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Subject } from "rxjs";
|
|
2
|
+
import { throttleTime } from "rxjs/operators";
|
|
3
|
+
|
|
4
|
+
const SCROLL_END_THROTTLE_MS = 1000;
|
|
5
|
+
const scrollEndReachedSubject = new Subject<void>();
|
|
6
|
+
|
|
7
|
+
/* Throttle so we only emit at most once per second; RN often fires onEndReached repeatedly (e.g. on Android) when near the bottom. */
|
|
8
|
+
export const scrollEndReached$ = scrollEndReachedSubject.pipe(
|
|
9
|
+
throttleTime(SCROLL_END_THROTTLE_MS)
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
/* Call from scroll container (ComponentsMap or Tabs) when scroll reaches end. */
|
|
13
|
+
export const emitScrollEndReached = (): void => {
|
|
14
|
+
scrollEndReachedSubject.next();
|
|
15
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-ui-components",
|
|
3
|
-
"version": "15.0.0-alpha.
|
|
3
|
+
"version": "15.0.0-alpha.9102777840",
|
|
4
4
|
"description": "Applicaster Zapp React Native ui components for the Quick Brick App",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@applicaster/applicaster-types": "15.0.0-alpha.
|
|
32
|
-
"@applicaster/zapp-react-native-bridge": "15.0.0-alpha.
|
|
33
|
-
"@applicaster/zapp-react-native-redux": "15.0.0-alpha.
|
|
34
|
-
"@applicaster/zapp-react-native-utils": "15.0.0-alpha.
|
|
31
|
+
"@applicaster/applicaster-types": "15.0.0-alpha.9102777840",
|
|
32
|
+
"@applicaster/zapp-react-native-bridge": "15.0.0-alpha.9102777840",
|
|
33
|
+
"@applicaster/zapp-react-native-redux": "15.0.0-alpha.9102777840",
|
|
34
|
+
"@applicaster/zapp-react-native-utils": "15.0.0-alpha.9102777840",
|
|
35
35
|
"fast-json-stable-stringify": "^2.1.0",
|
|
36
36
|
"promise": "^8.3.0",
|
|
37
37
|
"url": "^0.11.0",
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import * as R from "ramda";
|
|
3
|
-
import { Text, TextStyle, View, ViewStyle } from "react-native";
|
|
4
|
-
|
|
5
|
-
import { getLocalizations } from "@applicaster/zapp-react-native-utils/localizationUtils";
|
|
6
|
-
import { getAppStylesColor } from "@applicaster/zapp-react-native-utils/stylesUtils";
|
|
7
|
-
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
8
|
-
import { styleKeys } from "@applicaster/zapp-react-native-utils/styleKeysUtils";
|
|
9
|
-
|
|
10
|
-
type Props = {
|
|
11
|
-
styles: {};
|
|
12
|
-
error: {};
|
|
13
|
-
remoteConfigurations: { localizations: {} };
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const defaultAppStyles = {
|
|
17
|
-
loading_error_label: {
|
|
18
|
-
color: "#aaa",
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const textStyles = (appStyles = defaultAppStyles): TextStyle => ({
|
|
23
|
-
color: getAppStylesColor("loading_error_label", appStyles),
|
|
24
|
-
fontSize: 36,
|
|
25
|
-
textAlign: "center",
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
const errorStyles = ({ backgroundColor }): ViewStyle => ({
|
|
29
|
-
flex: 1,
|
|
30
|
-
width: "100%",
|
|
31
|
-
height: "100%",
|
|
32
|
-
justifyContent: "center",
|
|
33
|
-
alignItems: "center",
|
|
34
|
-
position: "absolute",
|
|
35
|
-
zIndex: 100,
|
|
36
|
-
backgroundColor,
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
export function ErrorDisplayComponent({
|
|
40
|
-
styles,
|
|
41
|
-
remoteConfigurations: { localizations },
|
|
42
|
-
}: Props) {
|
|
43
|
-
const theme = useTheme();
|
|
44
|
-
const backgroundColor = theme?.app_background_color;
|
|
45
|
-
|
|
46
|
-
const { stream_error_message = "Cannot play stream" } = getLocalizations({
|
|
47
|
-
localizations,
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
const appStyles = R.prop(styleKeys.style_namespace, styles);
|
|
51
|
-
|
|
52
|
-
return (
|
|
53
|
-
<View style={errorStyles({ backgroundColor })}>
|
|
54
|
-
<Text style={textStyles(appStyles)}>{stream_error_message}</Text>
|
|
55
|
-
</View>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as R from "ramda";
|
|
2
|
-
|
|
3
|
-
import { connectToStore } from "@applicaster/zapp-react-native-redux/utils/connectToStore";
|
|
4
|
-
|
|
5
|
-
import { ErrorDisplayComponent } from "./ErrorDisplay";
|
|
6
|
-
|
|
7
|
-
export const ErrorDisplay = R.compose(
|
|
8
|
-
connectToStore(R.pick(["remoteConfigurations"]))
|
|
9
|
-
)(ErrorDisplayComponent);
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/* eslint max-len: off */
|
|
2
|
-
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { TVEventHandlerComponent } from "@applicaster/zapp-react-native-tvos-ui-components/Components/TVEventHandlerComponent";
|
|
5
|
-
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
6
|
-
|
|
7
|
-
export const withTvEventHandler = (Component) => {
|
|
8
|
-
return function WithTVEventHandler(props) {
|
|
9
|
-
const navigator = useNavigation();
|
|
10
|
-
|
|
11
|
-
const remoteHandler = (event) => {
|
|
12
|
-
const { eventType } = event;
|
|
13
|
-
|
|
14
|
-
const canGoBack = navigator.canGoBack();
|
|
15
|
-
|
|
16
|
-
if (eventType === "menu" && canGoBack) {
|
|
17
|
-
navigator.goBack();
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<TVEventHandlerComponent tvEventHandler={remoteHandler}>
|
|
23
|
-
<Component {...props} />
|
|
24
|
-
</TVEventHandlerComponent>
|
|
25
|
-
);
|
|
26
|
-
};
|
|
27
|
-
};
|