@applicaster/zapp-react-native-utils 13.0.0-alpha.6179233127 → 13.0.0-alpha.6400875052
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/actionsExecutor/ActionExecutorContext.tsx +94 -6
- package/appUtils/HooksManager/Hook.ts +4 -0
- package/appUtils/HooksManager/index.ts +2 -0
- package/appUtils/contextKeysManager/contextResolver.ts +1 -12
- package/appUtils/playerManager/player.ts +20 -12
- package/appUtils/playerManager/playerNative.ts +12 -1
- package/dateUtils/index.ts +2 -0
- package/focusManager/FocusManager.ts +3 -1
- package/focusManager/index.ts +3 -21
- package/modalState/index.ts +32 -2
- package/package.json +2 -3
- package/reactHooks/advertising/index.ts +5 -5
- package/reactHooks/feed/useFeedLoader.tsx +4 -2
- package/reactHooks/hookModal/hooks/useHookModalScreenData.ts +39 -0
- package/reactHooks/navigation/index.ts +5 -3
- package/reactHooks/navigation/useRoute.ts +4 -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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="@applicaster/applicaster-types" />
|
|
2
2
|
import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
|
|
3
|
-
import React, { createContext, useMemo } from "react";
|
|
3
|
+
import React, { createContext, useEffect, useMemo } from "react";
|
|
4
4
|
import {
|
|
5
5
|
actionExecutor as _actionExecutor,
|
|
6
6
|
ActionResult,
|
|
@@ -19,8 +19,15 @@ import {
|
|
|
19
19
|
EntryResolver,
|
|
20
20
|
resolveObjectValues,
|
|
21
21
|
} from "../appUtils/contextKeysManager/contextResolver";
|
|
22
|
+
import { useNavigation } from "../reactHooks";
|
|
23
|
+
import { get } from "lodash";
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
import {
|
|
26
|
+
useContentTypes,
|
|
27
|
+
usePickFromState,
|
|
28
|
+
} from "@applicaster/zapp-react-native-redux/hooks";
|
|
29
|
+
|
|
30
|
+
export const { log_error, log_info, log_debug } = createLogger({
|
|
24
31
|
subsystem: "ActionExecutorContext",
|
|
25
32
|
category: "General",
|
|
26
33
|
});
|
|
@@ -51,6 +58,22 @@ type Props = {
|
|
|
51
58
|
children: React.ReactNode;
|
|
52
59
|
};
|
|
53
60
|
|
|
61
|
+
function findParentComponent(
|
|
62
|
+
childId: string,
|
|
63
|
+
parent: ZappRiver | ZappUIComponent
|
|
64
|
+
): ZappRiver | ZappUIComponent | null {
|
|
65
|
+
for (const child of parent.ui_components) {
|
|
66
|
+
if (child.id === childId) return parent;
|
|
67
|
+
|
|
68
|
+
if (child.ui_components) {
|
|
69
|
+
const found = findParentComponent(childId, child);
|
|
70
|
+
if (found) return found;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
|
|
54
77
|
const prepareDefaultActions = (actionExecutor) => {
|
|
55
78
|
actionExecutor.registerAction("localStorageSet", async (action) => {
|
|
56
79
|
const namespaces = action.options.content;
|
|
@@ -65,11 +88,13 @@ const prepareDefaultActions = (actionExecutor) => {
|
|
|
65
88
|
async (_action, context) => {
|
|
66
89
|
const dispatch = appStore.getDispatch();
|
|
67
90
|
|
|
68
|
-
|
|
91
|
+
const dataSource =
|
|
92
|
+
context?.component?.data?.source ||
|
|
93
|
+
findParentComponent(context?.component.id, context?.screenData)?.data
|
|
94
|
+
?.source;
|
|
69
95
|
|
|
70
|
-
|
|
96
|
+
log_info(`handleAction: refreshComponent for dataSource:${dataSource}`);
|
|
71
97
|
|
|
72
|
-
// TODO: Later we can pass component ids to do refresh instead of current one
|
|
73
98
|
// TODO: In theory we should wait callback to complete, before completing the action, but now it's not needed
|
|
74
99
|
// TODO: handle focused item removal
|
|
75
100
|
dispatch(
|
|
@@ -169,8 +194,29 @@ const prepareDefaultActions = (actionExecutor) => {
|
|
|
169
194
|
action: ActionType,
|
|
170
195
|
context?: Record<string, any>
|
|
171
196
|
): Promise<ActionResult> => {
|
|
197
|
+
if (!context) {
|
|
198
|
+
log_error(
|
|
199
|
+
"handleAction: localStorageToggleFlag action missing context"
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
return ActionResult.Error;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const entry = context?.entry as ZappEntry;
|
|
206
|
+
|
|
207
|
+
if (!entry) {
|
|
208
|
+
log_error(
|
|
209
|
+
"handleAction: localStorageToggleFlag action missing entry. Entry is required to get the tag."
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
return ActionResult.Error;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const tag = action.options?.selector
|
|
216
|
+
? get(entry, action.options.selector)
|
|
217
|
+
: (entry.extensions?.tag ?? entry.id);
|
|
218
|
+
|
|
172
219
|
const keyNamespace = action.options?.key;
|
|
173
|
-
const tag = context?.entry?.extensions?.tag;
|
|
174
220
|
|
|
175
221
|
if (keyNamespace && tag) {
|
|
176
222
|
const multiSelectProvider =
|
|
@@ -211,6 +257,10 @@ export function withActionExecutor(Component) {
|
|
|
211
257
|
prepareDefaultActions(_actionExecutor);
|
|
212
258
|
|
|
213
259
|
return function ActionExecutorComponent(props: Props) {
|
|
260
|
+
const navigator = useNavigation();
|
|
261
|
+
const { rivers } = usePickFromState(["rivers"]);
|
|
262
|
+
const contentTypes = useContentTypes();
|
|
263
|
+
|
|
214
264
|
const handlers = useMemo(() => {
|
|
215
265
|
return {
|
|
216
266
|
unregisterAction: _actionExecutor.unregisterAction,
|
|
@@ -221,6 +271,44 @@ export function withActionExecutor(Component) {
|
|
|
221
271
|
};
|
|
222
272
|
}, []);
|
|
223
273
|
|
|
274
|
+
useEffect(() => {
|
|
275
|
+
return _actionExecutor.registerAction(
|
|
276
|
+
"navigateToScreen",
|
|
277
|
+
async (action: ActionType, context?: Record<string, any>) => {
|
|
278
|
+
const screenType = action.options?.typeMapping;
|
|
279
|
+
|
|
280
|
+
if (!screenType) {
|
|
281
|
+
log_error("navigateToScreen: typeMapping option is missing");
|
|
282
|
+
|
|
283
|
+
return ActionResult.Error;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
const screenId = contentTypes?.[screenType]?.screen_id || null;
|
|
287
|
+
|
|
288
|
+
if (!screenId) {
|
|
289
|
+
log_error(
|
|
290
|
+
`navigateToScreen: can not resolve screen type mapping: ${screenType}`
|
|
291
|
+
);
|
|
292
|
+
|
|
293
|
+
return ActionResult.Error;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const river = rivers[screenId];
|
|
297
|
+
|
|
298
|
+
if (!river) {
|
|
299
|
+
log_error("navigateToScreen: can not resolve river");
|
|
300
|
+
|
|
301
|
+
return ActionResult.Error;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
context?.callback?.({ success: false, error: null, abort: true });
|
|
305
|
+
navigator.replace(river);
|
|
306
|
+
|
|
307
|
+
return ActionResult.Success;
|
|
308
|
+
}
|
|
309
|
+
);
|
|
310
|
+
}, [navigator, rivers, contentTypes]);
|
|
311
|
+
|
|
224
312
|
return (
|
|
225
313
|
<ActionExecutorContext.Provider value={handlers}>
|
|
226
314
|
<Component {...props} />
|
|
@@ -65,6 +65,10 @@ export class Hook implements HookInterface {
|
|
|
65
65
|
event: (typeof HOOKS_EVENTS)[keyof typeof HOOKS_EVENTS],
|
|
66
66
|
...args
|
|
67
67
|
) {
|
|
68
|
+
if (this.state === hookState(HOOKS_EVENTS.CANCEL)) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
68
72
|
this.state = hookState(event);
|
|
69
73
|
this.manager.subscriber.invokeHandler(event, ...args);
|
|
70
74
|
}
|
|
@@ -269,6 +269,7 @@ export function HooksManager({
|
|
|
269
269
|
payload = initialPayload,
|
|
270
270
|
callback: callbackArg,
|
|
271
271
|
cancelled,
|
|
272
|
+
abort,
|
|
272
273
|
}) {
|
|
273
274
|
let callback = callbackArg;
|
|
274
275
|
|
|
@@ -308,6 +309,7 @@ export function HooksManager({
|
|
|
308
309
|
hookPlugin.setStateAndNotify(HOOKS_EVENTS.CANCEL, {
|
|
309
310
|
hookPlugin,
|
|
310
311
|
payload,
|
|
312
|
+
abort,
|
|
311
313
|
});
|
|
312
314
|
|
|
313
315
|
const isHookInHomescreen = payload?.home;
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import { createLogger } from "../../logger";
|
|
2
1
|
import { ContextKeysManager } from "./index";
|
|
3
2
|
import * as R from "ramda";
|
|
4
3
|
|
|
5
|
-
const { log_error } = createLogger({
|
|
6
|
-
subsystem: "contextResolver",
|
|
7
|
-
category: "General",
|
|
8
|
-
});
|
|
9
|
-
|
|
10
4
|
interface IResolver {
|
|
11
5
|
resolve: (string) => Promise<string | number | object>;
|
|
12
6
|
}
|
|
@@ -64,12 +58,7 @@ export const resolveObjectValues = async (
|
|
|
64
58
|
return [key, resolvedValue];
|
|
65
59
|
}
|
|
66
60
|
|
|
67
|
-
|
|
68
|
-
key,
|
|
69
|
-
value,
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
return [key, null];
|
|
61
|
+
return [key, value];
|
|
73
62
|
})
|
|
74
63
|
);
|
|
75
64
|
|
|
@@ -97,7 +97,7 @@ export class Player {
|
|
|
97
97
|
this.onVideoLoad = this.onVideoLoad.bind(this);
|
|
98
98
|
this.isFullScreenSupported = this.isFullScreenSupported.bind(this);
|
|
99
99
|
this.onPlayerSeekComplete = this.onPlayerSeekComplete.bind(this);
|
|
100
|
-
|
|
100
|
+
this.onAdBreakEnd = this.onAdBreakEnd.bind(this);
|
|
101
101
|
this.entryObservable = null;
|
|
102
102
|
}
|
|
103
103
|
|
|
@@ -201,17 +201,25 @@ export class Player {
|
|
|
201
201
|
adPosition: currentTime,
|
|
202
202
|
};
|
|
203
203
|
} else {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
204
|
+
this.updateContentDuration({ seekableDuration, duration, currentTime });
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
207
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
208
|
+
protected updateContentDuration = ({
|
|
209
|
+
seekableDuration = null,
|
|
210
|
+
duration = null,
|
|
211
|
+
currentTime = null,
|
|
212
|
+
}) => {
|
|
213
|
+
if (!isEmptyOrNil(seekableDuration) && seekableDuration >= 0) {
|
|
214
|
+
this.playerState.seekableDuration = seekableDuration;
|
|
215
|
+
}
|
|
211
216
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
217
|
+
if (!isEmptyOrNil(duration) && duration >= 0) {
|
|
218
|
+
this.playerState.contentDuration = duration;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (!isEmptyOrNil(currentTime) && currentTime >= 0) {
|
|
222
|
+
this.playerState.contentPosition = currentTime;
|
|
215
223
|
}
|
|
216
224
|
};
|
|
217
225
|
|
|
@@ -559,7 +567,7 @@ export class Player {
|
|
|
559
567
|
});
|
|
560
568
|
};
|
|
561
569
|
|
|
562
|
-
onAdBreakEnd
|
|
570
|
+
onAdBreakEnd(event) {
|
|
563
571
|
this.playerState.adState = null;
|
|
564
572
|
this.playerState.isInAdBreak = false;
|
|
565
573
|
|
|
@@ -567,7 +575,7 @@ export class Player {
|
|
|
567
575
|
callbackName: SharedPlayerCallBacksKeys.OnAdBreakEnd,
|
|
568
576
|
event,
|
|
569
577
|
});
|
|
570
|
-
}
|
|
578
|
+
}
|
|
571
579
|
|
|
572
580
|
onAdEnd = (event) => {
|
|
573
581
|
this.playerState.adState = null;
|
|
@@ -225,7 +225,9 @@ export class PlayerNative extends Player {
|
|
|
225
225
|
};
|
|
226
226
|
|
|
227
227
|
onVideoLoad = (event) => {
|
|
228
|
-
|
|
228
|
+
this.updateContentDuration(event);
|
|
229
|
+
|
|
230
|
+
if (this.startPosition && !this.playerState.isInAdBreak) {
|
|
229
231
|
super.onVideoLoad({ ...event, ignoreContinueWatching: true });
|
|
230
232
|
|
|
231
233
|
this.seekTo(this.startPosition);
|
|
@@ -253,6 +255,15 @@ export class PlayerNative extends Player {
|
|
|
253
255
|
}
|
|
254
256
|
};
|
|
255
257
|
|
|
258
|
+
onAdBreakEnd = (event) => {
|
|
259
|
+
super.onAdBreakEnd(event);
|
|
260
|
+
|
|
261
|
+
if (this.startPosition) {
|
|
262
|
+
this.seekTo(this.startPosition);
|
|
263
|
+
this.startPosition = null;
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
|
|
256
267
|
// This function is called when native player used directly without wrapped component,
|
|
257
268
|
// Since event from native comes with wrapped in NativeEvent property
|
|
258
269
|
getNativeViewListener = (): QuickBrickPlayer.SharedPlayerCallBacks => {
|
package/dateUtils/index.ts
CHANGED
|
@@ -2,10 +2,12 @@ import dayjs from "dayjs";
|
|
|
2
2
|
import utc from "dayjs/plugin/utc";
|
|
3
3
|
import timezone from "dayjs/plugin/timezone";
|
|
4
4
|
import isoWeek from "dayjs/plugin/isoWeek";
|
|
5
|
+
import duration from "dayjs/plugin/duration";
|
|
5
6
|
|
|
6
7
|
// Extend dayjs with plugins
|
|
7
8
|
dayjs.extend(utc);
|
|
8
9
|
dayjs.extend(timezone);
|
|
9
10
|
dayjs.extend(isoWeek);
|
|
11
|
+
dayjs.extend(duration);
|
|
10
12
|
|
|
11
13
|
export { dayjs };
|
|
@@ -227,7 +227,9 @@ class FocusManager {
|
|
|
227
227
|
|
|
228
228
|
const nextNextFocus = FocusManager.getNextFocusable(direction, nextFocus);
|
|
229
229
|
|
|
230
|
-
|
|
230
|
+
if (nextNextFocus) {
|
|
231
|
+
FocusManager.instance.setFocus(nextNextFocus, options);
|
|
232
|
+
}
|
|
231
233
|
} else {
|
|
232
234
|
FocusManager.instance.setFocusLocal(nextFocus);
|
|
233
235
|
|
package/focusManager/index.ts
CHANGED
|
@@ -8,8 +8,6 @@ import { isNilOrEmpty } from "../reactUtils/helpers";
|
|
|
8
8
|
import { isAndroidTVPlatform } from "../reactUtils";
|
|
9
9
|
import { noop } from "../functionUtils";
|
|
10
10
|
|
|
11
|
-
const EMPTY_GROUP_COMPONENT = "empty_group_component";
|
|
12
|
-
|
|
13
11
|
export function useFocusManager() {
|
|
14
12
|
return focusManager;
|
|
15
13
|
}
|
|
@@ -76,14 +74,6 @@ export function useFocusEffect(onFocus, focusWatcher) {
|
|
|
76
74
|
}, focusWatcher);
|
|
77
75
|
}
|
|
78
76
|
|
|
79
|
-
export function shouldShowEmptyGroup(component) {
|
|
80
|
-
return (
|
|
81
|
-
component?.ui_components?.filter(
|
|
82
|
-
({ component_type }) => component_type === EMPTY_GROUP_COMPONENT
|
|
83
|
-
)?.length > 0
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
77
|
export const isFocusable = (component: ZappEntry | ZappUIComponent | any) =>
|
|
88
78
|
R.tryCatch(
|
|
89
79
|
R.compose(
|
|
@@ -101,6 +91,7 @@ type Props = {
|
|
|
101
91
|
|
|
102
92
|
export const useIsFocusable = (props: Props): void => {
|
|
103
93
|
const { component, zappPipesData } = props;
|
|
94
|
+
|
|
104
95
|
const { setIsFocusable } = useFocusable();
|
|
105
96
|
|
|
106
97
|
const componentCellsFocusable = toBooleanWithDefaultTrue(
|
|
@@ -119,12 +110,7 @@ export const useIsFocusable = (props: Props): void => {
|
|
|
119
110
|
|
|
120
111
|
const hasDataError = !!zappPipesData?.error;
|
|
121
112
|
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
const isGallery = component?.component_type === "gallery-qb";
|
|
125
|
-
|
|
126
|
-
const isHiddenDueToEmptyData =
|
|
127
|
-
!isLoadingData && hasNoData && hideIfDataEmpty && !hasEmptyGroup;
|
|
113
|
+
const isHiddenDueToEmptyData = !isLoadingData && hasNoData && hideIfDataEmpty;
|
|
128
114
|
|
|
129
115
|
const defaultFocusableLogic =
|
|
130
116
|
componentCellsFocusable && (!hasNoData || !hideIfDataEmpty);
|
|
@@ -133,9 +119,7 @@ export const useIsFocusable = (props: Props): void => {
|
|
|
133
119
|
if (isAndroidTVPlatform()) {
|
|
134
120
|
let isFocusableNew = false;
|
|
135
121
|
|
|
136
|
-
if (
|
|
137
|
-
isFocusableNew = true;
|
|
138
|
-
} else if (isFocusable(component)) {
|
|
122
|
+
if (isFocusable(component)) {
|
|
139
123
|
isFocusableNew = defaultFocusableLogic;
|
|
140
124
|
}
|
|
141
125
|
|
|
@@ -144,9 +128,7 @@ export const useIsFocusable = (props: Props): void => {
|
|
|
144
128
|
}, [
|
|
145
129
|
defaultFocusableLogic,
|
|
146
130
|
isHiddenDueToEmptyData,
|
|
147
|
-
isGallery,
|
|
148
131
|
setIsFocusable,
|
|
149
132
|
hasDataError,
|
|
150
|
-
hasEmptyGroup,
|
|
151
133
|
]);
|
|
152
134
|
};
|
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/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.6400875052",
|
|
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,7 +27,7 @@
|
|
|
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.6400875052",
|
|
32
31
|
"buffer": "^5.2.1",
|
|
33
32
|
"camelize": "^1.0.0",
|
|
34
33
|
"dayjs": "^1.11.10",
|
|
@@ -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
|
|
|
@@ -55,7 +55,9 @@ export const useFeedLoader = ({
|
|
|
55
55
|
|
|
56
56
|
const currentFeed = useZappPipesFeed(callableFeedUrl);
|
|
57
57
|
|
|
58
|
-
const riverId =
|
|
58
|
+
const riverId =
|
|
59
|
+
(screenData as LegacyNavigationScreenData)?.targetScreen?.id ??
|
|
60
|
+
screenData?.id;
|
|
59
61
|
|
|
60
62
|
const reloadData = React.useCallback<ReloadDataFunction>(
|
|
61
63
|
(silentRefresh = true, callback) => {
|
|
@@ -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
|
+
};
|
|
@@ -108,9 +108,11 @@ export function isNavBarVisible(
|
|
|
108
108
|
return false;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
const showSecondaryLevel =
|
|
112
|
-
(
|
|
113
|
-
|
|
111
|
+
const showSecondaryLevel =
|
|
112
|
+
!isTV() ||
|
|
113
|
+
screenData?.navigations?.some(
|
|
114
|
+
(navigation) => navigation.styles?.show_secondary_level_menu
|
|
115
|
+
);
|
|
114
116
|
|
|
115
117
|
if (canGoBack && !showSecondaryLevel) {
|
|
116
118
|
return false;
|
|
@@ -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 {
|
|
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
|
|
48
|
-
const hookModalState = useZappHooksModalState();
|
|
46
|
+
const modalState = useModalStoreState();
|
|
49
47
|
|
|
50
48
|
const modalScreenData = modalState.screen;
|
|
51
49
|
|
|
52
|
-
const hookModalScreenData =
|
|
50
|
+
const hookModalScreenData = useHookModalScreenData();
|
|
53
51
|
|
|
54
52
|
const videoModalScreenData =
|
|
55
53
|
navigator?.videoModalState?.item &&
|
package/utils/README.md
ADDED
|
@@ -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
package/utils/index.ts
ADDED
package/utils/times.ts
ADDED
|
@@ -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
|
-
|
|
95
|
+
`runInBackground: Background mode finished, ${isRefreshed ? "finish hook with completion true" : "refresh failed will presentUI"}`
|
|
94
96
|
);
|
|
95
97
|
|
|
96
|
-
|
|
98
|
+
isRefreshed
|
|
99
|
+
? callback({ success: isRefreshed, payload: item })
|
|
100
|
+
: presentUI();
|
|
97
101
|
|
|
98
102
|
return;
|
|
99
103
|
}
|