@applicaster/zapp-react-native-utils 13.0.0-alpha.2807014304 → 13.0.0-alpha.2886020207

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 (54) hide show
  1. package/actionsExecutor/ActionExecutorContext.tsx +126 -6
  2. package/actionsExecutor/consts.ts +4 -0
  3. package/appUtils/HooksManager/Hook.ts +4 -0
  4. package/appUtils/HooksManager/index.ts +2 -0
  5. package/appUtils/__tests__/__snapshots__/localizationsHelper.test.ts.snap +151 -0
  6. package/appUtils/__tests__/allZappLocales.ts +79 -0
  7. package/appUtils/__tests__/{localizationsHelper.test.js → localizationsHelper.test.ts} +11 -0
  8. package/appUtils/contextKeysManager/contextResolver.ts +1 -12
  9. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +2 -0
  10. package/appUtils/focusManager/index.ios.ts +14 -4
  11. package/appUtils/focusManager/index.ts +13 -0
  12. package/appUtils/focusManager/utils/__tests__/findChild.test.ts +35 -0
  13. package/appUtils/focusManager/utils/index.ts +5 -0
  14. package/appUtils/localizationsHelper.ts +31 -0
  15. package/appUtils/playerManager/playerHooks/usePlayerCurrentTime.tsx +11 -7
  16. package/appUtils/playerManager/usePlayerTitleSummaryOverlay.tsx +7 -1
  17. package/cellUtils/index.ts +9 -5
  18. package/componentsUtils/__tests__/isFirstComponentGallery.test.ts +33 -0
  19. package/componentsUtils/__tests__/isFirstComponentScreenPicker.test.ts +33 -0
  20. package/componentsUtils/__tests__/isGallery.test.ts +33 -0
  21. package/componentsUtils/__tests__/isScreenPicker.test.ts +33 -0
  22. package/componentsUtils/index.ts +39 -0
  23. package/dateUtils/index.ts +19 -0
  24. package/focusManager/FocusManager.ts +3 -1
  25. package/focusManager/index.ts +4 -30
  26. package/functionUtils/index.ts +25 -0
  27. package/index.d.ts +0 -12
  28. package/localizationUtils/index.ts +8 -13
  29. package/manifestUtils/defaultManifestConfigurations/generalContent.js +13 -0
  30. package/manifestUtils/defaultManifestConfigurations/player.js +6 -0
  31. package/manifestUtils/keys.js +27 -2
  32. package/modalState/__tests__/index.test.ts +51 -0
  33. package/modalState/index.ts +32 -2
  34. package/navigationUtils/__tests__/__snapshots__/navigationUtils.test.js.snap +1 -0
  35. package/navigationUtils/index.ts +3 -1
  36. package/numberUtils/__tests__/toPositiveNumberWithDefault.test.ts +23 -3
  37. package/numberUtils/index.ts +4 -0
  38. package/package.json +2 -2
  39. package/playerUtils/configurationGenerator.ts +7 -9
  40. package/reactHooks/advertising/index.ts +5 -5
  41. package/reactHooks/feed/useBatchLoading.ts +10 -12
  42. package/reactHooks/feed/useFeedLoader.tsx +17 -8
  43. package/reactHooks/hookModal/hooks/useHookModalScreenData.ts +39 -0
  44. package/reactHooks/navigation/useRoute.ts +4 -6
  45. package/reactHooks/screen/__tests__/useScreenBackgroundColor.test.tsx +69 -0
  46. package/reactHooks/screen/useScreenBackgroundColor.ts +3 -15
  47. package/reactHooks/useListenEventBusEvent.ts +1 -1
  48. package/utils/README.md +30 -0
  49. package/utils/chunk.ts +5 -0
  50. package/utils/index.ts +5 -0
  51. package/utils/times.ts +5 -0
  52. package/zappFrameworkUtils/localStorageHelper.ts +6 -0
  53. package/zappFrameworkUtils/loginPluginUtils.ts +6 -2
  54. package/zappFrameworkUtils/types.ts +11 -0
