@applicaster/zapp-react-native-ui-components 14.0.0-rc.8 → 14.0.0-rc.9

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.
@@ -281,8 +281,8 @@ function ComponentsMapComponent(props: Props) {
281
281
  scrollIndicatorInsets={scrollIndicatorInsets}
282
282
  extraData={feed}
283
283
  stickyHeaderIndices={stickyHeaderIndices}
284
- onLayout={handleOnLayout}
285
284
  removeClippedSubviews={isAndroid}
285
+ onLayout={handleOnLayout}
286
286
  initialNumToRender={3}
287
287
  maxToRenderPerBatch={10}
288
288
  windowSize={12}
@@ -303,10 +303,6 @@ function ComponentsMapComponent(props: Props) {
303
303
  onMomentumScrollEnd={_onMomentumScrollEnd}
304
304
  onScrollEndDrag={_onScrollEndDrag}
305
305
  scrollEventThrottle={16}
306
- maintainVisibleContentPosition={{
307
- minIndexForVisible: 0,
308
- autoscrollToTopThreshold: 10,
309
- }}
310
306
  {...scrollViewExtraProps}
311
307
  />
312
308
  </ViewportTracker>
@@ -39,6 +39,10 @@ function getFeedUrl(feed: ZappFeed, index: number) {
39
39
  }
40
40
  }
41
41
 
42
+ const isNextIndex = (index, readyIndex) => {
43
+ return readyIndex + 1 >= index;
44
+ };
45
+
42
46
  /**
43
47
  * useLoadingState for RiverItemComponent
44
48
  * takes currentIndex and loadingState as arguments
@@ -48,24 +52,20 @@ const useLoadingState = (
48
52
  loadingState: RiverItemType["loadingState"]
49
53
  ) => {
50
54
  const [readyToBeDisplayed, setReadyToBeDisplayed] = React.useState(
51
- loadingState.getValue().index + 1 >= currentIndex
55
+ isNextIndex(currentIndex, loadingState.getValue().index)
52
56
  );
53
57
 
54
58
  useEffect(() => {
55
59
  const subscription = loadingState.subscribe(({ index }) => {
56
- if (index + 1 >= currentIndex) {
60
+ if (isNextIndex(currentIndex, index)) {
57
61
  setReadyToBeDisplayed(true);
58
62
  }
59
63
  });
60
64
 
61
- if (loadingState.getValue().index + 1 >= currentIndex) {
62
- setReadyToBeDisplayed(true);
63
- }
64
-
65
65
  return () => {
66
66
  subscription.unsubscribe();
67
67
  };
68
- }, [loadingState, currentIndex]);
68
+ }, [currentIndex]);
69
69
 
70
70
  return readyToBeDisplayed;
71
71
  };
@@ -151,7 +151,7 @@ function RiverItemComponent(props: RiverItemType) {
151
151
  component={item}
152
152
  componentIndex={index}
153
153
  onLoadFailed={onLoadFailed}
154
- onLoadFinished={() => onLoadFinished(index)} // Keeping it here to don't break the plugins.
154
+ onLoadFinished={() => onLoadFinished(index)}
155
155
  groupId={groupId}
156
156
  feedUrl={feedUrl}
157
157
  isLast={isLast}
@@ -135,12 +135,6 @@ exports[`componentsMap renders renders components map correctly 1`] = `
135
135
  getItemCount={[Function]}
136
136
  initialNumToRender={3}
137
137
  keyExtractor={[Function]}
138
- maintainVisibleContentPosition={
139
- {
140
- "autoscrollToTopThreshold": 10,
141
- "minIndexForVisible": 0,
142
- }
143
- }
144
138
  maxToRenderPerBatch={10}
145
139
  onContentSizeChange={[Function]}
146
140
  onLayout={[Function]}
@@ -71,6 +71,36 @@ exports[`PlayerWrapper renders inline 1`] = `
71
71
  }
72
72
  testID="test-player-container"
73
73
  />
74
+ <View
75
+ animationType="componentFade"
76
+ style={
77
+ {
78
+ "flex": 1,
79
+ }
80
+ }
81
+ >
82
+ <View
83
+ configuration={
84
+ {
85
+ "tablet_landscape_player_container_background_color": "red",
86
+ "tablet_landscape_sidebar_width": "35%",
87
+ }
88
+ }
89
+ entry={
90
+ {
91
+ "id": "test",
92
+ }
93
+ }
94
+ isTablet={false}
95
+ isTabletLandscape={false}
96
+ style={
97
+ {
98
+ "flex": 1,
99
+ "paddingTop": 20,
100
+ }
101
+ }
102
+ />
103
+ </View>
74
104
  </View>
75
105
  </RNCSafeAreaView>
76
106
  </RNCSafeAreaProvider>
@@ -239,6 +269,36 @@ exports[`PlayerWrapper renders inline on tablet in landscape orientation 1`] = `
239
269
  }
240
270
  />
241
271
  </View>
272
+ <View
273
+ animationType="componentFade"
274
+ style={
275
+ {
276
+ "flex": 1,
277
+ }
278
+ }
279
+ >
280
+ <View
281
+ configuration={
282
+ {
283
+ "tablet_landscape_player_container_background_color": "red",
284
+ "tablet_landscape_sidebar_width": "35%",
285
+ }
286
+ }
287
+ entry={
288
+ {
289
+ "id": "test",
290
+ }
291
+ }
292
+ isTablet={true}
293
+ isTabletLandscape={true}
294
+ style={
295
+ {
296
+ "flex": 1,
297
+ "paddingTop": 20,
298
+ }
299
+ }
300
+ />
301
+ </View>
242
302
  </View>
243
303
  </RNCSafeAreaView>
244
304
  </RNCSafeAreaProvider>
@@ -1,19 +1,9 @@
1
1
  import { renderHook } from "@testing-library/react-hooks";
2
2
  import { useDelayedPlayerDetails } from "../useDelayedPlayerDetails";
3
- import { withTimeout$ } from "@applicaster/zapp-react-native-utils/idleUtils";
4
- import { showDetails } from "../utils";
5
3
  import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
6
4
 
7
- jest.mock("@applicaster/zapp-react-native-utils/idleUtils", () => ({
8
- withTimeout$: jest.fn(),
9
- }));
10
-
11
- jest.mock("../utils", () => ({
12
- showDetails: jest.fn(),
13
- }));
14
-
15
5
  jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
16
- useIsTablet: jest.fn(),
6
+ useIsTablet: jest.fn().mockReturnValue(false),
17
7
  }));
18
8
 
19
9
  describe("useDelayedPlayerDetails", () => {
@@ -21,69 +11,41 @@ describe("useDelayedPlayerDetails", () => {
21
11
  jest.clearAllMocks();
22
12
  });
23
13
 
24
- it("should return false initially", () => {
25
- (withTimeout$ as jest.Mock).mockReturnValue({
26
- subscribe: jest.fn().mockReturnValue({ unsubscribe: jest.fn() }),
27
- });
28
-
14
+ it("should return true initially", () => {
29
15
  const { result } = renderHook(() =>
30
16
  useDelayedPlayerDetails({ isInline: true, isDocked: false, isPip: false })
31
17
  );
32
18
 
33
- expect(result.current).toBe(false);
19
+ expect(result.current).toBe(true);
34
20
  });
35
21
 
36
- it("should return true if showDetails returns true", () => {
37
- (withTimeout$ as jest.Mock).mockReturnValue({
38
- subscribe: (callback) => {
39
- callback.next();
40
-
41
- return { unsubscribe: jest.fn() };
42
- },
43
- });
44
-
45
- (showDetails as jest.Mock).mockReturnValue(true);
46
- (useIsTablet as jest.Mock).mockReturnValue(false);
47
-
22
+ it("should return false when isPip is true", () => {
48
23
  const { result } = renderHook(() =>
49
- useDelayedPlayerDetails({ isInline: true, isDocked: false, isPip: false })
24
+ useDelayedPlayerDetails({ isInline: true, isDocked: true, isPip: true })
50
25
  );
51
26
 
52
- expect(result.current).toBe(true);
27
+ expect(result.current).toBe(false);
53
28
  });
54
29
 
55
- it("should return false if showDetails returns false", () => {
56
- (withTimeout$ as jest.Mock).mockReturnValue({
57
- subscribe: (callback) => {
58
- callback.next();
59
-
60
- return { unsubscribe: jest.fn() };
61
- },
62
- });
63
-
64
- (showDetails as jest.Mock).mockReturnValue(false);
65
- (useIsTablet as jest.Mock).mockReturnValue(false);
66
-
30
+ it("should return false when isDocked is true", () => {
67
31
  const { result } = renderHook(() =>
68
- useDelayedPlayerDetails({ isInline: true, isDocked: false, isPip: false })
32
+ useDelayedPlayerDetails({ isInline: true, isDocked: true, isPip: false })
69
33
  );
70
34
 
71
35
  expect(result.current).toBe(false);
72
36
  });
73
37
 
74
- it("should unsubscribe on unmount", () => {
75
- const unsubscribeMock = jest.fn();
38
+ it("should return true for tablet regardless of other flags", () => {
39
+ (useIsTablet as jest.Mock).mockReturnValue(true);
76
40
 
77
- (withTimeout$ as jest.Mock).mockReturnValue({
78
- subscribe: jest.fn().mockReturnValue({ unsubscribe: unsubscribeMock }),
79
- });
80
-
81
- const { unmount } = renderHook(() =>
82
- useDelayedPlayerDetails({ isInline: true, isDocked: false, isPip: false })
41
+ const { result } = renderHook(() =>
42
+ useDelayedPlayerDetails({
43
+ isInline: false,
44
+ isDocked: false,
45
+ isPip: false,
46
+ })
83
47
  );
84
48
 
85
- unmount();
86
-
87
- expect(unsubscribeMock).toHaveBeenCalled();
49
+ expect(result.current).toBe(true);
88
50
  });
89
51
  });
@@ -1,13 +1,23 @@
1
- import * as React from "react";
2
1
  import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
3
- import { withTimeout$ } from "@applicaster/zapp-react-native-utils/idleUtils";
4
2
 
5
3
  import { showDetails } from "./utils";
6
4
 
7
- const TIMEOUT = 100; // ms
8
-
9
5
  type Props = { isInline: boolean; isDocked: boolean; isPip: boolean };
10
6
 
7
+ const showPlayerDetails = (
8
+ isInline: boolean,
9
+ isDocked: boolean,
10
+ isPip: boolean,
11
+ isTablet: boolean
12
+ ) => {
13
+ return showDetails({
14
+ isMobile: !isTablet,
15
+ isInline,
16
+ isDocked,
17
+ isPip,
18
+ });
19
+ };
20
+
11
21
  /**
12
22
  * Custom hook to determine whether to show player details with a delay.
13
23
  *
@@ -22,28 +32,7 @@ export const useDelayedPlayerDetails = ({
22
32
  isDocked,
23
33
  isPip,
24
34
  }: Props): boolean => {
25
- const [shouldShowDetails, setShouldShowDetails] = React.useState(false);
26
-
27
35
  const isTablet = useIsTablet();
28
36
 
29
- React.useEffect(() => {
30
- const subscription = withTimeout$(TIMEOUT).subscribe({
31
- next: () => {
32
- setShouldShowDetails(() => {
33
- return showDetails({
34
- isMobile: !isTablet,
35
- isInline,
36
- isDocked,
37
- isPip,
38
- });
39
- });
40
- },
41
- });
42
-
43
- return () => {
44
- subscription.unsubscribe();
45
- };
46
- }, [isDocked, isTablet, isInline, isPip]);
47
-
48
- return shouldShowDetails;
37
+ return showPlayerDetails(isInline, isDocked, isPip, isTablet);
49
38
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-ui-components",
3
- "version": "14.0.0-rc.8",
3
+ "version": "14.0.0-rc.9",
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",
@@ -31,10 +31,10 @@
31
31
  "redux-mock-store": "^1.5.3"
32
32
  },
33
33
  "dependencies": {
34
- "@applicaster/applicaster-types": "14.0.0-rc.8",
35
- "@applicaster/zapp-react-native-bridge": "14.0.0-rc.8",
36
- "@applicaster/zapp-react-native-redux": "14.0.0-rc.8",
37
- "@applicaster/zapp-react-native-utils": "14.0.0-rc.8",
34
+ "@applicaster/applicaster-types": "14.0.0-rc.9",
35
+ "@applicaster/zapp-react-native-bridge": "14.0.0-rc.9",
36
+ "@applicaster/zapp-react-native-redux": "14.0.0-rc.9",
37
+ "@applicaster/zapp-react-native-utils": "14.0.0-rc.9",
38
38
  "promise": "^8.3.0",
39
39
  "url": "^0.11.0",
40
40
  "uuid": "^3.3.2"