@applicaster/zapp-react-native-ui-components 15.0.0-alpha.5485312433 → 15.0.0-alpha.5531846549

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 (105) hide show
  1. package/Components/GeneralContentScreen/GeneralContentScreen.tsx +39 -28
  2. package/Components/GeneralContentScreen/__tests__/GeneralContentScreen.test.tsx +104 -0
  3. package/Components/GeneralContentScreen/utils/__tests__/getScreenDataSource.test.ts +19 -0
  4. package/Components/GeneralContentScreen/utils/getScreenDataSource.ts +9 -0
  5. package/Components/HandlePlayable/HandlePlayable.tsx +16 -29
  6. package/Components/HandlePlayable/utils.ts +31 -0
  7. package/Components/HookRenderer/HookRenderer.tsx +40 -10
  8. package/Components/HookRenderer/__tests__/HookRenderer.test.tsx +60 -0
  9. package/Components/Layout/TV/NavBarContainer.tsx +1 -10
  10. package/Components/Layout/TV/__tests__/__snapshots__/NavBarContainer.test.tsx.snap +7 -12
  11. package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +7 -12
  12. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/model.test.ts +80 -0
  13. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/placement.test.ts +187 -0
  14. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/selectors.test.ts +45 -0
  15. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/style.test.ts +49 -0
  16. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/model.ts +47 -0
  17. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/placement.ts +170 -0
  18. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/selectors.ts +26 -0
  19. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/style.ts +29 -0
  20. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/types.ts +37 -0
  21. package/Components/MasterCell/DefaultComponents/Button.tsx +0 -15
  22. package/Components/MasterCell/DefaultComponents/LiveImage/__tests__/prepareEntry.test.ts +352 -0
  23. package/Components/MasterCell/DefaultComponents/LiveImage/executePreloadHooks.ts +136 -0
  24. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +33 -16
  25. package/Components/MasterCell/DefaultComponents/PressableView.tsx +261 -0
  26. package/Components/MasterCell/DefaultComponents/Text/index.tsx +2 -6
  27. package/Components/MasterCell/DefaultComponents/index.ts +2 -0
  28. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Asset.ts +42 -0
  29. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Button.ts +127 -0
  30. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/ButtonContainerView.ts +23 -0
  31. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Spacer.ts +16 -0
  32. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/TextLabel.ts +67 -0
  33. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/TextLabelsContainer.ts +32 -0
  34. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/PressableView.test.tsx +195 -0
  35. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/builders.test.ts +140 -0
  36. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/index.test.ts +222 -0
  37. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/helpers.ts +105 -0
  38. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/index.ts +104 -0
  39. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/__tests__/insertButtons.test.ts +118 -0
  40. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/index.ts +73 -0
  41. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/__tests__/index.test.ts +86 -0
  42. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/index.ts +35 -52
  43. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/__tests__/getPluginIdentifier.test.ts +35 -171
  44. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/index.ts +36 -145
  45. package/Components/MasterCell/elementMapper.tsx +1 -0
  46. package/Components/PlayerContainer/PlayerContainer.tsx +1 -18
  47. package/Components/PreloaderWrapper/__tests__/index.test.tsx +26 -0
  48. package/Components/PreloaderWrapper/index.tsx +15 -0
  49. package/Components/River/ComponentsMap/ComponentsMap.tsx +18 -16
  50. package/Components/River/RefreshControl.tsx +19 -83
  51. package/Components/River/River.tsx +9 -82
  52. package/Components/River/RiverItem.tsx +26 -20
  53. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +2 -0
  54. package/Components/River/__tests__/componentsMap.test.js +38 -0
  55. package/Components/River/hooks/__tests__/usePullToRefresh.test.ts +132 -0
  56. package/Components/River/hooks/index.ts +1 -0
  57. package/Components/River/hooks/usePullToRefresh.ts +51 -0
  58. package/Components/Screen/__tests__/Screen.test.tsx +1 -0
  59. package/Components/Screen/hooks.ts +73 -3
  60. package/Components/Screen/index.tsx +7 -1
  61. package/Components/ScreenFeedLoader/ScreenFeedLoader.tsx +46 -0
  62. package/Components/ScreenFeedLoader/__tests__/ScreenFeedLoader.test.tsx +94 -0
  63. package/Components/ScreenFeedLoader/index.ts +1 -0
  64. package/Components/ScreenResolver/__tests__/screenResolver.test.js +24 -0
  65. package/Components/ScreenResolver/hooks/index.ts +3 -0
  66. package/Components/ScreenResolver/hooks/useGetComponent.ts +15 -0
  67. package/Components/ScreenResolver/hooks/useScreenComponentResolver.tsx +90 -0
  68. package/Components/ScreenResolver/index.tsx +15 -117
  69. package/Components/ScreenResolver/utils/__tests__/getScreenTypeProps.test.ts +45 -0
  70. package/Components/ScreenResolver/utils/getScreenTypeProps.ts +43 -0
  71. package/Components/ScreenResolver/utils/index.ts +1 -0
  72. package/Components/ScreenResolver/withDefaultScreenContext.tsx +16 -0
  73. package/Components/ScreenResolverFeedProvider/ScreenResolverFeedProvider.tsx +25 -0
  74. package/Components/ScreenResolverFeedProvider/__tests__/ScreenResolverFeedProvider.test.tsx +44 -0
  75. package/Components/ScreenResolverFeedProvider/index.ts +1 -0
  76. package/Components/Tabs/TabContent.tsx +7 -4
  77. package/Components/TopCutoffOverlay/hooks/__tests__/useMarginTop.test.ts +130 -0
  78. package/Components/TopCutoffOverlay/hooks/index.ts +1 -0
  79. package/Components/TopCutoffOverlay/hooks/useMarginTop.ts +59 -0
  80. package/Components/TopCutoffOverlay/index.tsx +55 -0
  81. package/Components/Transitioner/Scene.tsx +9 -15
  82. package/Components/VideoLive/LiveImageManager.ts +199 -54
  83. package/Components/VideoLive/PlayerLiveImageComponent.tsx +31 -33
  84. package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +2 -17
  85. package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +0 -2
  86. package/Components/Viewport/ViewportAware/index.tsx +16 -7
  87. package/Components/ZappUIComponent/index.tsx +12 -6
  88. package/Components/default-cell-renderer/viewTrees/mobile/index.ts +0 -3
  89. package/Components/index.js +1 -1
  90. package/Contexts/ScreenContext/__tests__/index.test.tsx +57 -0
  91. package/Contexts/ScreenContext/index.tsx +71 -19
  92. package/Contexts/ZappPipesContext/ZappPipesContextFactory.tsx +18 -7
  93. package/Decorators/ZappPipesDataConnector/ResolverSelector.tsx +25 -7
  94. package/Decorators/ZappPipesDataConnector/__tests__/ResolverSelector.test.tsx +212 -5
  95. package/Decorators/ZappPipesDataConnector/__tests__/UrlFeedResolver.test.tsx +39 -21
  96. package/Decorators/ZappPipesDataConnector/resolvers/UrlFeedResolver.tsx +18 -7
  97. package/events/index.ts +2 -0
  98. package/events/scrollEndReached.ts +15 -0
  99. package/package.json +5 -5
  100. package/Components/MasterCell/DefaultComponents/Text/utils/__tests__/withAdjustedLineHeight.test.ts +0 -46
  101. package/Components/MasterCell/DefaultComponents/Text/utils/index.ts +0 -21
  102. package/Components/PlayerContainer/ErrorDisplay/ErrorDisplay.tsx +0 -57
  103. package/Components/PlayerContainer/ErrorDisplay/index.ts +0 -9
  104. package/Components/PlayerContainer/useRestrictMobilePlayback.tsx +0 -101
  105. /package/Components/HookRenderer/{index.tsx → index.ts} +0 -0
