@applicaster/zapp-react-native-utils 13.0.0-rc.84 → 13.0.0-rc.85
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.
|
@@ -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,9 +19,15 @@ import {
|
|
|
19
19
|
EntryResolver,
|
|
20
20
|
resolveObjectValues,
|
|
21
21
|
} from "../appUtils/contextKeysManager/contextResolver";
|
|
22
|
+
import { useNavigation } from "../reactHooks";
|
|
22
23
|
import { get } from "lodash";
|
|
23
24
|
|
|
24
|
-
|
|
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({
|
|
25
31
|
subsystem: "ActionExecutorContext",
|
|
26
32
|
category: "General",
|
|
27
33
|
});
|
|
@@ -233,6 +239,10 @@ export function withActionExecutor(Component) {
|
|
|
233
239
|
prepareDefaultActions(_actionExecutor);
|
|
234
240
|
|
|
235
241
|
return function ActionExecutorComponent(props: Props) {
|
|
242
|
+
const navigator = useNavigation();
|
|
243
|
+
const { rivers } = usePickFromState(["rivers"]);
|
|
244
|
+
const contentTypes = useContentTypes();
|
|
245
|
+
|
|
236
246
|
const handlers = useMemo(() => {
|
|
237
247
|
return {
|
|
238
248
|
unregisterAction: _actionExecutor.unregisterAction,
|
|
@@ -243,6 +253,43 @@ export function withActionExecutor(Component) {
|
|
|
243
253
|
};
|
|
244
254
|
}, []);
|
|
245
255
|
|
|
256
|
+
useEffect(() => {
|
|
257
|
+
return _actionExecutor.registerAction(
|
|
258
|
+
"navigateToScreen",
|
|
259
|
+
async (action: ActionType, _context?: Record<string, any>) => {
|
|
260
|
+
const screenType = action.options?.typeMapping;
|
|
261
|
+
|
|
262
|
+
if (!screenType) {
|
|
263
|
+
log_error("navigateToScreen: typeMapping option is missing");
|
|
264
|
+
|
|
265
|
+
return ActionResult.Error;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const screenId = contentTypes?.[screenType]?.screen_id || null;
|
|
269
|
+
|
|
270
|
+
if (!screenId) {
|
|
271
|
+
log_error(
|
|
272
|
+
`navigateToScreen: can not resolve screen type mapping: ${screenType}`
|
|
273
|
+
);
|
|
274
|
+
|
|
275
|
+
return ActionResult.Error;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const river = rivers[screenId];
|
|
279
|
+
|
|
280
|
+
if (!river) {
|
|
281
|
+
log_error("navigateToScreen: can not resolve river");
|
|
282
|
+
|
|
283
|
+
return ActionResult.Error;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
navigator.replace(river);
|
|
287
|
+
|
|
288
|
+
return ActionResult.Success;
|
|
289
|
+
}
|
|
290
|
+
);
|
|
291
|
+
}, [navigator, rivers, contentTypes]);
|
|
292
|
+
|
|
246
293
|
return (
|
|
247
294
|
<ActionExecutorContext.Provider value={handlers}>
|
|
248
295
|
<Component {...props} />
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "13.0.0-rc.
|
|
3
|
+
"version": "13.0.0-rc.85",
|
|
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-rc.
|
|
30
|
+
"@applicaster/applicaster-types": "13.0.0-rc.85",
|
|
31
31
|
"buffer": "^5.2.1",
|
|
32
32
|
"camelize": "^1.0.0",
|
|
33
33
|
"dayjs": "^1.11.10",
|