@@ -111,6 +111,7 @@ export function getNavigationProps({
111
111
  assets: ZappNavBarAssets;
112
112
  rules: ZappNavBarRules;
113
113
  nav_items: NavBarItem[];
114
+ data: MenuItemDataProperties;
114
115
  } | null {
115
116
  const { activeRiver } = navigator;
116
117
  const { navigations, id: selected, home } = activeRiver; // use useRiver hook instead
@@ -124,7 +125,7 @@ export function getNavigationProps({
124
125
  return null;
125
126
  }
126
127
 
127
- const { styles, assets, nav_items, rules } = navigation;
128
+ const { styles, assets, nav_items, rules, data } = navigation;
128
129
 
129
130
  return {
130
131
  selected,
@@ -134,6 +135,7 @@ export function getNavigationProps({
134
135
  assets: assets as ZappNavBarAssets,
135
136
  nav_items: nav_items as any as NavBarItem[],
136
137
  rules: rules as any as ZappNavBarRules,
138
+ data: data as MenuItemDataProperties,
137
139
  };
138
140
  }
139
141
 
@@ -1,10 +1,10 @@
1
1
  import { toPositiveNumberWithDefault } from "..";
2
2
 
3
- describe("toNumber", () => {
3
+ describe("toPositiveNumberWithDefault", () => {
4
4
  const DEFAULT = 5;
5
5
 
6
6
  it("return number if input is positive number", () => {
7
- const inputs = [0, 1, 2, 100, 200.12, Infinity];
7
+ const inputs = [1, 2, 100, 200.12, Infinity];
8
8
  expect.assertions(inputs.length);
9
9
 
10
10
  inputs.forEach((input) => {
@@ -14,7 +14,7 @@ describe("toNumber", () => {
14
14
  });
15
15
 
16
16
  it("return number if input is positive number as string", () => {
17
- const inputs = ["0", "1", "2", "100", "200.12"];
17
+ const inputs = ["1", "2", "100", "200.12"];
18
18
  expect.assertions(inputs.length);
19
19
 
20
20
  inputs.forEach((input) => {
@@ -63,4 +63,24 @@ describe("toNumber", () => {
63
63
  expect(output).toBe(DEFAULT);
64
64
  });
65
65
  });
66
+
67
+ it("return default if input is zero number", () => {
68
+ const inputs = [0, -0];
69
+ expect.assertions(inputs.length);
70
+
71
+ inputs.forEach((input) => {
72
+ const output = toPositiveNumberWithDefault(DEFAULT, input);
73
+ expect(output).toBe(DEFAULT);
74
+ });
75
+ });
76
+
77
+ it("return default if input is zero string", () => {
78
+ const inputs = ["0", "-0"];
79
+ expect.assertions(inputs.length);
80
+
81
+ inputs.forEach((input) => {
82
+ const output = toPositiveNumberWithDefault(DEFAULT, input);
83
+ expect(output).toBe(DEFAULT);
84
+ });
85
+ });
66
86
  });
@@ -83,6 +83,10 @@ export const toPositiveNumberWithDefault = (
83
83
  return defaultValue;
84
84
  }
85
85
 
86
+ if (isZero(possibleNumber)) {
87
+ return defaultValue;
88
+ }
89
+
86
90
  return possibleNumber;
87
91
  };
88
92
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "13.0.0-alpha.2807014304",
3
+ "version": "13.0.0-alpha.2886020207",
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": "13.0.0-alpha.2807014304",
30
+ "@applicaster/applicaster-types": "13.0.0-alpha.2886020207",
31
31
  "buffer": "^5.2.1",
32
32
  "camelize": "^1.0.0",
33
33
  "dayjs": "^1.11.10",
@@ -39,21 +39,13 @@ function getPlayerConfiguration({ platform }) {
39
39
  label_tooltip:
40
40
  "Disable if you don't want the content to have a right orientation",
41
41
  },
42
- {
43
- key: "magic_background",
44
- label: "Enable Magic Background",
45
- initial_value: false,
46
- type: "switch",
47
- label_tooltip:
48
- "Enable if you want to have adaptive background gradient based on audio background image.",
49
- },
50
42
  {
51
43
  key: "audio_player_background_image_query",
52
44
  label: "Audio Player Image Query",
53
45
  initial_value: "",
54
46
  type: "text_input",
55
47
  label_tooltip:
56
- "Set the query params which control the size of the image e.g width, height. This will help to optimize the loading time, when magic background is enabled.",
48
+ "Set the query params which control the size of the image e.g width, height. This will help to optimize the loading time.",
57
49
  },
58
50
  {
59
51
  key: "audio_player_background_image_default_color",
@@ -2557,6 +2549,12 @@ function getPlayerConfiguration({ platform }) {
2557
2549
  multiple: false,
2558
2550
  label_tooltip: "Choose the default aspect ratio for the artwork",
2559
2551
  },
2552
+ {
2553
+ key: "audio_player_artwork_border_radius",
2554
+ label: "Audio Player Artwork Corner Radius",
2555
+ type: "number_input",
2556
+ initial_value: 16,
2557
+ },
2560
2558
  ]
2561
2559
  )
2562
2560
  );
@@ -5,6 +5,7 @@ import * as R from "ramda";
5
5
  import { useNavigation } from "../navigation";
6
6
  import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
7
7
  import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
8
+ import { dismissModal, openModal } from "../../modalState";
8
9
 
9
10
  const GOOGLE_ADS_IDENTIFIER = "google-admob-ads-qb";
10
11
 
@@ -14,9 +15,8 @@ const ModalContainer = platformSelect({
14
15
  });
15
16
 
16
17
  export function useAdvertisingInterstitial() {
17
- const navigator = useNavigation();
18
+ const { screenData, currentRoute } = useNavigation();
18
19
  const { plugins } = usePickFromState();
19
- const { screenData } = navigator;
20
20
 
21
21
  return useEffect(() => {
22
22
  // TODD: typing problem: fix any type
@@ -26,7 +26,7 @@ export function useAdvertisingInterstitial() {
26
26
  plugins
27
27
  );
28
28
 
29
- navigator.openModal({
29
+ openModal({
30
30
  item: {},
31
31
  options: {
32
32
  ModalContainer,
@@ -36,11 +36,11 @@ export function useAdvertisingInterstitial() {
36
36
  screenType: "hooks",
37
37
  screenData: {
38
38
  payload: screenData,
39
- callback: navigator.dismissModal,
39
+ callback: dismissModal,
40
40
  hookPlugin: GoogleAdsPlugin,
41
41
  },
42
42
  },
43
43
  });
44
44
  }
45
- }, [navigator.currentRoute, screenData?.id]);
45
+ }, [currentRoute, screenData?.id]);
46
46
  }
@@ -1,7 +1,7 @@
1
- import { isNil, complement, compose, map, min, prop, take, uniq } from "ramda";
1
+ import { complement, compose, isNil, map, min, prop, take, uniq } from "ramda";
2
2
  import { useDispatch } from "react-redux";
3
3
  import * as React from "react";
4
- import { useZappPipesFeeds } from "@applicaster/zapp-react-native-redux/hooks/useZappPipesFeeds";
4
+ import { useZappPipesFeeds } from "@applicaster/zapp-react-native-redux/hooks";
5
5
  import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
6
6
  import { isNilOrEmpty } from "../../reactUtils/helpers";
7
7
  import { ZappPipesSearchContext } from "@applicaster/zapp-react-native-ui-components/Contexts";
@@ -9,6 +9,7 @@ import {
9
9
  getInflatedDataSourceUrl,
10
10
  getSearchContext,
11
11
  } from "@applicaster/zapp-react-native-utils/reactHooks";
12
+ import { isGallery } from "@applicaster/zapp-react-native-utils/componentsUtils";
12
13
  import { useScreenContext } from "../screen/useScreenContext";
13
14
 
14
15
  type Options = {
@@ -46,9 +47,7 @@ const filterEmptyData = (data) => {
46
47
  };
47
48
 
48
49
  const getData = (rawData) =>
49
- rawData.component_type === "gallery-qb"
50
- ? rawData.ui_components[0].data
51
- : rawData.data;
50
+ isGallery(rawData) ? rawData.ui_components[0].data : rawData.data;
52
51
 
53
52
  const extractData = compose(uniq, map(getData));
54
53
 
@@ -70,13 +69,12 @@ export const useBatchLoading = (
70
69
  const [hasEverBeenReady, setHasEverBeenReady] = React.useState(false);
71
70
 
72
71
  // if first component is gallery-qb, take only one component for initial load
73
- const takeSize =
74
- componentsToRender?.[0]?.component_type === "gallery-qb"
75
- ? 1
76
- : min(
77
- options.initialBatchSize ?? DEFAULT_BATCH_SIZE,
78
- componentsToRender.length
79
- );
72
+ const takeSize = isGallery(componentsToRender?.[0])
73
+ ? 1
74
+ : min(
75
+ options.initialBatchSize ?? DEFAULT_BATCH_SIZE,
76
+ componentsToRender.length
77
+ );
80
78
 
81
79
  const takeBatchSize = React.useCallback(take(takeSize), [takeSize]);
82
80
 
@@ -5,7 +5,7 @@ import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
5
5
  import { useZappPipesFeed } from "@applicaster/zapp-react-native-redux/hooks";
6
6
 
7
7
  import { reactHooksLogger } from "../logger";
8
- import { useIsInitialRender, shouldDispatchData } from "../utils";
8
+ import { shouldDispatchData, useIsInitialRender } from "../utils";
9
9
  import { useInflatedUrl } from "./useInflatedUrl";
10
10
  import { useRoute } from "../navigation";
11
11
 
@@ -20,6 +20,7 @@ type Props = {
20
20
  silentRefresh?: boolean;
21
21
  method?: "get" | "post";
22
22
  bodyParams?: Record<string, unknown>;
23
+ skipLoading?: boolean;
23
24
  };
24
25
  };
25
26
 
@@ -55,7 +56,9 @@ export const useFeedLoader = ({
55
56
 
56
57
  const currentFeed = useZappPipesFeed(callableFeedUrl);
57
58
 
58
- const riverId = screenData?.id;
59
+ const riverId =
60
+ (screenData as LegacyNavigationScreenData)?.targetScreen?.id ??
61
+ screenData?.id;
59
62
 
60
63
  const reloadData = React.useCallback<ReloadDataFunction>(
61
64
  (silentRefresh = true, callback) => {
@@ -93,7 +96,7 @@ export const useFeedLoader = ({
93
96
  if (
94
97
  shouldDispatchData(callableFeedUrl, currentFeed, pipesOptions.clearCache)
95
98
  ) {
96
- if (callableFeedUrl) {
99
+ if (callableFeedUrl && !pipesOptions.skipLoading) {
97
100
  dispatch(
98
101
  loadPipesData(callableFeedUrl, {
99
102
  ...pipesOptions,
@@ -101,26 +104,33 @@ export const useFeedLoader = ({
101
104
  riverId,
102
105
  })
103
106
  );
104
- } else {
107
+ } else if (!callableFeedUrl) {
105
108
  logger.info({
106
109
  message:
107
110
  "Feed is not defined or not inflated, skipping loading. \nMake sure you have correct feedUrl and mapping.",
108
111
  jsOnly: true,
109
112
  });
113
+ } else {
114
+ logger.info({
115
+ message:
116
+ "Loading skipped as per pipesOptions.skipLoading configuration.",
117
+ data: { url: callableFeedUrl },
118
+ jsOnly: true,
119
+ });
110
120
  }
111
121
  } else {
112
122
  logger.info({
113
123
  message:
114
- "Feed already exist, skipping loading. \nCall reloadData() if you want to refresh data.",
124
+ "Feed already exists, skipping loading. \nCall reloadData() if you want to refresh data.",
115
125
  data: { url: callableFeedUrl },
116
126
  jsOnly: true,
117
127
  });
118
128
  }
119
129
  }, []);
120
130
 
121
- // Reload feed when feedUrl changes
131
+ // Reload feed when feedUrl changes, unless skipLoading is true
122
132
  useEffect(() => {
123
- if (!isInitialRender && callableFeedUrl) {
133
+ if (!isInitialRender && callableFeedUrl && !pipesOptions.skipLoading) {
124
134
  dispatch(loadPipesData(callableFeedUrl, { ...pipesOptions, riverId }));
125
135
  }
126
136
  }, [callableFeedUrl]);
@@ -156,7 +166,6 @@ export const useFeedLoader = ({
156
166
  currentFeed?.data,
157
167
  currentFeed?.error,
158
168
  currentFeed?.loading,
159
-
160
169
  reloadData,
161
170
  loadNext,
162
171
  ]);
@@ -0,0 +1,39 @@
1
+ import { reactHooksLogger } from "../../logger";
2
+ import { useZappHooksModalState } from "@applicaster/zapp-react-dom-ui-components/Components/ZappHooksModal/hooks/useZappHooksModalState";
3
+
4
+ const logger = reactHooksLogger.addSubsystem("useHookModalScreenData");
5
+
6
+ type VariousScreenData = LegacyNavigationScreenData | ZappRiver | ZappEntry;
7
+
8
+ export const useHookModalScreenData = (): VariousScreenData | undefined => {
9
+ const hookModalState = useZappHooksModalState();
10
+
11
+ if (!hookModalState.state?.screenData) {
12
+ return;
13
+ }
14
+
15
+ try {
16
+ const screenData = hookModalState.state.screenData?.payload;
17
+ const hookPlugin = hookModalState.state.screenData.hookPlugin;
18
+
19
+ if (hookPlugin?.screen_id) {
20
+ return {
21
+ ...screenData,
22
+ targetScreen: hookPlugin,
23
+ };
24
+ }
25
+
26
+ return hookModalState.state.screenData?.payload;
27
+ } catch (error) {
28
+ logger.error({
29
+ message: "Hook modal screen data creation failed",
30
+ data: {
31
+ error,
32
+ hookModalState,
33
+ },
34
+ jsOnly: true,
35
+ });
36
+
37
+ return hookModalState.state.screenData?.payload;
38
+ }
39
+ };
@@ -7,12 +7,11 @@ import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
7
7
 
8
8
  import { legacyScreenData } from "@applicaster/quick-brick-core/App/NavigationProvider/utils";
9
9
 
10
- import { useZappHooksModalState } from "@applicaster/zapp-react-dom-ui-components/Components/ZappHooksModal/hooks/useZappHooksModalState";
11
-
12
10
  import { getTargetScreenData } from "../screen/useTargetScreenData";
11
+ import { useHookModalScreenData } from "../hookModal/hooks/useHookModalScreenData";
13
12
 
14
13
  import { useNavigation } from "./useNavigation";
15
- import { useModalStore } from "../../modalState";
14
+ import { useModalStoreState } from "../../modalState";
16
15
  import { ScreenDataContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenDataContext";
17
16
  import { usePathname } from "./usePathname";
18
17
 
@@ -44,12 +43,11 @@ export const useRoute = (): {
44
43
  "contentTypes",
45
44
  ]);
46
45
 
47
- const { modalState } = useModalStore();
48
- const hookModalState = useZappHooksModalState();
46
+ const modalState = useModalStoreState();
49
47
 
50
48
  const modalScreenData = modalState.screen;
51
49
 
52
- const hookModalScreenData = hookModalState.state.screenData?.payload;
50
+ const hookModalScreenData = useHookModalScreenData();
53
51
 
54
52
  const videoModalScreenData =
55
53
  navigator?.videoModalState?.item &&
@@ -0,0 +1,69 @@
1
+ import { renderHook } from "@testing-library/react-hooks";
2
+
3
+ jest.mock(
4
+ "@applicaster/zapp-react-native-ui-components/Components/River/useScreenConfiguration",
5
+ () => ({
6
+ useScreenConfiguration: jest.fn(),
7
+ })
8
+ );
9
+
10
+ const {
11
+ useScreenConfiguration,
12
+ } = require("@applicaster/zapp-react-native-ui-components/Components/River/useScreenConfiguration");
13
+
14
+ const { useScreenBackgroundColor } = require("../useScreenBackgroundColor");
15
+
16
+ describe("useScreenBackgroundColor", () => {
17
+ afterEach(() => {
18
+ jest.clearAllMocks();
19
+ });
20
+
21
+ it("should return the background color from screen configuration", () => {
22
+ useScreenConfiguration.mockReturnValue({
23
+ backgroundColor: "#FF0000",
24
+ });
25
+
26
+ // Render the hook with a screen ID
27
+ const { result } = renderHook(() =>
28
+ useScreenBackgroundColor("test-screen-id")
29
+ );
30
+
31
+ expect(result.current).toBe("#FF0000");
32
+
33
+ expect(useScreenConfiguration).toHaveBeenCalledWith("test-screen-id");
34
+ });
35
+
36
+ it("should return 'transparent' when background color is empty", () => {
37
+ useScreenConfiguration.mockReturnValue({
38
+ backgroundColor: "",
39
+ });
40
+
41
+ const { result } = renderHook(() =>
42
+ useScreenBackgroundColor("test-screen-id")
43
+ );
44
+
45
+ expect(result.current).toBe("transparent");
46
+ });
47
+
48
+ it("should return 'transparent' when background color is null", () => {
49
+ useScreenConfiguration.mockReturnValue({
50
+ backgroundColor: null,
51
+ });
52
+
53
+ const { result } = renderHook(() =>
54
+ useScreenBackgroundColor("test-screen-id")
55
+ );
56
+
57
+ expect(result.current).toBe("transparent");
58
+ });
59
+
60
+ it("should return 'transparent' when background color is undefined", () => {
61
+ useScreenConfiguration.mockReturnValue({});
62
+
63
+ const { result } = renderHook(() =>
64
+ useScreenBackgroundColor("test-screen-id")
65
+ );
66
+
67
+ expect(result.current).toBe("transparent");
68
+ });
69
+ });
@@ -1,23 +1,11 @@
1
- import * as React from "react";
2
- import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
3
1
  import { useScreenConfiguration } from "@applicaster/zapp-react-native-ui-components/Components/River/useScreenConfiguration";
4
2
  import { ifEmptyUseFallback } from "@applicaster/zapp-react-native-utils/cellUtils";
5
3
 
4
+ const DEFAULT_BACKGROUND_FALLBACK = "transparent";
5
+
6
6
  export const useScreenBackgroundColor = (screenId: string): string => {
7
7
  const { backgroundColor: screenBackgroundColor } =
8
8
  useScreenConfiguration(screenId);
9
9
 
10
- const theme = useTheme();
11
-
12
- const themeBackgroundColor = React.useMemo(
13
- () => theme.app_background_color,
14
- [theme.app_background_color]
15
- );
16
-
17
- const backgroundColor = ifEmptyUseFallback(
18
- screenBackgroundColor,
19
- themeBackgroundColor
20
- );
21
-
22
- return backgroundColor;
10
+ return ifEmptyUseFallback(screenBackgroundColor, DEFAULT_BACKGROUND_FALLBACK);
23
11
  };
@@ -23,5 +23,5 @@ export const useListenEventBusEvent = (
23
23
  sub.remove(); // stop listening to DeviceEventEmitter
24
24
  };
25
25
  }
26
- }, []);
26
+ }, [handler, subscriptionID, source, events]);
27
27
  };
@@ -0,0 +1,30 @@
1
+ ### ramda replacement utils
2
+
3
+ See contribution guide below
4
+
5
+ ## Reference
6
+
7
+ Prefer non-fp variant as it more performant - if refactoring assumes you need more efforts rewrite ramda sample to lodash and it can be easily replaced with lodash-fp - use lodash-fp.
8
+
9
+ ### Ramda alternatives:
10
+
11
+ Custom
12
+ - `splitEvery` => `chunk`
13
+ - `times` => `times`
14
+
15
+ From `lodash`
16
+ - `clone` => `clone`
17
+ - `flatten` => `flatten`
18
+ - `drop` => `drop`
19
+ - `length` => `size`
20
+
21
+
22
+ ## Contribution
23
+
24
+ To add new helper function as ramda replacement
25
+
26
+ 1. Search for replacement ( you can use lodash or pure JS solution), arguments should match with Ramda definition (for easier transition).
27
+ 2. Add new file if needed, add test, update exports in index file. 2.1. Make sure it's well-typed.
28
+ 3. If the function can-be reexported from other 3rd party lib - update index.ts to re-export it.
29
+ 4. Make sure README is updated and contains reference for newly added function.
30
+ 5. You can use AI's help. Use query like 'lodash & lodash/fp equivalent of Ramda's R.clone function' to get an options you can use.
package/utils/chunk.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { chunk as _chunk } from "lodash";
2
+
3
+ export const chunk = <T>(size: number, array: T[]): T[][] => {
4
+ return _chunk(array, size);
5
+ };
package/utils/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ export { chunk } from "./chunk";
2
+
3
+ export { times } from "./times";
4
+
5
+ export { cloneDeep as clone, flatten, drop, size } from "lodash";
package/utils/times.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { times as _times } from "lodash";
2
+
3
+ export const times = <T>(iteratee: (index: number) => T, n: number) => {
4
+ return _times(n, iteratee);
5
+ };
@@ -1,6 +1,12 @@
1
1
  import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
2
2
  import { isNilOrEmpty } from "../reactUtils/helpers";
3
3
  import { parseJsonIfNeeded } from "@applicaster/zapp-react-native-utils/functionUtils";
4
+ import {
5
+ StorageOwnedValues,
6
+ NamespaceValues,
7
+ StorageValuesToRemove,
8
+ StorageValuesToAdd,
9
+ } from "./types";
4
10
 
5
11
  const defaultOwnedKey = "owned_keys";
6
12
  const DEFAULT_NAMESPACE = "applicaster.v2";
@@ -89,11 +89,15 @@ const runInBackground = async ({
89
89
  const shouldPresent = await hookPresentPolicy.shouldPresentScreen();
90
90
 
91
91
  if (!shouldPresent) {
92
+ const isRefreshed = await checkUserAuthenticated();
93
+
92
94
  log_info(
93
- "runInBackground: Background mode finished, hook plugin will be skipped"
95
+ `runInBackground: Background mode finished, ${isRefreshed ? "finish hook with completion true" : "refresh failed will presentUI"}`
94
96
  );
95
97
 
96
- await checkUserAuthenticated();
98
+ isRefreshed
99
+ ? callback({ success: isRefreshed, payload: item })
100
+ : presentUI();
97
101
 
98
102
  return;
99
103
  }
@@ -0,0 +1,11 @@
1
+ export type StorageValuesToAdd = Record<string, NamespaceValues>;
2
+
3
+ export type StorageValuesToRemove = {
4
+ string?: string[];
5
+ };
6
+
7
+ export type StorageOwnedValues = {
8
+ string?: string[];
9
+ };
10
+
11
+ export type NamespaceValues = Record<string, string>;