@applicaster/zapp-react-native-utils 13.0.0-alpha.2330880002 → 13.0.0-alpha.4585770583

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.
@@ -169,12 +169,8 @@ export class PlayerManager {
169
169
  this.addPlayer(id, playerController);
170
170
 
171
171
  if (playerController.playerRole === PlayerRole.Primary) {
172
- if (RNPlayerManager) {
173
- Object.keys(RNPlayerManager).forEach((pluginId) => {
174
- if (pluginId !== playerController.playerPluginId) {
175
- RNPlayerManager[pluginId].stopBackgroundPlayback?.();
176
- }
177
- });
172
+ if (playerController.playerPluginId !== "QuickBrickPlayerPlugin") {
173
+ RNPlayerManager?.["QuickBrickPlayerPlugin"]?.stopBackgroundPlayback?.();
178
174
  }
179
175
 
180
176
  playerController.addListener({
@@ -40,14 +40,13 @@ export const playerFactory = (
40
40
 
41
41
  const playerPlugin = findPluginByIdentifier(IDENTIFIER, plugins);
42
42
 
43
- if (!playerPlugin?.module?.playerProtocol) {
43
+ if (!playerPlugin) {
44
44
  return null;
45
45
  }
46
46
 
47
- const playerProtocol: PlayerConstructor = playerPlugin.module.playerProtocol(
48
- config?.screenConfig,
49
- config?.entry
50
- );
47
+ // TODO: Fix type:
48
+ const playerProtocol: PlayerConstructor =
49
+ playerPlugin?.module?.playerProtocol(config?.screenConfig);
51
50
 
52
51
  const playerView = (playerProtocol as any)?.Component || null;
53
52
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "13.0.0-alpha.2330880002",
3
+ "version": "13.0.0-alpha.4585770583",
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-alpha.2330880002",
31
+ "@applicaster/applicaster-types": "13.0.0-alpha.4585770583",
32
32
  "buffer": "^5.2.1",
33
33
  "camelize": "^1.0.0",
34
34
  "create-react-context": "^0.2.3",
@@ -135,11 +135,7 @@ describe("useFeedLoader", () => {
135
135
  );
136
136
 
137
137
  expect(result.current.data).toBeNull();
138
-
139
- expect(loadPipesDataSpy).toBeCalledWith(feedUrl, {
140
- clearCache: true,
141
- riverId: undefined,
142
- });
138
+ expect(loadPipesDataSpy).toBeCalledWith(feedUrl, {});
143
139
 
144
140
  const store2 = mockStore({
145
141
  plugins: [],
@@ -176,11 +172,7 @@ describe("useFeedLoader", () => {
176
172
  );
177
173
 
178
174
  expect(result.current.data).toBeNull();
179
-
180
- expect(loadPipesDataSpy).toBeCalledWith(feedUrl, {
181
- clearCache: true,
182
- riverId: undefined,
183
- });
175
+ expect(loadPipesDataSpy).toBeCalledWith(feedUrl, {});
184
176
 
185
177
  const store2 = mockStore({
186
178
  plugins: [],
@@ -1,11 +1,12 @@
1
1
  import React, { useEffect } from "react";
2
+ import { path } from "ramda";
2
3
  import { useDispatch } from "react-redux";
3
4
 
4
5
  import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
5
6
  import { useZappPipesFeed } from "@applicaster/zapp-react-native-redux/hooks";
6
7
 
7
8
  import { reactHooksLogger } from "../logger";
8
- import { useIsInitialRender, shouldDispatchData } from "../utils";
9
+ import { useIsInitialRender } from "../utils";
9
10
  import { useInflatedUrl } from "./useInflatedUrl";
10
11
  import { useRoute } from "../navigation";
11
12
 
@@ -55,6 +56,8 @@ export const useFeedLoader = ({
55
56
 
56
57
  const currentFeed = useZappPipesFeed(callableFeedUrl);
57
58
 
59
+ const cachedFeed = React.useMemo(() => path(["data"])(currentFeed), []);
60
+
58
61
  const riverId = screenData?.id;
59
62
 
60
63
  const reloadData = React.useCallback<ReloadDataFunction>(
@@ -89,18 +92,11 @@ export const useFeedLoader = ({
89
92
  }
90
93
  }, [callableFeedUrl, currentFeed?.data]);
91
94
 
95
+ // If feed doesn't exist, load it
92
96
  useEffect(() => {
93
- if (
94
- shouldDispatchData(callableFeedUrl, currentFeed, pipesOptions.clearCache)
95
- ) {
97
+ if (!cachedFeed || pipesOptions.clearCache) {
96
98
  if (callableFeedUrl) {
97
- dispatch(
98
- loadPipesData(callableFeedUrl, {
99
- ...pipesOptions,
100
- clearCache: true,
101
- riverId,
102
- })
103
- );
99
+ dispatch(loadPipesData(callableFeedUrl, { ...pipesOptions, riverId }));
104
100
  } else {
105
101
  logger.info({
106
102
  message:
@@ -30,16 +30,3 @@ 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 shouldDispatchData = (
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
- };