@applicaster/zapp-react-native-utils 13.0.0-alpha.7330390362 → 13.0.0-alpha.7620873141
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.
- package/README.md +0 -10
- package/actionsExecutor/ActionExecutorContext.tsx +104 -6
- package/analyticsUtils/currentScreenProperities.ts +6 -4
- package/appUtils/HooksManager/Hook.ts +4 -0
- package/appUtils/HooksManager/index.ts +3 -1
- package/appUtils/__tests__/__snapshots__/localizationsHelper.test.ts.snap +151 -0
- package/appUtils/__tests__/allZappLocales.ts +79 -0
- package/appUtils/__tests__/{localizationsHelper.test.js → localizationsHelper.test.ts} +11 -0
- package/appUtils/contextKeysManager/contextResolver.ts +1 -12
- package/appUtils/contextKeysManager/index.ts +2 -2
- package/appUtils/contextKeysManager/utils/index.ts +2 -1
- package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +1 -0
- package/appUtils/focusManager/index.ts +14 -10
- package/appUtils/keyCodes/index.ts +11 -7
- package/appUtils/localizationsHelper.ts +30 -0
- package/appUtils/orientationHelper.ts +11 -13
- package/appUtils/playerManager/index.ts +1 -1
- package/appUtils/playerManager/player.ts +24 -12
- package/appUtils/playerManager/playerNative.ts +18 -3
- package/appUtils/playerManager/usePlayerTitleSummaryOverlay.tsx +7 -1
- package/componentsUtils/__tests__/isFirstComponentGallery.test.ts +33 -0
- package/componentsUtils/__tests__/isFirstComponentScreenPicker.test.ts +33 -0
- package/componentsUtils/__tests__/isGallery.test.ts +33 -0
- package/componentsUtils/__tests__/isScreenPicker.test.ts +33 -0
- package/componentsUtils/index.ts +32 -0
- package/dateUtils/index.ts +19 -0
- package/equalUtils/__tests__/isEqual/combination.test.ts +263 -0
- package/equalUtils/index.ts +49 -30
- package/focusManager/FocusManager.ts +14 -2
- package/focusManager/index.ts +23 -4
- package/functionUtils/index.ts +46 -8
- package/index.d.ts +0 -12
- package/localizationUtils/index.ts +5 -10
- package/manifestUtils/defaultManifestConfigurations/player.js +14 -0
- package/manifestUtils/fonts/index.js +5 -6
- package/manifestUtils/keys.js +9 -0
- package/manifestUtils/sharedConfiguration/screenPicker/__tests__/utils.test.js +304 -0
- package/manifestUtils/sharedConfiguration/screenPicker/stylesFields.js +875 -0
- package/manifestUtils/sharedConfiguration/screenPicker/utils.js +130 -0
- package/modalState/__tests__/index.test.ts +51 -0
- package/modalState/index.ts +32 -2
- package/navigationUtils/__tests__/__snapshots__/navigationUtils.test.js.snap +1 -0
- package/navigationUtils/index.ts +3 -1
- package/numberUtils/__tests__/toPositiveNumberWithDefault.test.ts +23 -3
- package/numberUtils/index.ts +4 -0
- package/package.json +4 -10
- package/playerUtils/configurationGenerator.ts +14 -0
- package/reactHooks/advertising/index.ts +5 -5
- package/reactHooks/feed/useFeedLoader.tsx +17 -8
- package/reactHooks/hookModal/hooks/useHookModalScreenData.ts +39 -0
- package/reactHooks/navigation/__mocks__/useNavigation.ts +3 -0
- package/reactHooks/navigation/__tests__/index.test.tsx +6 -17
- package/reactHooks/navigation/index.ts +13 -23
- package/reactHooks/navigation/useProfilerLogging.ts +15 -0
- package/reactHooks/navigation/useRoute.ts +4 -6
- package/reactUtils/__tests__/__snapshots__/reactUtilsHelpers.test.js.snap +16 -4
- package/reactUtils/__tests__/reactUtils.test.js +1 -19
- package/reactUtils/__tests__/reactUtilsHelpers.test.js +72 -71
- package/reactUtils/createContext/__tests__/__snapshots__/helpers.test.js.snap +6 -72
- package/reactUtils/createContext/__tests__/__snapshots__/provider.test.js.snap +3 -28
- package/reactUtils/createContext/__tests__/__snapshots__/withConsumer.test.js.snap +3 -4
- package/reactUtils/createContext/__tests__/__snapshots__/withProvider.test.js.snap +7 -3
- package/reactUtils/createContext/__tests__/helpers.test.js +107 -121
- package/reactUtils/createContext/__tests__/{index.test.js → index.test.ts} +2 -2
- package/reactUtils/createContext/__tests__/provider.test.js +4 -6
- package/reactUtils/createContext/__tests__/withConsumer.test.js +12 -12
- package/reactUtils/createContext/__tests__/withProvider.test.js +4 -4
- package/reactUtils/createContext/helpers.ts +6 -1
- package/reactUtils/createContext/index.ts +11 -25
- package/reactUtils/index.ts +0 -11
- package/services/js2native.ts +673 -0
- package/testUtils/index.tsx +0 -10
- package/time/BackgroundTimer.ts +55 -0
- package/time/Timer.ts +6 -6
- package/utils/README.md +30 -0
- package/utils/chunk.ts +5 -0
- package/utils/index.ts +5 -0
- package/utils/times.ts +5 -0
- package/zappFrameworkUtils/localStorageHelper.ts +6 -0
- package/zappFrameworkUtils/loginPluginUtils.ts +6 -2
- package/zappFrameworkUtils/types.ts +11 -0
- package/reactUtils/createContext/__tests__/index-no-react.test.js +0 -27
- /package/reactUtils/createContext/__tests__/__snapshots__/{index.test.js.snap → index.test.ts.snap} +0 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
const defaultPlatforms = {
|
|
2
|
+
tvos: "tvOS",
|
|
3
|
+
android_tv: "Android TV",
|
|
4
|
+
lg_tv: "LG TV",
|
|
5
|
+
samsung_tv: "Samsung TV",
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const global_defaults = {
|
|
9
|
+
fontSize: 20,
|
|
10
|
+
lineHeight: 40,
|
|
11
|
+
letterSpacing: 0.4,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const generateFontConfiguration = (platforms = defaultPlatforms) => {
|
|
15
|
+
const platformEntries = Object.entries(platforms);
|
|
16
|
+
const defaultsEntries = Object.entries(global_defaults);
|
|
17
|
+
const splitCamelCase = (str) => str.replace(/([a-z](?=[A-Z]))/g, "$1_");
|
|
18
|
+
|
|
19
|
+
return platformEntries.reduce((acc, [platformKey, platformValue]) => {
|
|
20
|
+
acc.push(
|
|
21
|
+
...defaultsEntries.reduce((acc2, [valueKey, defaultValue]) => {
|
|
22
|
+
acc2.push({
|
|
23
|
+
type: "number_input",
|
|
24
|
+
label: `${platformValue} ${splitCamelCase(valueKey).replace(
|
|
25
|
+
"_",
|
|
26
|
+
" "
|
|
27
|
+
)}`,
|
|
28
|
+
key: `${platformKey}_${splitCamelCase(valueKey)}`.toLowerCase(),
|
|
29
|
+
initial_value: defaultValue,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return acc2;
|
|
33
|
+
}, [])
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
return acc;
|
|
37
|
+
}, []);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const conditional_rule = (key, condition_value) => ({
|
|
41
|
+
key,
|
|
42
|
+
condition_value,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const createConditionalConfig = (rules, matchAll = false) => ({
|
|
46
|
+
rules: matchAll ? "all_conditions" : "conditional",
|
|
47
|
+
conditional_fields: rules.map((field) => conditional_rule(...field)),
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const conditional_horizontal_type = createConditionalConfig([
|
|
51
|
+
["styles/screen_picker_type", "horizontal"],
|
|
52
|
+
]);
|
|
53
|
+
|
|
54
|
+
const conditional_vertical_type = createConditionalConfig([
|
|
55
|
+
["styles/screen_picker_type", "vertical"],
|
|
56
|
+
]);
|
|
57
|
+
|
|
58
|
+
const conditional_horizontal_type_item_fixed = createConditionalConfig(
|
|
59
|
+
[
|
|
60
|
+
["styles/screen_picker_type", "horizontal"],
|
|
61
|
+
["styles/screen_picker_item_size", "fixed"],
|
|
62
|
+
],
|
|
63
|
+
true
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
const conditional_horizontal_type_item_dynamic = createConditionalConfig(
|
|
67
|
+
[
|
|
68
|
+
["styles/screen_picker_type", "horizontal"],
|
|
69
|
+
["screen_picker_horizontal_display_type", "dynamic"],
|
|
70
|
+
],
|
|
71
|
+
true
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const conditional_horizontal_display_type_fixed = createConditionalConfig(
|
|
75
|
+
[
|
|
76
|
+
["styles/screen_picker_type", "horizontal"],
|
|
77
|
+
["styles/screen_picker_horizontal_display_type", "fixed"],
|
|
78
|
+
],
|
|
79
|
+
true
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const conditional_horizontal_asset_on = createConditionalConfig(
|
|
83
|
+
[
|
|
84
|
+
["styles/screen_picker_type", "horizontal"],
|
|
85
|
+
["styles/screen_picker_asset_switch", true],
|
|
86
|
+
],
|
|
87
|
+
true
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
const createVariationFields = ({
|
|
91
|
+
prefix = "screen_picker",
|
|
92
|
+
key,
|
|
93
|
+
type = "number_input",
|
|
94
|
+
label = "",
|
|
95
|
+
variants: [a, b],
|
|
96
|
+
}) => {
|
|
97
|
+
return [
|
|
98
|
+
{
|
|
99
|
+
type,
|
|
100
|
+
key: `${prefix}${prefix.length > 0 ? "_" : ""}${
|
|
101
|
+
a?.key ?? "vertical"
|
|
102
|
+
}_${key}`,
|
|
103
|
+
label: a?.label ?? label,
|
|
104
|
+
initial_value: a.initial_value,
|
|
105
|
+
...conditional_vertical_type,
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
type,
|
|
109
|
+
key: `${prefix}${prefix.length > 0 ? "_" : ""}${
|
|
110
|
+
b.key ?? "horizontal"
|
|
111
|
+
}_${key}`,
|
|
112
|
+
label: b?.label ?? label,
|
|
113
|
+
initial_value: b.initial_value,
|
|
114
|
+
...conditional_horizontal_type,
|
|
115
|
+
},
|
|
116
|
+
];
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
module.exports = {
|
|
120
|
+
generateFontConfiguration,
|
|
121
|
+
createVariationFields,
|
|
122
|
+
createConditionalConfig,
|
|
123
|
+
conditional_rule,
|
|
124
|
+
conditional_horizontal_type,
|
|
125
|
+
conditional_vertical_type,
|
|
126
|
+
conditional_horizontal_type_item_fixed,
|
|
127
|
+
conditional_horizontal_type_item_dynamic,
|
|
128
|
+
conditional_horizontal_display_type_fixed,
|
|
129
|
+
conditional_horizontal_asset_on,
|
|
130
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { modalStore } from "../";
|
|
2
|
+
|
|
3
|
+
describe("Modal State", () => {
|
|
4
|
+
it("should have initial state", () => {
|
|
5
|
+
const state = modalStore.getState();
|
|
6
|
+
|
|
7
|
+
expect(state).toMatchObject({
|
|
8
|
+
modalState: {
|
|
9
|
+
visible: false,
|
|
10
|
+
screen: null,
|
|
11
|
+
options: {},
|
|
12
|
+
props: {},
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
expect(state.openModal).toBeDefined();
|
|
17
|
+
expect(state.dismissModal).toBeDefined();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe("opening and dismissing modal", () => {
|
|
21
|
+
it("should open modal", () => {
|
|
22
|
+
const item = { id: "test", name: "Test Modal" };
|
|
23
|
+
const options = { animated: true, animationType: "slide" };
|
|
24
|
+
const props = { customProp: "value" };
|
|
25
|
+
|
|
26
|
+
modalStore.getState().openModal({ item, options, props });
|
|
27
|
+
|
|
28
|
+
const state = modalStore.getState();
|
|
29
|
+
|
|
30
|
+
expect(state.modalState).toMatchObject({
|
|
31
|
+
visible: true,
|
|
32
|
+
screen: item,
|
|
33
|
+
options,
|
|
34
|
+
props,
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("should dismiss modal", () => {
|
|
39
|
+
modalStore.getState().dismissModal();
|
|
40
|
+
|
|
41
|
+
const state = modalStore.getState();
|
|
42
|
+
|
|
43
|
+
expect(state.modalState).toMatchObject({
|
|
44
|
+
visible: false,
|
|
45
|
+
screen: null,
|
|
46
|
+
options: {},
|
|
47
|
+
props: {},
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
});
|
package/modalState/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useStore, createStore } from "zustand";
|
|
2
2
|
|
|
3
3
|
interface ModalState {
|
|
4
4
|
visible: boolean;
|
|
@@ -25,7 +25,7 @@ const initialModalState: ModalState = {
|
|
|
25
25
|
props: {},
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
export const
|
|
28
|
+
export const modalStore = createStore<ModalStore>((set) => ({
|
|
29
29
|
modalState: initialModalState,
|
|
30
30
|
setModalState: (newState) =>
|
|
31
31
|
set((state) => ({
|
|
@@ -51,3 +51,33 @@ export const useModalStore = create<ModalStore>((set) => ({
|
|
|
51
51
|
}),
|
|
52
52
|
dismissModal: () => set(() => ({ modalState: initialModalState })),
|
|
53
53
|
}));
|
|
54
|
+
|
|
55
|
+
export const useModalStore = <T>(selector: (state: ModalStore) => T) =>
|
|
56
|
+
useStore(modalStore, selector);
|
|
57
|
+
|
|
58
|
+
export const openModal = modalStore.getInitialState().openModal;
|
|
59
|
+
|
|
60
|
+
export const dismissModal = modalStore.getInitialState().dismissModal;
|
|
61
|
+
|
|
62
|
+
export const openBottomSheetModal = ({
|
|
63
|
+
ModalBottomSheetContent,
|
|
64
|
+
modalBottomSheetContentProps,
|
|
65
|
+
props = {},
|
|
66
|
+
options = {},
|
|
67
|
+
}: OpenModalBottomSheetArgs) => {
|
|
68
|
+
openModal({
|
|
69
|
+
item: {
|
|
70
|
+
ModalBottomSheetContent,
|
|
71
|
+
modalBottomSheetContentProps,
|
|
72
|
+
},
|
|
73
|
+
props,
|
|
74
|
+
options: {
|
|
75
|
+
animationType: "none",
|
|
76
|
+
animated: false,
|
|
77
|
+
...options,
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const useModalStoreState = (): ModalState =>
|
|
83
|
+
useModalStore<ModalState>((state) => state.modalState);
|
package/navigationUtils/index.ts
CHANGED
|
@@ -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("
|
|
3
|
+
describe("toPositiveNumberWithDefault", () => {
|
|
4
4
|
const DEFAULT = 5;
|
|
5
5
|
|
|
6
6
|
it("return number if input is positive number", () => {
|
|
7
|
-
const inputs = [
|
|
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 = ["
|
|
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
|
});
|
package/numberUtils/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "13.0.0-alpha.
|
|
3
|
+
"version": "13.0.0-alpha.7620873141",
|
|
4
4
|
"description": "Applicaster Zapp React Native utilities package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"test": "jest -w=2",
|
|
9
8
|
"build": "echo skipping hybrid ts build in main packages for now"
|
|
10
9
|
},
|
|
11
10
|
"publishConfig": {
|
|
@@ -28,11 +27,9 @@
|
|
|
28
27
|
},
|
|
29
28
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
30
29
|
"dependencies": {
|
|
31
|
-
"@applicaster/applicaster-types": "13.0.0-alpha.
|
|
30
|
+
"@applicaster/applicaster-types": "13.0.0-alpha.7620873141",
|
|
32
31
|
"buffer": "^5.2.1",
|
|
33
32
|
"camelize": "^1.0.0",
|
|
34
|
-
"create-react-context": "^0.2.3",
|
|
35
|
-
"create-react-ref": "^0.1.0",
|
|
36
33
|
"dayjs": "^1.11.10",
|
|
37
34
|
"memoizee": "0.4.15",
|
|
38
35
|
"prop-types": "^15.0.0",
|
|
@@ -42,13 +39,10 @@
|
|
|
42
39
|
"@applicaster/zapp-pipes-v2-client": "*",
|
|
43
40
|
"@react-native-community/netinfo": "*",
|
|
44
41
|
"immer": "*",
|
|
45
|
-
"react": "
|
|
46
|
-
"react-native": "
|
|
42
|
+
"react": "*",
|
|
43
|
+
"react-native": "*",
|
|
47
44
|
"uglify-js": "*",
|
|
48
45
|
"validate-color": "*",
|
|
49
46
|
"zustand": "*"
|
|
50
|
-
},
|
|
51
|
-
"devDependencies": {
|
|
52
|
-
"@types/react-native": "0.69.6"
|
|
53
47
|
}
|
|
54
48
|
}
|
|
@@ -55,6 +55,14 @@ function getPlayerConfiguration({ platform }) {
|
|
|
55
55
|
label_tooltip:
|
|
56
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.",
|
|
57
57
|
},
|
|
58
|
+
{
|
|
59
|
+
key: "audio_player_background_image_default_color",
|
|
60
|
+
label: "Audio Player Background Image Default Color",
|
|
61
|
+
initial_value: "",
|
|
62
|
+
type: "text_input",
|
|
63
|
+
label_tooltip:
|
|
64
|
+
"Set the default color for the audio player background image if not image or set of gradient colors are not provided.",
|
|
65
|
+
},
|
|
58
66
|
],
|
|
59
67
|
};
|
|
60
68
|
|
|
@@ -2549,6 +2557,12 @@ function getPlayerConfiguration({ platform }) {
|
|
|
2549
2557
|
multiple: false,
|
|
2550
2558
|
label_tooltip: "Choose the default aspect ratio for the artwork",
|
|
2551
2559
|
},
|
|
2560
|
+
{
|
|
2561
|
+
key: "audio_player_artwork_border_radius",
|
|
2562
|
+
label: "Audio Player Artwork Corner Radius",
|
|
2563
|
+
type: "number_input",
|
|
2564
|
+
initial_value: 16,
|
|
2565
|
+
},
|
|
2552
2566
|
]
|
|
2553
2567
|
)
|
|
2554
2568
|
);
|
|
@@ -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
|
|
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
|
-
|
|
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:
|
|
39
|
+
callback: dismissModal,
|
|
40
40
|
hookPlugin: GoogleAdsPlugin,
|
|
41
41
|
},
|
|
42
42
|
},
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
|
-
}, [
|
|
45
|
+
}, [currentRoute, screenData?.id]);
|
|
46
46
|
}
|
|
@@ -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 {
|
|
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 =
|
|
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
|
|
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
|
+
};
|
|
@@ -310,14 +310,14 @@ describe("navigation", () => {
|
|
|
310
310
|
expect(navBarVisible).toBe(false);
|
|
311
311
|
});
|
|
312
312
|
|
|
313
|
-
it("returns false if it's secondary nav bar and
|
|
313
|
+
it("returns false if it's secondary nav bar and show_secondary_level_menu is false", () => {
|
|
314
314
|
const navBarVisible = isNavBarVisible(
|
|
315
315
|
"",
|
|
316
316
|
{
|
|
317
317
|
navigations: [
|
|
318
318
|
{
|
|
319
319
|
styles: {
|
|
320
|
-
|
|
320
|
+
show_secondary_level_menu: false,
|
|
321
321
|
},
|
|
322
322
|
},
|
|
323
323
|
],
|
|
@@ -329,14 +329,14 @@ describe("navigation", () => {
|
|
|
329
329
|
expect(navBarVisible).toBe(false);
|
|
330
330
|
});
|
|
331
331
|
|
|
332
|
-
it("returns true if it's secondary nav bar and
|
|
332
|
+
it("returns true if it's secondary nav bar and show_secondary_level_menu is true", () => {
|
|
333
333
|
const navBarVisible = isNavBarVisible(
|
|
334
334
|
"",
|
|
335
335
|
{
|
|
336
336
|
navigations: [
|
|
337
337
|
{
|
|
338
338
|
styles: {
|
|
339
|
-
|
|
339
|
+
show_secondary_level_menu: true,
|
|
340
340
|
},
|
|
341
341
|
},
|
|
342
342
|
],
|
|
@@ -348,14 +348,14 @@ describe("navigation", () => {
|
|
|
348
348
|
expect(navBarVisible).toBe(true);
|
|
349
349
|
});
|
|
350
350
|
|
|
351
|
-
it("returns true if it's first level menu and
|
|
351
|
+
it("returns true if it's first level menu and show_secondary_level_menu is false", () => {
|
|
352
352
|
const navBarVisible = isNavBarVisible(
|
|
353
353
|
"",
|
|
354
354
|
{
|
|
355
355
|
navigations: [
|
|
356
356
|
{
|
|
357
357
|
styles: {
|
|
358
|
-
|
|
358
|
+
show_secondary_level_menu: false,
|
|
359
359
|
},
|
|
360
360
|
},
|
|
361
361
|
],
|
|
@@ -366,16 +366,5 @@ describe("navigation", () => {
|
|
|
366
366
|
|
|
367
367
|
expect(navBarVisible).toBe(true);
|
|
368
368
|
});
|
|
369
|
-
|
|
370
|
-
it("returns true otherwise", () => {
|
|
371
|
-
const navBarVisible = isNavBarVisible(
|
|
372
|
-
"",
|
|
373
|
-
{ navigations: [] } as any,
|
|
374
|
-
true,
|
|
375
|
-
true
|
|
376
|
-
);
|
|
377
|
-
|
|
378
|
-
expect(navBarVisible).toBe(true);
|
|
379
|
-
});
|
|
380
369
|
});
|
|
381
370
|
});
|