@applicaster/zapp-react-native-utils 13.0.0-rc.2 → 13.0.0-rc.4

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.
@@ -40,13 +40,14 @@ export const playerFactory = (
40
40
 
41
41
  const playerPlugin = findPluginByIdentifier(IDENTIFIER, plugins);
42
42
 
43
- if (!playerPlugin) {
43
+ if (!playerPlugin?.module?.playerProtocol) {
44
44
  return null;
45
45
  }
46
46
 
47
- // TODO: Fix type:
48
- const playerProtocol: PlayerConstructor =
49
- playerPlugin?.module?.playerProtocol(config?.screenConfig);
47
+ const playerProtocol: PlayerConstructor = playerPlugin.module.playerProtocol(
48
+ config?.screenConfig,
49
+ config?.entry
50
+ );
50
51
 
51
52
  const playerView = (playerProtocol as any)?.Component || null;
52
53
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "13.0.0-rc.2",
3
+ "version": "13.0.0-rc.4",
4
4
  "description": "Applicaster Zapp React Native utilities package",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "homepage": "https://github.com/applicaster/quickbrick#readme",
30
30
  "dependencies": {
31
- "@applicaster/applicaster-types": "13.0.0-rc.2",
31
+ "@applicaster/applicaster-types": "13.0.0-rc.4",
32
32
  "buffer": "^5.2.1",
33
33
  "camelize": "^1.0.0",
34
34
  "create-react-context": "^0.2.3",
@@ -1,12 +1,11 @@
1
1
  import React, { useEffect } from "react";
2
- import { path } from "ramda";
3
2
  import { useDispatch } from "react-redux";
4
3
 
5
4
  import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
6
5
  import { useZappPipesFeed } from "@applicaster/zapp-react-native-redux/hooks";
7
6
 
8
7
  import { reactHooksLogger } from "../logger";
9
- import { useIsInitialRender } from "../utils";
8
+ import { useIsInitialRender, shouldUseCachedData } from "../utils";
10
9
  import { useInflatedUrl } from "./useInflatedUrl";
11
10
  import { useRoute } from "../navigation";
12
11
 
@@ -56,8 +55,6 @@ export const useFeedLoader = ({
56
55
 
57
56
  const currentFeed = useZappPipesFeed(callableFeedUrl);
58
57
 
59
- const cachedFeed = React.useMemo(() => path(["data"])(currentFeed), []);
60
-
61
58
  const riverId = screenData?.id;
62
59
 
63
60
  const reloadData = React.useCallback<ReloadDataFunction>(
@@ -94,7 +91,9 @@ export const useFeedLoader = ({
94
91
 
95
92
  // If feed doesn't exist, load it
96
93
  useEffect(() => {
97
- if (!cachedFeed || pipesOptions.clearCache) {
94
+ if (
95
+ shouldUseCachedData(callableFeedUrl, currentFeed, pipesOptions.clearCache)
96
+ ) {
98
97
  if (callableFeedUrl) {
99
98
  dispatch(loadPipesData(callableFeedUrl, { ...pipesOptions, riverId }));
100
99
  } else {
@@ -30,3 +30,16 @@ export const useIsInitialRender = (): boolean => {
30
30
 
31
31
  return isInitialRenderRef.current;
32
32
  };
33
+
34
+ export const checkIsLocalFeed = (feedUrl) => feedUrl?.startsWith("pipesv2://");
35
+
36
+ export const shouldUseCachedData = (
37
+ url: string,
38
+ feed: ZappPipesData | null,
39
+ clearCache: boolean
40
+ ) => {
41
+ const currentFeedHasData = feed?.data;
42
+ const isLocalFeed = checkIsLocalFeed(url);
43
+
44
+ return !currentFeedHasData || clearCache || isLocalFeed;
45
+ };