@applicaster/zapp-react-native-utils 13.0.0-alpha.2545325570 → 13.0.0-alpha.2614386581
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/dateUtils/index.ts +2 -0
- package/focusManager/FocusManager.ts +3 -1
- package/focusManager/index.ts +4 -30
- package/index.d.ts +0 -12
- package/package.json +2 -2
- package/reactHooks/feed/useFeedLoader.tsx +4 -2
- package/reactHooks/hookModal/hooks/useHookModalScreenData.ts +39 -0
- package/reactHooks/navigation/useRoute.ts +2 -4
- 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
|
|
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(
|
|
@@ -117,33 +108,18 @@ export const useIsFocusable = (props: Props): void => {
|
|
|
117
108
|
isNilOrEmpty(zappPipesData?.data) ||
|
|
118
109
|
isNilOrEmpty(zappPipesData?.data?.entry);
|
|
119
110
|
|
|
120
|
-
const hasNoUIComponents = isNilOrEmpty(component?.ui_components);
|
|
121
|
-
|
|
122
111
|
const hasDataError = !!zappPipesData?.error;
|
|
123
112
|
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
const isGallery = component?.component_type === "gallery-qb";
|
|
127
|
-
|
|
128
|
-
const isGroup = component?.component_type === "group-qb";
|
|
129
|
-
|
|
130
|
-
const isHiddenDueToEmptyData =
|
|
131
|
-
!isLoadingData && hasNoData && hideIfDataEmpty && !hasEmptyGroup;
|
|
132
|
-
|
|
133
|
-
const isEmptyGroup = isGroup && hasNoUIComponents;
|
|
113
|
+
const isHiddenDueToEmptyData = !isLoadingData && hasNoData && hideIfDataEmpty;
|
|
134
114
|
|
|
135
115
|
const defaultFocusableLogic =
|
|
136
|
-
componentCellsFocusable &&
|
|
137
|
-
(!hasNoData || !hideIfDataEmpty) &&
|
|
138
|
-
!isEmptyGroup;
|
|
116
|
+
componentCellsFocusable && (!hasNoData || !hideIfDataEmpty);
|
|
139
117
|
|
|
140
118
|
React.useEffect(() => {
|
|
141
119
|
if (isAndroidTVPlatform()) {
|
|
142
120
|
let isFocusableNew = false;
|
|
143
121
|
|
|
144
|
-
if (
|
|
145
|
-
isFocusableNew = true;
|
|
146
|
-
} else if (isFocusable(component)) {
|
|
122
|
+
if (isFocusable(component)) {
|
|
147
123
|
isFocusableNew = defaultFocusableLogic;
|
|
148
124
|
}
|
|
149
125
|
|
|
@@ -152,9 +128,7 @@ export const useIsFocusable = (props: Props): void => {
|
|
|
152
128
|
}, [
|
|
153
129
|
defaultFocusableLogic,
|
|
154
130
|
isHiddenDueToEmptyData,
|
|
155
|
-
isGallery,
|
|
156
131
|
setIsFocusable,
|
|
157
132
|
hasDataError,
|
|
158
|
-
hasEmptyGroup,
|
|
159
133
|
]);
|
|
160
134
|
};
|
package/index.d.ts
CHANGED
|
@@ -105,18 +105,6 @@ declare type NavBarState = {
|
|
|
105
105
|
title: string;
|
|
106
106
|
};
|
|
107
107
|
|
|
108
|
-
declare type StorageValuesToAdd = Record<string, NamespaceValues>;
|
|
109
|
-
|
|
110
|
-
declare type StorageValuesToRemove = {
|
|
111
|
-
string?: string[];
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
declare type StorageOwnedValues = {
|
|
115
|
-
string?: string[];
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
declare type NamespaceValues = Record<string, string>;
|
|
119
|
-
|
|
120
108
|
declare type RefreshProps = {
|
|
121
109
|
forceRefresh?: boolean;
|
|
122
110
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "13.0.0-alpha.
|
|
3
|
+
"version": "13.0.0-alpha.2614386581",
|
|
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.
|
|
30
|
+
"@applicaster/applicaster-types": "13.0.0-alpha.2614386581",
|
|
31
31
|
"buffer": "^5.2.1",
|
|
32
32
|
"camelize": "^1.0.0",
|
|
33
33
|
"dayjs": "^1.11.10",
|
|
@@ -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
|
+
};
|
|
@@ -7,9 +7,8 @@ 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
14
|
import { useModalStore } from "../../modalState";
|
|
@@ -45,11 +44,10 @@ export const useRoute = (): {
|
|
|
45
44
|
]);
|
|
46
45
|
|
|
47
46
|
const { modalState } = useModalStore();
|
|
48
|
-
const hookModalState = useZappHooksModalState();
|
|
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
|
}
|