@applicaster/zapp-react-native-utils 14.0.0-alpha.9203091422 → 14.0.0-alpha.9551591420
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 +83 -60
- package/analyticsUtils/AnalyticsEvents/helper.ts +1 -1
- package/appUtils/contextKeysManager/contextResolver.ts +1 -14
- package/appUtils/focusManager/treeDataStructure/Tree/index.js +1 -1
- package/navigationUtils/__tests__/mapContentTypesToRivers.test.ts +130 -0
- package/navigationUtils/index.ts +6 -4
- package/package.json +2 -3
- package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +3 -1
- package/reactHooks/cell-click/index.ts +1 -8
- package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +0 -20
- package/reactHooks/feed/useBatchLoading.ts +8 -6
- package/reactHooks/feed/useFeedLoader.tsx +14 -17
- package/reactHooks/feed/usePipesCacheReset.ts +2 -2
- package/reactHooks/flatList/useSequentialRenderItem.tsx +3 -3
- package/reactHooks/layout/__tests__/index.test.tsx +3 -1
- package/reactHooks/layout/useDimensions/__tests__/useDimensions.test.ts +34 -36
- package/reactHooks/layout/useDimensions/useDimensions.ts +2 -3
- package/reactHooks/layout/useLayoutVersion.ts +5 -5
- package/reactHooks/navigation/useRoute.ts +2 -7
- package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +4 -0
- package/reactHooks/state/useRivers.ts +7 -8
- package/time/BackgroundTimer.ts +1 -1
- package/utils/index.ts +1 -0
- package/actionsExecutor/ScreenActions.ts +0 -163
- package/actionsExecutor/StorageActions.ts +0 -110
- package/actionsExecutor/feedDecorator.ts +0 -171
- package/actionsExecutor/screenResolver.ts +0 -11
- package/reactHooks/navigation/useScreenStateStore.ts +0 -8
- package/storage/ScreenSingleValueProvider.ts +0 -201
- package/storage/ScreenStateMultiSelectProvider.ts +0 -290
- package/storage/StorageMultiSelectProvider.ts +0 -192
- package/storage/StorageSingleSelectProvider.ts +0 -108
|
@@ -16,6 +16,7 @@ import { QUICK_BRICK_EVENTS } from "@applicaster/zapp-react-native-bridge/QuickB
|
|
|
16
16
|
import { showConfirmationDialog } from "../alertUtils";
|
|
17
17
|
import { createCloudEvent, sendCloudEvent } from "../cloudEventsUtils";
|
|
18
18
|
import { createLogger } from "../logger";
|
|
19
|
+
import { StorageMultiSelectProvider } from "@applicaster/zapp-react-native-bridge/ZappStorage/StorageMultiSelectProvider";
|
|
19
20
|
import { ACTIVE_LAYOUT_ID_STORAGE_KEY } from "@applicaster/quick-brick-core/App/remoteContextReloader/consts";
|
|
20
21
|
import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
|
|
21
22
|
import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
|
|
@@ -24,19 +25,15 @@ import {
|
|
|
24
25
|
resolveObjectValues,
|
|
25
26
|
} from "../appUtils/contextKeysManager/contextResolver";
|
|
26
27
|
import { useNavigation } from "../reactHooks";
|
|
28
|
+
import { get } from "../utils";
|
|
27
29
|
|
|
28
30
|
import {
|
|
29
31
|
useContentTypes,
|
|
30
32
|
usePickFromState,
|
|
31
33
|
} from "@applicaster/zapp-react-native-redux/hooks";
|
|
32
|
-
import {
|
|
34
|
+
import { TOGGLE_FLAG_MAX_ITEMS_REACHED_EVENT } from "./consts";
|
|
35
|
+
import { postEvent, useSubscriberFor } from "../reactHooks/useSubscriberFor";
|
|
33
36
|
import { APP_EVENTS } from "../appUtils/events";
|
|
34
|
-
import {
|
|
35
|
-
localStorageToggleFlag,
|
|
36
|
-
sessionStorageToggleFlag,
|
|
37
|
-
} from "./StorageActions";
|
|
38
|
-
|
|
39
|
-
import { screenSetVariable, screenToggleFlag } from "./ScreenActions";
|
|
40
37
|
|
|
41
38
|
export const { log_error, log_info, log_debug } = createLogger({
|
|
42
39
|
subsystem: "ActionExecutorContext",
|
|
@@ -85,6 +82,19 @@ function findParentComponent(
|
|
|
85
82
|
return null;
|
|
86
83
|
}
|
|
87
84
|
|
|
85
|
+
// send all data just in case (like for message string formatting)
|
|
86
|
+
// Type is not exported for now
|
|
87
|
+
type MaxTagsReachedEvent = {
|
|
88
|
+
selectedItems: string[];
|
|
89
|
+
maxItems: number;
|
|
90
|
+
tag: string;
|
|
91
|
+
keyNamespace: string;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
async function onMaxTagsReached(data: MaxTagsReachedEvent) {
|
|
95
|
+
postEvent(TOGGLE_FLAG_MAX_ITEMS_REACHED_EVENT, [data]);
|
|
96
|
+
}
|
|
97
|
+
|
|
88
98
|
const prepareDefaultActions = (actionExecutor) => {
|
|
89
99
|
actionExecutor.registerAction("localStorageSet", async (action) => {
|
|
90
100
|
const namespaces = action.options.content;
|
|
@@ -168,15 +178,10 @@ const prepareDefaultActions = (actionExecutor) => {
|
|
|
168
178
|
|
|
169
179
|
const entry = context?.entry || {};
|
|
170
180
|
const entryResolver = new EntryResolver(entry);
|
|
171
|
-
const screenData = context?.screenStateStore.getState().data || {};
|
|
172
|
-
const screenResolver = new EntryResolver(screenData || {});
|
|
173
181
|
|
|
174
182
|
const data =
|
|
175
183
|
options?.data && options.inflateData
|
|
176
|
-
? await resolveObjectValues(options.data, {
|
|
177
|
-
entry: entryResolver,
|
|
178
|
-
screen: screenResolver,
|
|
179
|
-
})
|
|
184
|
+
? await resolveObjectValues(options.data, { entry: entryResolver })
|
|
180
185
|
: options?.data || entry;
|
|
181
186
|
|
|
182
187
|
const cloudEvent = await createCloudEvent({
|
|
@@ -210,63 +215,81 @@ const prepareDefaultActions = (actionExecutor) => {
|
|
|
210
215
|
return ActionResult.Error;
|
|
211
216
|
});
|
|
212
217
|
|
|
213
|
-
actionExecutor.registerAction(
|
|
214
|
-
"sessionStorageToggleFlag",
|
|
215
|
-
async (
|
|
216
|
-
action: ActionType,
|
|
217
|
-
context?: Record<string, any>
|
|
218
|
-
): Promise<ActionResult> => {
|
|
219
|
-
return await sessionStorageToggleFlag(context, action);
|
|
220
|
-
}
|
|
221
|
-
);
|
|
222
|
-
|
|
223
218
|
actionExecutor.registerAction(
|
|
224
219
|
"localStorageToggleFlag",
|
|
225
220
|
async (
|
|
226
221
|
action: ActionType,
|
|
227
222
|
context?: Record<string, any>
|
|
228
223
|
): Promise<ActionResult> => {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
224
|
+
if (!context) {
|
|
225
|
+
log_error(
|
|
226
|
+
"handleAction: localStorageToggleFlag action missing context"
|
|
227
|
+
);
|
|
232
228
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
async (
|
|
236
|
-
action: ActionType,
|
|
237
|
-
context?: Record<string, any>
|
|
238
|
-
): Promise<ActionResult> => {
|
|
239
|
-
const route = context?.screenRoute;
|
|
240
|
-
const screenStateStore = context?.screenStateStore;
|
|
241
|
-
|
|
242
|
-
await screenSetVariable(
|
|
243
|
-
route,
|
|
244
|
-
screenStateStore,
|
|
245
|
-
{ entry: context?.entry, options: action.options },
|
|
246
|
-
action
|
|
247
|
-
);
|
|
229
|
+
return ActionResult.Error;
|
|
230
|
+
}
|
|
248
231
|
|
|
249
|
-
|
|
250
|
-
}
|
|
251
|
-
);
|
|
232
|
+
const entry = context?.entry as ZappEntry;
|
|
252
233
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
)
|
|
234
|
+
if (!entry) {
|
|
235
|
+
log_error(
|
|
236
|
+
"handleAction: localStorageToggleFlag action missing entry. Entry is required to get the tag."
|
|
237
|
+
);
|
|
238
|
+
|
|
239
|
+
return ActionResult.Error;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const tag = action.options?.selector
|
|
243
|
+
? get(entry, action.options.selector)
|
|
244
|
+
: (entry.extensions?.tag ?? entry.id);
|
|
245
|
+
|
|
246
|
+
const keyNamespace = action.options?.key;
|
|
247
|
+
|
|
248
|
+
if (keyNamespace && tag) {
|
|
249
|
+
const multiSelectProvider =
|
|
250
|
+
StorageMultiSelectProvider.getProvider(keyNamespace);
|
|
251
|
+
|
|
252
|
+
const selectedItems = await multiSelectProvider.getSelectedAsync();
|
|
253
|
+
const isTagInSelectedItems = selectedItems.includes(tag);
|
|
268
254
|
|
|
269
|
-
|
|
255
|
+
log_info(
|
|
256
|
+
`handleAction: localStorageToggleFlag event will ${
|
|
257
|
+
isTagInSelectedItems ? "remove" : "add"
|
|
258
|
+
} tag: ${tag} for keyNamespace: ${keyNamespace}, current selectedItems: ${selectedItems}`
|
|
259
|
+
);
|
|
260
|
+
|
|
261
|
+
if (selectedItems.includes(tag)) {
|
|
262
|
+
await multiSelectProvider.removeItem(tag);
|
|
263
|
+
} else {
|
|
264
|
+
const maxItems = action.options?.max_items;
|
|
265
|
+
|
|
266
|
+
if (maxItems && selectedItems.length >= maxItems) {
|
|
267
|
+
log_info(
|
|
268
|
+
`handleAction: localStorageToggleFlag event reached max items limit: ${maxItems}, cannot add tag: ${tag}`
|
|
269
|
+
);
|
|
270
|
+
|
|
271
|
+
await onMaxTagsReached({
|
|
272
|
+
selectedItems,
|
|
273
|
+
maxItems,
|
|
274
|
+
tag,
|
|
275
|
+
keyNamespace,
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
return ActionResult.Cancel;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
await multiSelectProvider.addItem(tag);
|
|
282
|
+
}
|
|
283
|
+
} else {
|
|
284
|
+
log_error(
|
|
285
|
+
"handleAction: localStorageToggleFlag event missing keyNamespace or tag",
|
|
286
|
+
{ keyNamespace, tag }
|
|
287
|
+
);
|
|
288
|
+
|
|
289
|
+
return ActionResult.Error;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
return ActionResult.Success;
|
|
270
293
|
}
|
|
271
294
|
);
|
|
272
295
|
};
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from "../events";
|
|
10
10
|
import { isEmptyOrNil } from "../../cellUtils";
|
|
11
11
|
import { get } from "lodash";
|
|
12
|
-
import { StorageMultiSelectProvider } from "@applicaster/zapp-react-native-
|
|
12
|
+
import { StorageMultiSelectProvider } from "@applicaster/zapp-react-native-bridge/ZappStorage/StorageMultiSelectProvider";
|
|
13
13
|
|
|
14
14
|
export enum OfflineItemState {
|
|
15
15
|
notExist = "NOT_EXISTS",
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { ContextKeysManager } from "./index";
|
|
2
2
|
import * as R from "ramda";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
interface IResolver {
|
|
5
5
|
resolve: (string) => Promise<string | number | object>;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
// TODO: Rename to ObjectKeyResolver or similar
|
|
9
8
|
export class EntryResolver implements IResolver {
|
|
10
9
|
entry: ZappEntry;
|
|
11
10
|
|
|
@@ -22,18 +21,6 @@ export class EntryResolver implements IResolver {
|
|
|
22
21
|
}
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
// TODO: Move to proper place
|
|
26
|
-
|
|
27
|
-
export class ScreenStateResolver implements IResolver {
|
|
28
|
-
constructor(private screenStateStore: ScreenStateStore) {}
|
|
29
|
-
|
|
30
|
-
async resolve(key: string) {
|
|
31
|
-
const screenState = this.screenStateStore.getState().data;
|
|
32
|
-
|
|
33
|
-
return screenState?.[key];
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
24
|
export class ContextResolver implements IResolver {
|
|
38
25
|
resolve = async (compositeKey: string) =>
|
|
39
26
|
ContextKeysManager.instance.getKey(compositeKey);
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { mapContentTypesToRivers } from "../index";
|
|
2
|
+
|
|
3
|
+
describe("mapContentTypesToRivers", () => {
|
|
4
|
+
it("should return the correct content types mapped to rivers", () => {
|
|
5
|
+
const state = {
|
|
6
|
+
rivers: {
|
|
7
|
+
"river-1": {
|
|
8
|
+
plugin_type: "river",
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
contentTypes: {
|
|
12
|
+
"content-type-1": {
|
|
13
|
+
screen_id: "river-1",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const result = mapContentTypesToRivers(state);
|
|
19
|
+
|
|
20
|
+
expect(result).toEqual({
|
|
21
|
+
"content-type-1": {
|
|
22
|
+
screenType: "river",
|
|
23
|
+
screen_id: "river-1",
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("should return null if contentTypes is undefined", () => {
|
|
29
|
+
const state = {
|
|
30
|
+
rivers: {
|
|
31
|
+
"river-1": {
|
|
32
|
+
plugin_type: "river",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
// contentTypes is missing
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const result = mapContentTypesToRivers(state);
|
|
39
|
+
|
|
40
|
+
expect(result).toBeNull();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("should skip content types whose screen does not exist in rivers", () => {
|
|
44
|
+
const state = {
|
|
45
|
+
rivers: {
|
|
46
|
+
"river-1": {
|
|
47
|
+
plugin_type: "river",
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
contentTypes: {
|
|
51
|
+
"content-type-1": {
|
|
52
|
+
screen_id: "river-1",
|
|
53
|
+
},
|
|
54
|
+
"content-type-2": {
|
|
55
|
+
screen_id: "river-2", // river-2 does not exist
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const result = mapContentTypesToRivers(state);
|
|
61
|
+
|
|
62
|
+
expect(result).toEqual({
|
|
63
|
+
"content-type-1": {
|
|
64
|
+
screenType: "river",
|
|
65
|
+
screen_id: "river-1",
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// result is not null, but may be undefined for missing keys
|
|
70
|
+
expect(result && result["content-type-2"]).toBeUndefined();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("should use 'type' if 'plugin_type' is not present in river", () => {
|
|
74
|
+
const state = {
|
|
75
|
+
rivers: {
|
|
76
|
+
"river-1": {
|
|
77
|
+
type: "custom-type",
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
contentTypes: {
|
|
81
|
+
"content-type-1": {
|
|
82
|
+
screen_id: "river-1",
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const result = mapContentTypesToRivers(state);
|
|
88
|
+
|
|
89
|
+
expect(result).toEqual({
|
|
90
|
+
"content-type-1": {
|
|
91
|
+
screenType: "custom-type",
|
|
92
|
+
screen_id: "river-1",
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("should skip content types if neither plugin_type nor type is present in river", () => {
|
|
98
|
+
const state = {
|
|
99
|
+
rivers: {
|
|
100
|
+
"river-1": {
|
|
101
|
+
// no plugin_type or type
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
contentTypes: {
|
|
105
|
+
"content-type-1": {
|
|
106
|
+
screen_id: "river-1",
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const result = mapContentTypesToRivers(state);
|
|
112
|
+
|
|
113
|
+
expect(result).toEqual({});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it("should handle empty contentTypes object", () => {
|
|
117
|
+
const state = {
|
|
118
|
+
rivers: {
|
|
119
|
+
"river-1": {
|
|
120
|
+
plugin_type: "river",
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
contentTypes: {},
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const result = mapContentTypesToRivers(state);
|
|
127
|
+
|
|
128
|
+
expect(result).toEqual({});
|
|
129
|
+
});
|
|
130
|
+
});
|
package/navigationUtils/index.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
isPlayable,
|
|
14
14
|
isV2River,
|
|
15
15
|
} from "./itemTypeMatchers";
|
|
16
|
+
import { RootState } from "@applicaster/zapp-react-native-redux/store";
|
|
16
17
|
|
|
17
18
|
type PathAttribute = {
|
|
18
19
|
screenType: string;
|
|
@@ -377,10 +378,11 @@ export const usesVideoModal = (
|
|
|
377
378
|
return targetScreenConfiguration?.styles?.use_video_modal;
|
|
378
379
|
};
|
|
379
380
|
|
|
380
|
-
export const mapContentTypesToRivers = (
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
381
|
+
export const mapContentTypesToRivers = (
|
|
382
|
+
state: Partial<RootState>
|
|
383
|
+
): ZappContentTypesMapped | null => {
|
|
384
|
+
const { rivers, contentTypes } = state;
|
|
385
|
+
|
|
384
386
|
if (!contentTypes) {
|
|
385
387
|
return null;
|
|
386
388
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "14.0.0-alpha.
|
|
3
|
+
"version": "14.0.0-alpha.9551591420",
|
|
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": "14.0.0-alpha.
|
|
30
|
+
"@applicaster/applicaster-types": "14.0.0-alpha.9551591420",
|
|
31
31
|
"buffer": "^5.2.1",
|
|
32
32
|
"camelize": "^1.0.0",
|
|
33
33
|
"dayjs": "^1.11.10",
|
|
@@ -38,7 +38,6 @@
|
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@applicaster/zapp-pipes-v2-client": "*",
|
|
40
40
|
"@react-native-community/netinfo": "*",
|
|
41
|
-
"immer": "*",
|
|
42
41
|
"react": "*",
|
|
43
42
|
"react-native": "*",
|
|
44
43
|
"uglify-js": "*",
|
|
@@ -23,7 +23,9 @@ jest.mock(
|
|
|
23
23
|
|
|
24
24
|
jest.useFakeTimers();
|
|
25
25
|
|
|
26
|
-
jest.mock(
|
|
26
|
+
jest.mock(
|
|
27
|
+
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation"
|
|
28
|
+
);
|
|
27
29
|
|
|
28
30
|
const mockStore = configureStore();
|
|
29
31
|
|
|
@@ -16,8 +16,7 @@ import { ActionExecutorContext } from "@applicaster/zapp-react-native-utils/acti
|
|
|
16
16
|
import { isFunction, noop } from "../../functionUtils";
|
|
17
17
|
import { useSendAnalyticsOnPress } from "../analytics";
|
|
18
18
|
import { logOnPress, warnEmptyContentType } from "./helpers";
|
|
19
|
-
import { useCurrentScreenData
|
|
20
|
-
import { useScreenStateStore } from "../navigation/useScreenStateStore";
|
|
19
|
+
import { useCurrentScreenData } from "../screen";
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
22
|
* If onCellTap is defined execute the function and
|
|
@@ -43,12 +42,10 @@ export const useCellClick = ({
|
|
|
43
42
|
}: Props): onPressReturnFn => {
|
|
44
43
|
const { push, currentRoute } = useNavigation();
|
|
45
44
|
const { pathname } = useRoute();
|
|
46
|
-
const screenStateStore = useScreenStateStore();
|
|
47
45
|
|
|
48
46
|
const onCellTap: Option<Function> = React.useContext(CellTapContext);
|
|
49
47
|
const actionExecutor = React.useContext(ActionExecutorContext);
|
|
50
48
|
const screenData = useCurrentScreenData();
|
|
51
|
-
const screenState = useScreenContext()?.options;
|
|
52
49
|
|
|
53
50
|
const cellSelectable = toBooleanWithDefaultTrue(
|
|
54
51
|
component?.rules?.component_cells_selectable
|
|
@@ -86,9 +83,6 @@ export const useCellClick = ({
|
|
|
86
83
|
await actionExecutor?.handleEntryActions(selectedItem, {
|
|
87
84
|
component,
|
|
88
85
|
screenData,
|
|
89
|
-
screenState,
|
|
90
|
-
screenRoute: pathname,
|
|
91
|
-
screenStateStore,
|
|
92
86
|
});
|
|
93
87
|
}
|
|
94
88
|
|
|
@@ -123,7 +117,6 @@ export const useCellClick = ({
|
|
|
123
117
|
push,
|
|
124
118
|
sendAnalyticsOnPress,
|
|
125
119
|
screenData,
|
|
126
|
-
screenState,
|
|
127
120
|
]
|
|
128
121
|
);
|
|
129
122
|
|
|
@@ -138,11 +138,6 @@ describe("useFeedLoader", () => {
|
|
|
138
138
|
expect(loadPipesDataSpy).toBeCalledWith(feedUrl, {
|
|
139
139
|
clearCache: true,
|
|
140
140
|
riverId: undefined,
|
|
141
|
-
resolvers: {
|
|
142
|
-
screen: {
|
|
143
|
-
screenStateStore: undefined,
|
|
144
|
-
},
|
|
145
|
-
},
|
|
146
141
|
});
|
|
147
142
|
|
|
148
143
|
const store2 = mockStore({
|
|
@@ -184,11 +179,6 @@ describe("useFeedLoader", () => {
|
|
|
184
179
|
expect(loadPipesDataSpy).toBeCalledWith(feedUrl, {
|
|
185
180
|
clearCache: true,
|
|
186
181
|
riverId: undefined,
|
|
187
|
-
resolvers: {
|
|
188
|
-
screen: {
|
|
189
|
-
screenStateStore: undefined,
|
|
190
|
-
},
|
|
191
|
-
},
|
|
192
182
|
});
|
|
193
183
|
|
|
194
184
|
const store2 = mockStore({
|
|
@@ -238,11 +228,6 @@ describe("useFeedLoader", () => {
|
|
|
238
228
|
expect(loadPipesDataSpy).toBeCalledWith(feedUrl, {
|
|
239
229
|
clearCache: true,
|
|
240
230
|
silentRefresh: true,
|
|
241
|
-
resolvers: {
|
|
242
|
-
screen: {
|
|
243
|
-
screenStateStore: undefined,
|
|
244
|
-
},
|
|
245
|
-
},
|
|
246
231
|
});
|
|
247
232
|
|
|
248
233
|
loadPipesDataSpy.mockRestore();
|
|
@@ -282,11 +267,6 @@ describe("useFeedLoader", () => {
|
|
|
282
267
|
expect(loadPipesDataSpy).toBeCalledWith(nextUrl, {
|
|
283
268
|
parentFeed: feedUrlWithNext,
|
|
284
269
|
silentRefresh: true,
|
|
285
|
-
resolvers: {
|
|
286
|
-
screen: {
|
|
287
|
-
screenStateStore: undefined,
|
|
288
|
-
},
|
|
289
|
-
},
|
|
290
270
|
});
|
|
291
271
|
|
|
292
272
|
loadPipesDataSpy.mockRestore();
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { complement, compose, isNil, map, min, prop, take, uniq } from "ramda";
|
|
2
|
-
import { useDispatch } from "react-redux";
|
|
3
2
|
import * as React from "react";
|
|
4
|
-
import {
|
|
5
|
-
|
|
3
|
+
import {
|
|
4
|
+
ZappPipes,
|
|
5
|
+
useAppDispatch,
|
|
6
|
+
useZappPipesFeed,
|
|
7
|
+
} from "@applicaster/zapp-react-native-redux";
|
|
6
8
|
import { isNilOrEmpty } from "../../reactUtils/helpers";
|
|
7
9
|
import { ZappPipesSearchContext } from "@applicaster/zapp-react-native-ui-components/Contexts";
|
|
8
10
|
import {
|
|
@@ -63,7 +65,7 @@ export const useBatchLoading = (
|
|
|
63
65
|
componentsToRender: { data?: ZappDataSource; component_type: string }[],
|
|
64
66
|
options: Options
|
|
65
67
|
) => {
|
|
66
|
-
const dispatch =
|
|
68
|
+
const dispatch = useAppDispatch();
|
|
67
69
|
const { screen: screenContext, entry: entryContext } = useScreenContext();
|
|
68
70
|
const [searchContext] = ZappPipesSearchContext.useZappPipesContext();
|
|
69
71
|
const [hasEverBeenReady, setHasEverBeenReady] = React.useState(false);
|
|
@@ -118,7 +120,7 @@ export const useBatchLoading = (
|
|
|
118
120
|
[]
|
|
119
121
|
);
|
|
120
122
|
|
|
121
|
-
const feeds =
|
|
123
|
+
const feeds = useZappPipesFeed(feedUrls);
|
|
122
124
|
|
|
123
125
|
// dispatch loadPipesData for each feed that is not loaded
|
|
124
126
|
const runBatchLoading = React.useCallback(() => {
|
|
@@ -139,7 +141,7 @@ export const useBatchLoading = (
|
|
|
139
141
|
if (mappedFeedUrl) {
|
|
140
142
|
// 4. load data
|
|
141
143
|
return dispatch(
|
|
142
|
-
loadPipesData(mappedFeedUrl, { riverId: options.riverId })
|
|
144
|
+
ZappPipes.loadPipesData(mappedFeedUrl, { riverId: options.riverId })
|
|
143
145
|
);
|
|
144
146
|
}
|
|
145
147
|
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import React, { useEffect } from "react";
|
|
2
|
-
import { useDispatch } from "react-redux";
|
|
3
2
|
|
|
4
|
-
import {
|
|
5
|
-
|
|
3
|
+
import {
|
|
4
|
+
ZappPipes,
|
|
5
|
+
useAppDispatch,
|
|
6
|
+
useZappPipesFeed,
|
|
7
|
+
} from "@applicaster/zapp-react-native-redux";
|
|
6
8
|
|
|
7
9
|
import { reactHooksLogger } from "../logger";
|
|
8
10
|
import { shouldDispatchData, useIsInitialRender } from "../utils";
|
|
9
11
|
import { useInflatedUrl } from "./useInflatedUrl";
|
|
10
12
|
import { useRoute } from "../navigation";
|
|
11
|
-
import { useScreenResolvers } from "@applicaster/zapp-react-native-utils/actionsExecutor/screenResolver";
|
|
12
13
|
|
|
13
14
|
const logger = reactHooksLogger.addSubsystem("useFeedLoader");
|
|
14
15
|
|
|
@@ -50,9 +51,8 @@ export const useFeedLoader = ({
|
|
|
50
51
|
}, []);
|
|
51
52
|
|
|
52
53
|
const isInitialRender = useIsInitialRender();
|
|
53
|
-
const dispatch =
|
|
54
|
+
const dispatch = useAppDispatch();
|
|
54
55
|
const { screenData } = useRoute();
|
|
55
|
-
const resolvers = useScreenResolvers();
|
|
56
56
|
|
|
57
57
|
const callableFeedUrl = useInflatedUrl({ feedUrl, mapping });
|
|
58
58
|
|
|
@@ -66,17 +66,16 @@ export const useFeedLoader = ({
|
|
|
66
66
|
(silentRefresh = true, callback) => {
|
|
67
67
|
if (callableFeedUrl) {
|
|
68
68
|
dispatch(
|
|
69
|
-
loadPipesData(callableFeedUrl, {
|
|
69
|
+
ZappPipes.loadPipesData(callableFeedUrl, {
|
|
70
70
|
clearCache: true,
|
|
71
71
|
silentRefresh,
|
|
72
72
|
callback,
|
|
73
73
|
riverId,
|
|
74
|
-
resolvers,
|
|
75
74
|
})
|
|
76
75
|
);
|
|
77
76
|
}
|
|
78
77
|
},
|
|
79
|
-
[callableFeedUrl
|
|
78
|
+
[callableFeedUrl]
|
|
80
79
|
);
|
|
81
80
|
|
|
82
81
|
const loadNext: FeedLoaderResponse["loadNext"] = React.useCallback(() => {
|
|
@@ -85,16 +84,15 @@ export const useFeedLoader = ({
|
|
|
85
84
|
|
|
86
85
|
if (nextFeed) {
|
|
87
86
|
dispatch(
|
|
88
|
-
loadPipesData(nextFeed, {
|
|
87
|
+
ZappPipes.loadPipesData(nextFeed, {
|
|
89
88
|
silentRefresh: true,
|
|
90
89
|
parentFeed: callableFeedUrl,
|
|
91
90
|
riverId,
|
|
92
|
-
resolvers,
|
|
93
91
|
})
|
|
94
92
|
);
|
|
95
93
|
}
|
|
96
94
|
}
|
|
97
|
-
}, [callableFeedUrl, currentFeed?.data?.next
|
|
95
|
+
}, [callableFeedUrl, currentFeed?.data?.next]);
|
|
98
96
|
|
|
99
97
|
useEffect(() => {
|
|
100
98
|
if (
|
|
@@ -102,11 +100,10 @@ export const useFeedLoader = ({
|
|
|
102
100
|
) {
|
|
103
101
|
if (callableFeedUrl && !pipesOptions.skipLoading) {
|
|
104
102
|
dispatch(
|
|
105
|
-
loadPipesData(callableFeedUrl, {
|
|
103
|
+
ZappPipes.loadPipesData(callableFeedUrl, {
|
|
106
104
|
...pipesOptions,
|
|
107
105
|
clearCache: true,
|
|
108
106
|
riverId,
|
|
109
|
-
resolvers,
|
|
110
107
|
})
|
|
111
108
|
);
|
|
112
109
|
} else if (!callableFeedUrl) {
|
|
@@ -131,16 +128,16 @@ export const useFeedLoader = ({
|
|
|
131
128
|
jsOnly: true,
|
|
132
129
|
});
|
|
133
130
|
}
|
|
134
|
-
}, [
|
|
131
|
+
}, []);
|
|
135
132
|
|
|
136
133
|
// Reload feed when feedUrl changes, unless skipLoading is true
|
|
137
134
|
useEffect(() => {
|
|
138
135
|
if (!isInitialRender && callableFeedUrl && !pipesOptions.skipLoading) {
|
|
139
136
|
dispatch(
|
|
140
|
-
loadPipesData(callableFeedUrl, { ...pipesOptions, riverId
|
|
137
|
+
ZappPipes.loadPipesData(callableFeedUrl, { ...pipesOptions, riverId })
|
|
141
138
|
);
|
|
142
139
|
}
|
|
143
|
-
}, [callableFeedUrl
|
|
140
|
+
}, [callableFeedUrl]);
|
|
144
141
|
|
|
145
142
|
return React.useMemo(() => {
|
|
146
143
|
if (!callableFeedUrl || !feedUrl) {
|