@applicaster/zapp-react-native-utils 15.1.9-alpha.3547421944 → 15.1.10-alpha.1542385274

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.
@@ -0,0 +1,38 @@
1
+ import { PlayerNative } from "../playerNative";
2
+
3
+ const playerWithEntry = (entry: any) =>
4
+ new PlayerNative({
5
+ entry,
6
+ player: null as any,
7
+ playerId: "test-player",
8
+ });
9
+
10
+ describe("PlayerNative.isAudioItem", () => {
11
+ it.each(["audio", "audio-player", "audio-detail", "audio-show", "audio-hub"])(
12
+ "treats the %s content type as audio",
13
+ (type) => {
14
+ expect(playerWithEntry({ type: { value: type } }).isAudioItem()).toBe(
15
+ true
16
+ );
17
+ }
18
+ );
19
+
20
+ it.each(["video", "video-detail", "comic-detail", "article-show"])(
21
+ "does not treat the %s content type as audio",
22
+ (type) => {
23
+ expect(playerWithEntry({ type: { value: type } }).isAudioItem()).toBe(
24
+ false
25
+ );
26
+ }
27
+ );
28
+
29
+ it("falls back to the media type when the content type says nothing", () => {
30
+ const entry = { content: { type: "audio/mpeg" }, type: { value: "link" } };
31
+
32
+ expect(playerWithEntry(entry).isAudioItem()).toBe(true);
33
+ });
34
+
35
+ it("returns false when there is no entry", () => {
36
+ expect(playerWithEntry(null).isAudioItem()).toBe(false);
37
+ });
38
+ });
@@ -287,9 +287,11 @@ export class PlayerNative extends Player {
287
287
  }, listeners);
288
288
  };
289
289
 
290
- isAudioItem = () =>
291
- this.getEntry()?.content?.type?.includes?.("audio") ||
292
- this.getEntry()?.type?.value === "audio";
290
+ isAudioItem = (): boolean =>
291
+ Boolean(
292
+ this.getEntry()?.content?.type?.includes?.("audio") ||
293
+ this.getEntry()?.type?.value?.includes?.("audio")
294
+ );
293
295
 
294
296
  isFullScreenSupported = (): boolean => {
295
297
  const config = this.getConfig();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "15.1.9-alpha.3547421944",
3
+ "version": "15.1.10-alpha.1542385274",
4
4
  "description": "Applicaster Zapp React Native utilities package",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "homepage": "https://github.com/applicaster/quickbrick#readme",
29
29
  "dependencies": {
30
- "@applicaster/applicaster-types": "15.1.9-alpha.3547421944",
30
+ "@applicaster/applicaster-types": "15.1.10-alpha.1542385274",
31
31
  "buffer": "^5.2.1",
32
32
  "camelize": "^1.0.0",
33
33
  "dayjs": "^1.11.10",
@@ -129,5 +129,15 @@ export const useCellClick = ({
129
129
  ]
130
130
  );
131
131
 
132
- return cellSelectable ? onPress : noop;
132
+ const onPressRef = React.useRef<onPressReturnFn>();
133
+
134
+ if (!cellSelectable) {
135
+ // update ref with dummy function
136
+ onPressRef.current = noop;
137
+ } else {
138
+ // update ref with the latest onPress function
139
+ onPressRef.current = onPress;
140
+ }
141
+
142
+ return React.useCallback(onPressRef.current, [item]);
133
143
  };