@@ -23,6 +23,7 @@ import { isLast } from "@applicaster/zapp-react-native-utils/arrayUtils";
23
23
  import { withComponentsMapProvider } from "@applicaster/zapp-react-native-ui-components/Decorators/ComponentsMapWrapper";
24
24
  import { useScreenContextV2 } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
25
25
  import { useShallow } from "zustand/react/shallow";
26
+ import { emitScrollEndReached } from "@applicaster/zapp-react-native-ui-components/events";
26
27
 
27
28
  import { isAndroidPlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
28
29
  import { ComponentsMapHeightContext } from "./ContextProviders/ComponentsMapHeightContext";
@@ -38,8 +39,6 @@ type Props = {
38
39
  scrollViewExtraProps?: {};
39
40
  riverId?: string;
40
41
  getStaticComponentFeed: any;
41
- pullToRefreshPipesV1RefreshingStateUpdater: () => boolean;
42
- refreshingPipesV1?: boolean;
43
42
  stickyHeaderIndices?: number[];
44
43
  };
45
44
 
@@ -64,15 +63,12 @@ function ComponentsMapComponent(props: Props) {
64
63
  groupId,
65
64
  riverId,
66
65
  getStaticComponentFeed,
67
- // Method added to keep pipes v1 logic up to date with the pullToRefresh state.
68
- // TODO: Remove when pipes v1 is deprecated.
69
- pullToRefreshPipesV1RefreshingStateUpdater,
70
- refreshingPipesV1,
71
66
  stickyHeaderIndices,
72
67
  } = props;
73
68
 
74
69
  const flatListRef = React.useRef<FlatList | null>(null);
75
70
  const flatListWrapperRef = React.useRef<View | null>(null);
71
+ const hasUserScrolledRef = React.useRef(false);
76
72
  const screenConfig = useScreenConfiguration(riverId);
77
73
  const screenData = useScreenData(riverId);
78
74
  const pullToRefreshEnabled = screenData?.rules?.pull_to_refresh_enabled;
@@ -161,16 +157,8 @@ function ComponentsMapComponent(props: Props) {
161
157
  usePipesCacheReset(riverId, riverComponents);
162
158
 
163
159
  const refreshControl = React.useMemo(
164
- () =>
165
- pullToRefreshEnabled ? (
166
- <RefreshControl
167
- pullToRefreshPipesV1RefreshingStateUpdater={
168
- pullToRefreshPipesV1RefreshingStateUpdater
169
- }
170
- refreshingPipesV1={refreshingPipesV1}
171
- />
172
- ) : null,
173
- []
160
+ () => (pullToRefreshEnabled ? <RefreshControl /> : null),
161
+ [pullToRefreshEnabled]
174
162
  );
175
163
 
176
164
  const navBarStore = useScreenContextV2()._navBarStore;
@@ -236,6 +224,8 @@ function ComponentsMapComponent(props: Props) {
236
224
  }, []);
237
225
 
238
226
  const onScroll = React.useCallback((event) => {
227
+ hasUserScrolledRef.current = true;
228
+
239
229
  const {
240
230
  nativeEvent: {
241
231
  contentOffset: { y },
@@ -277,6 +267,7 @@ function ComponentsMapComponent(props: Props) {
277
267
  >
278
268
  <ViewportTracker>
279
269
  <FlatList
270
+ testID="components-map-flat-list"
280
271
  ref={(ref) => {
281
272
  flatListRef.current = ref;
282
273
  }}
@@ -308,6 +299,17 @@ function ComponentsMapComponent(props: Props) {
308
299
  onScrollEndDrag={_onScrollEndDrag}
309
300
  scrollEventThrottle={16}
310
301
  {...scrollViewExtraProps}
302
+ onEndReached={
303
+ /* When wrapped in a parent ScrollView (e.g. tabs),
304
+ this FlatList doesn't scroll so onEndReached can fire repeatedly;
305
+ skip it here and let the parent ScrollView emit scroll-end instead. */
306
+ isScreenWrappedInContainer
307
+ ? undefined
308
+ : () => {
309
+ if (!hasUserScrolledRef.current) return;
310
+ emitScrollEndReached();
311
+ }
312
+ }
311
313
  />
312
314
  </ViewportTracker>
313
315
  </ScreenLoadingMeasurements>
@@ -4,7 +4,7 @@ import {
4
4
  RefreshControl as RNRefreshControl,
5
5
  StyleSheet,
6
6
  } from "react-native";
7
- import * as R from "ramda";
7
+ import { get } from "@applicaster/zapp-react-native-utils/utils";
8
8
  import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
9
9
  import { useLocalizedStrings } from "@applicaster/zapp-react-native-utils/localizationUtils";
10
10
  import { useAnalytics } from "@applicaster/zapp-react-native-utils/analyticsUtils";
@@ -13,7 +13,7 @@ import { useCurrentScreenData } from "@applicaster/zapp-react-native-utils/react
13
13
  import { useShallow } from "zustand/react/shallow";
14
14
  import { useScreenContextV2 } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
15
15
  import { useSafeAreaInsets } from "react-native-safe-area-context";
16
- import { useLoadPipesDataDispatch } from "@applicaster/zapp-react-native-utils/reactHooks";
16
+ import { usePullToRefresh } from "./hooks";
17
17
 
18
18
  const BRIGHTNESS_THRESHOLD = 160;
19
19
  const ABOVE_DEFAULT_COLOR = "gray";
@@ -53,62 +53,6 @@ const getBrightness = (RGBcolor) => {
53
53
  );
54
54
  };
55
55
 
56
- export const usePullToRefresh = (
57
- riverComponents,
58
- pullToRefreshPipesV1RefreshingStateUpdater,
59
- refreshingPipesV1
60
- ) => {
61
- const isPipesV1 = !!pullToRefreshPipesV1RefreshingStateUpdater;
62
-
63
- const [refreshing, setRefreshing] = React.useState(false);
64
-
65
- const feeds: string[] =
66
- riverComponents?.map(R.path(["data", "source"])).filter((feed) => !!feed) ??
67
- [];
68
-
69
- const feedsLength = feeds.length;
70
-
71
- const [requestsCompletedCounter, setRequestsCompletedCounter] =
72
- React.useState(0);
73
-
74
- const loadPipesDataDispatcher = useLoadPipesDataDispatch();
75
-
76
- React.useEffect(() => {
77
- // will not work for pipes v1 on 1st level screens
78
- if (refreshing && !isPipesV1) {
79
- feeds.forEach((feed) => {
80
- loadPipesDataDispatcher(feed, {
81
- silentRefresh: true,
82
- clearCache: true,
83
- callback: () => {
84
- setRequestsCompletedCounter(R.inc);
85
- },
86
- });
87
- });
88
- }
89
- }, [refreshing, isPipesV1, feeds, loadPipesDataDispatcher]);
90
-
91
- React.useEffect(() => {
92
- if (requestsCompletedCounter === feedsLength) {
93
- setRefreshing(false);
94
- }
95
- }, [requestsCompletedCounter, feedsLength]);
96
-
97
- const onRefresh = React.useCallback(() => {
98
- if (isPipesV1) {
99
- pullToRefreshPipesV1RefreshingStateUpdater(true);
100
- } else {
101
- setRefreshing(true);
102
- setRequestsCompletedCounter(0);
103
- }
104
- }, [isPipesV1]);
105
-
106
- return {
107
- refreshing: isPipesV1 ? refreshingPipesV1 : refreshing,
108
- onRefresh,
109
- };
110
- };
111
-
112
56
  /** Returns the offset for the progress view of the RefreshControl component
113
57
  * based on navbar content position */
114
58
  export const useGetProgressViewOffset = () => {
@@ -137,16 +81,12 @@ export const useGetProgressViewOffset = () => {
137
81
  }
138
82
  };
139
83
 
140
- export function RefreshControl(props: {
141
- pullToRefreshPipesV1RefreshingStateUpdater?: (refreshing: boolean) => void;
142
- refreshingPipesV1?: boolean;
143
- }) {
84
+ export function RefreshControl() {
144
85
  const screenData = useCurrentScreenData();
145
86
 
146
87
  const { refreshing, onRefresh } = usePullToRefresh(
147
- screenData.ui_components,
148
- props.pullToRefreshPipesV1RefreshingStateUpdater,
149
- props.refreshingPipesV1
88
+ screenData.id,
89
+ screenData.ui_components
150
90
  );
151
91
 
152
92
  const { app_background_color: themeBackgroundColor } = useTheme();
@@ -164,29 +104,26 @@ export function RefreshControl(props: {
164
104
  displayTitleIOS,
165
105
  } = React.useMemo(
166
106
  () => ({
167
- indicatorColor: R.prop(
168
- "pull_to_refresh_indicator_color",
169
- screenData.styles
170
- ),
171
- titleUnderIndicatorColor: R.prop(
172
- "pull_to_refresh_title_color_under_indicator",
173
- screenData.styles
107
+ indicatorColor: get(screenData.styles, "pull_to_refresh_indicator_color"),
108
+ titleUnderIndicatorColor: get(
109
+ screenData.styles,
110
+ "pull_to_refresh_title_color_under_indicator"
174
111
  ),
175
- indicatorBackgroundColor: R.prop(
176
- "pull_to_refresh_indicator_bg_color",
177
- screenData.styles
112
+ indicatorBackgroundColor: get(
113
+ screenData.styles,
114
+ "pull_to_refresh_indicator_bg_color"
178
115
  ),
179
116
  indicatorSize:
180
- R.prop("pull_to_refresh_indicator_size", screenData.styles) === "large"
117
+ get(screenData.styles, "pull_to_refresh_indicator_size") === "large"
181
118
  ? "large"
182
119
  : "default",
183
- generalContentBackgroungColor: R.prop(
184
- "screen_background_color",
185
- screenData.styles
120
+ generalContentBackgroungColor: get(
121
+ screenData.styles,
122
+ "screen_background_color"
186
123
  ),
187
- displayTitleIOS: R.prop(
188
- "pull_to_refresh_display_title_ios",
189
- screenData.styles
124
+ displayTitleIOS: get(
125
+ screenData.styles,
126
+ "pull_to_refresh_display_title_ios"
190
127
  ),
191
128
  }),
192
129
  [screenData]
@@ -253,7 +190,6 @@ export function RefreshControl(props: {
253
190
 
254
191
  return (
255
192
  <RNRefreshControl
256
- {...props}
257
193
  refreshing={refreshing}
258
194
  onRefresh={onRefreshHandler}
259
195
  colors={[preparedIndicatorColor]}
@@ -2,7 +2,6 @@ import * as React from "react";
2
2
  import * as R from "ramda";
3
3
  import { GeneralContentScreen } from "@applicaster/zapp-react-native-ui-components/Components/GeneralContentScreen";
4
4
 
5
- import { FeedLoader } from "../FeedLoader";
6
5
  import { ScreenResolver } from "../ScreenResolver";
7
6
 
8
7
  type Props = ZappScreenProps & {
@@ -23,24 +22,13 @@ type Props = ZappScreenProps & {
23
22
  river: ZappRiver;
24
23
  };
25
24
 
26
- type State = {
27
- refreshing: boolean;
28
- };
29
-
30
- export class RiverComponent extends React.Component<Props, State> {
25
+ export class RiverComponent extends React.Component<Props> {
31
26
  private currentScreenTitle: string;
32
27
  private currentScreenSummary: string;
33
28
  constructor(props: Props) {
34
29
  super(props);
35
30
 
36
- this.state = {
37
- refreshing: false,
38
- };
39
-
40
31
  this.applyContexts();
41
-
42
- this.pullToRefreshPipesV1RefreshingStateUpdater =
43
- this.pullToRefreshPipesV1RefreshingStateUpdater.bind(this);
44
32
  }
45
33
 
46
34
  applyContexts() {
@@ -69,20 +57,9 @@ export class RiverComponent extends React.Component<Props, State> {
69
57
  }
70
58
  }
71
59
 
72
- usesPipesV1Layout() {
73
- return this.props?.appData?.layoutVersion === "v1";
74
- }
75
-
76
- // Method added to keep pipes v1 logic up to date with the pullToRefresh state.
77
- // TODO: Remove when pipes v1 is deprecated.
78
- pullToRefreshPipesV1RefreshingStateUpdater(refreshing) {
79
- this.setState({ refreshing });
80
- }
81
-
82
60
  render() {
83
61
  const {
84
62
  river,
85
- feedUrl,
86
63
  screenData,
87
64
  isInsideContainer,
88
65
  groupId,
@@ -91,22 +68,10 @@ export class RiverComponent extends React.Component<Props, State> {
91
68
 
92
69
  const { id, type } = river;
93
70
 
94
- const connectedFeedURL = R.path(["content", "src"], screenData);
95
- const _feedUrl = feedUrl || connectedFeedURL;
96
-
97
71
  if (type !== "general_content") {
98
- let riverWithConnectedDatasource;
99
-
100
- if (_feedUrl && this.usesPipesV1Layout()) {
101
- riverWithConnectedDatasource = {
102
- ...river,
103
- data: R.merge(river.data || {}, { source: _feedUrl }),
104
- };
105
- }
106
-
107
72
  return (
108
73
  <ScreenResolver
109
- screenData={R.mergeLeft(riverWithConnectedDatasource || river, {
74
+ screenData={R.mergeLeft(river, {
110
75
  groupId,
111
76
  ...screenData,
112
77
  })}
@@ -116,53 +81,15 @@ export class RiverComponent extends React.Component<Props, State> {
116
81
  );
117
82
  }
118
83
 
119
- if (!_feedUrl || !this.usesPipesV1Layout()) {
120
- this.currentScreenTitle = (screenData && screenData.title) || null;
121
-
122
- return (
123
- <GeneralContentScreen
124
- screenId={id}
125
- isScreenWrappedInContainer={isInsideContainer}
126
- groupId={groupId}
127
- scrollViewExtraProps={scrollViewExtraProps}
128
- />
129
- );
130
- }
84
+ this.currentScreenTitle = (screenData && screenData.title) || null;
131
85
 
132
86
  return (
133
- <FeedLoader
134
- feedUrl={_feedUrl}
135
- refreshing={this.state.refreshing}
136
- refreshCallback={() =>
137
- this.pullToRefreshPipesV1RefreshingStateUpdater(false)
138
- }
139
- >
140
- {(feed) => {
141
- if (!feed) {
142
- return null;
143
- }
144
-
145
- this.currentScreenSummary = (feed && feed.summary) || null;
146
-
147
- this.currentScreenTitle =
148
- (feed && feed.title) || (screenData && screenData.title) || null;
149
-
150
- return (
151
- <GeneralContentScreen
152
- screenId={id}
153
- groupId={groupId}
154
- feed={feed}
155
- isScreenWrappedInContainer={isInsideContainer}
156
- scrollViewExtraProps={scrollViewExtraProps}
157
- componentsMapExtraProps={{
158
- pullToRefreshPipesV1RefreshingStateUpdater:
159
- this.pullToRefreshPipesV1RefreshingStateUpdater,
160
- refreshingPipesV1: this.state.refreshing,
161
- }}
162
- />
163
- );
164
- }}
165
- </FeedLoader>
87
+ <GeneralContentScreen
88
+ screenId={id}
89
+ isScreenWrappedInContainer={isInsideContainer}
90
+ groupId={groupId}
91
+ scrollViewExtraProps={scrollViewExtraProps}
92
+ />
166
93
  );
167
94
  }
168
95
  }
@@ -14,6 +14,7 @@ import { tvPluginsWithCellRenderer } from "../../const";
14
14
  import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
15
15
  import type { BehaviorSubject } from "rxjs";
16
16
  import { useCallbackActions } from "@applicaster/zapp-react-native-utils/zappFrameworkUtils/HookCallback/useCallbackActions";
17
+ import { isNilOrEmpty } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
17
18
 
18
19
  export type RiverItemType = {
19
20
  item: ZappUIComponent;
@@ -112,33 +113,38 @@ function RiverItemComponent(props: RiverItemType) {
112
113
  CellRenderer = undefined;
113
114
  }
114
115
 
115
- React.useEffect(() => {
116
- riverLogger.log({
117
- message: "mounting component",
118
- data: { item, feedUrl, Component, CellRenderer },
119
- jsOnly: true,
120
- });
116
+ const isComponentMissing = isNilOrEmpty(Component);
121
117
 
122
- if (!CellRenderer && !isGroup(item)) {
118
+ /**
119
+ * TODO: Move this plugin existence check further up the stack (before ComponentsMap).
120
+ * Filtering items at the list-rendering or data-processing level would prevent
121
+ * mounting RiverItem entirely for missing components.
122
+ */
123
+ React.useEffect(() => {
124
+ if (isComponentMissing) {
123
125
  riverLogger.warning({
124
- message: "Cell Renderer is null - will fallback to default cell",
125
- data: { item, CellRenderer },
126
+ message: `Component ${item.component_type} is null - skipping rendering`,
127
+ });
128
+
129
+ onLoadFinished(index);
130
+ } else {
131
+ riverLogger.log({
132
+ message: "mounting component",
133
+ data: { item, feedUrl, Component, CellRenderer },
126
134
  jsOnly: true,
127
135
  });
136
+
137
+ if (!CellRenderer && !isGroup(item)) {
138
+ riverLogger.warning({
139
+ message: "Cell Renderer is null - will fallback to default cell",
140
+ data: { item, CellRenderer },
141
+ jsOnly: true,
142
+ });
143
+ }
128
144
  }
129
145
  }, []);
130
146
 
131
- if (!readyToBeDisplayed) {
132
- return null;
133
- }
134
-
135
- if (Component === null || typeof Component === "undefined") {
136
- riverLogger.warning({
137
- message: `Component ${item.component_type} is null - skipping rendering`,
138
- });
139
-
140
- onLoadFinished(index);
141
-
147
+ if (!readyToBeDisplayed || isComponentMissing) {
142
148
  return null;
143
149
  }
144
150
 
@@ -137,6 +137,7 @@ exports[`componentsMap renders renders components map correctly 1`] = `
137
137
  keyExtractor={[Function]}
138
138
  maxToRenderPerBatch={10}
139
139
  onContentSizeChange={[Function]}
140
+ onEndReached={[Function]}
140
141
  onLayout={[Function]}
141
142
  onMomentumScrollBegin={[Function]}
142
143
  onMomentumScrollEnd={[Function]}
@@ -154,6 +155,7 @@ exports[`componentsMap renders renders components map correctly 1`] = `
154
155
  }
155
156
  }
156
157
  stickyHeaderIndices={[]}
158
+ testID="components-map-flat-list"
157
159
  viewabilityConfigCallbackPairs={[]}
158
160
  windowSize={12}
159
161
  >
@@ -139,7 +139,13 @@ jest.mock(
139
139
  })
140
140
  );
141
141
 
142
+ jest.mock("@applicaster/zapp-react-native-ui-components/events", () => ({
143
+ ...jest.requireActual("@applicaster/zapp-react-native-ui-components/events"),
144
+ emitScrollEndReached: jest.fn(),
145
+ }));
146
+
142
147
  const { View } = require("react-native");
148
+ const events = require("@applicaster/zapp-react-native-ui-components/events");
143
149
  const { ComponentsMap } = require("../ComponentsMap/ComponentsMap");
144
150
  const theme = require("./theme-mock.json");
145
151
 
@@ -190,4 +196,36 @@ describe("componentsMap", () => {
190
196
 
191
197
  expect(toJSON()).toMatchSnapshot();
192
198
  });
199
+
200
+ it("calls emitScrollEndReached when onScroll was called and isScreenWrappedInContainer is false", () => {
201
+ themeSpy = jest
202
+ .spyOn(themeUtils, "useTheme")
203
+ .mockImplementation(() => () => theme);
204
+
205
+ events.emitScrollEndReached.mockClear();
206
+
207
+ const { getByTestId } = render(
208
+ <Provider store={store}>
209
+ <ComponentsMap
210
+ {...props}
211
+ isScreenWrappedInContainer={false}
212
+ feed={{ entry: [] }}
213
+ />
214
+ </Provider>
215
+ );
216
+
217
+ const flatList = getByTestId("components-map-flat-list");
218
+
219
+ flatList.props.onScroll({
220
+ nativeEvent: {
221
+ contentOffset: { y: 0 },
222
+ layoutMeasurement: { height: 100 },
223
+ contentSize: { height: 200 },
224
+ },
225
+ });
226
+
227
+ flatList.props.onEndReached();
228
+
229
+ expect(events.emitScrollEndReached).toHaveBeenCalledTimes(1);
230
+ });
193
231
  });
@@ -0,0 +1,132 @@
1
+ import { act, renderHook } from "@testing-library/react-native";
2
+ import { refreshCoordinator } from "@applicaster/zapp-react-native-utils/refreshUtils/RefreshCoordinator";
3
+
4
+ import { usePullToRefresh } from "../usePullToRefresh";
5
+
6
+ jest.mock(
7
+ "@applicaster/zapp-react-native-utils/refreshUtils/RefreshCoordinator",
8
+ () => ({
9
+ refreshCoordinator: {
10
+ triggerRefresh: jest.fn(),
11
+ },
12
+ })
13
+ );
14
+
15
+ jest.useFakeTimers();
16
+
17
+ describe("usePullToRefresh", () => {
18
+ const screenId = "test-screen";
19
+ const components = [{ id: "comp1" }, { id: "comp2" }] as any;
20
+
21
+ beforeEach(() => {
22
+ jest.clearAllMocks();
23
+ });
24
+
25
+ it("should initialize with refreshing=false", () => {
26
+ const { result } = renderHook(() => usePullToRefresh(screenId, components));
27
+
28
+ expect(result.current.refreshing).toBe(false);
29
+ });
30
+
31
+ it("should trigger refresh and set refreshing=true", () => {
32
+ const { result } = renderHook(() => usePullToRefresh(screenId, components));
33
+
34
+ act(() => {
35
+ result.current.onRefresh();
36
+ });
37
+
38
+ expect(result.current.refreshing).toBe(true);
39
+
40
+ expect(refreshCoordinator.triggerRefresh).toHaveBeenCalledWith(
41
+ components,
42
+ screenId
43
+ );
44
+ });
45
+
46
+ it("should set refreshing=false after spinner duration", () => {
47
+ const { result } = renderHook(() => usePullToRefresh(screenId, components));
48
+
49
+ act(() => {
50
+ result.current.onRefresh();
51
+ });
52
+
53
+ expect(result.current.refreshing).toBe(true);
54
+
55
+ act(() => {
56
+ jest.advanceTimersByTime(1500);
57
+ });
58
+
59
+ expect(result.current.refreshing).toBe(false);
60
+ });
61
+
62
+ it("should not stop refreshing before spinner duration", () => {
63
+ const { result } = renderHook(() => usePullToRefresh(screenId, components));
64
+
65
+ act(() => {
66
+ result.current.onRefresh();
67
+ });
68
+
69
+ act(() => {
70
+ jest.advanceTimersByTime(1000);
71
+ });
72
+
73
+ expect(result.current.refreshing).toBe(true);
74
+ });
75
+
76
+ it("should clear timeout on unmount", () => {
77
+ const clearTimeoutSpy = jest.spyOn(global, "clearTimeout");
78
+
79
+ const { result, unmount } = renderHook(() =>
80
+ usePullToRefresh(screenId, components)
81
+ );
82
+
83
+ act(() => {
84
+ result.current.onRefresh();
85
+ });
86
+
87
+ unmount();
88
+
89
+ expect(clearTimeoutSpy).toHaveBeenCalled();
90
+ });
91
+
92
+ it("should handle multiple refresh calls correctly", () => {
93
+ const { result } = renderHook(() => usePullToRefresh(screenId, components));
94
+
95
+ act(() => {
96
+ result.current.onRefresh();
97
+ result.current.onRefresh();
98
+ });
99
+
100
+ expect(refreshCoordinator.triggerRefresh).toHaveBeenCalledTimes(2);
101
+ expect(result.current.refreshing).toBe(true);
102
+
103
+ act(() => {
104
+ jest.advanceTimersByTime(1500);
105
+ });
106
+
107
+ expect(result.current.refreshing).toBe(false);
108
+ });
109
+
110
+ it("should use latest props in callback", () => {
111
+ const { result, rerender } = renderHook(
112
+ ({ screenId, components }) => usePullToRefresh(screenId, components),
113
+ {
114
+ initialProps: { screenId, components },
115
+ }
116
+ );
117
+
118
+ const newComponents = [{ id: "new-comp" }] as any;
119
+ const newScreenId = "new-screen";
120
+
121
+ rerender({ screenId: newScreenId, components: newComponents });
122
+
123
+ act(() => {
124
+ result.current.onRefresh();
125
+ });
126
+
127
+ expect(refreshCoordinator.triggerRefresh).toHaveBeenCalledWith(
128
+ newComponents,
129
+ newScreenId
130
+ );
131
+ });
132
+ });
@@ -0,0 +1 @@
1
+ export { usePullToRefresh } from "./usePullToRefresh";
@@ -0,0 +1,51 @@
1
+ import { useState, useCallback, useRef, useEffect } from "react";
2
+ import { refreshCoordinator } from "@applicaster/zapp-react-native-utils/refreshUtils/RefreshCoordinator";
3
+
4
+ const SPINNER_DURATION_MS = 1500;
5
+
6
+ /**
7
+ * Pull-to-refresh hook.
8
+ *
9
+ * Triggers a refresh for all screen components via RefreshCoordinator.
10
+ * Each component's UrlFeedResolver already subscribes to refresh$ events
11
+ * and calls reloadData() when triggered — so this hook only needs to:
12
+ * 1. Push events into the refresh bus
13
+ * 2. Show a fixed-duration spinner as UX feedback
14
+ *
15
+ * Data updates arrive reactively via Redux (silentRefresh: true keeps
16
+ * old data visible while loading).
17
+ */
18
+ export const usePullToRefresh = (
19
+ screenId: string,
20
+ components: ZappUIComponent[] = []
21
+ ) => {
22
+ const [refreshing, setRefreshing] = useState(false);
23
+ const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
24
+
25
+ // Cleanup timer on unmount
26
+ useEffect(() => {
27
+ return () => {
28
+ if (timerRef.current) {
29
+ clearTimeout(timerRef.current);
30
+ }
31
+ };
32
+ }, []);
33
+
34
+ const onRefresh = useCallback(() => {
35
+ setRefreshing(true);
36
+ refreshCoordinator.triggerRefresh(components, screenId);
37
+
38
+ // Spinner is UX feedback for the gesture.
39
+ // Data updates arrive reactively via Redux (silentRefresh: true).
40
+ if (timerRef.current) {
41
+ clearTimeout(timerRef.current);
42
+ }
43
+
44
+ timerRef.current = setTimeout(
45
+ () => setRefreshing(false),
46
+ SPINNER_DURATION_MS
47
+ );
48
+ }, [components, screenId]);
49
+
50
+ return { refreshing, onRefresh };
51
+ };