@applicaster/zapp-react-native-utils 14.0.0-alpha.7140739134 → 14.0.0-alpha.7900711229
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 +60 -83
- package/actionsExecutor/ScreenActions.ts +163 -0
- package/actionsExecutor/StorageActions.ts +110 -0
- package/actionsExecutor/feedDecorator.ts +171 -0
- package/actionsExecutor/screenResolver.ts +11 -0
- package/appUtils/contextKeysManager/contextResolver.ts +14 -1
- package/audioPlayerUtils/index.ts +104 -0
- package/manifestUtils/_internals/getDefaultConfiguration.js +28 -0
- package/manifestUtils/{_internals.js → _internals/index.js} +2 -25
- package/manifestUtils/createConfig.js +4 -1
- package/manifestUtils/defaultManifestConfigurations/player.js +1231 -200
- package/manifestUtils/progressBar/__tests__/mobileProgressBar.test.js +0 -30
- package/package.json +2 -2
- package/playerUtils/__tests__/configurationUtils.test.ts +1 -65
- package/playerUtils/_internals/__tests__/utils.test.ts +71 -0
- package/playerUtils/_internals/index.ts +1 -0
- package/playerUtils/_internals/utils.ts +31 -0
- package/playerUtils/configurationUtils.ts +0 -44
- package/playerUtils/useValidatePlayerConfig.tsx +22 -19
- package/reactHooks/cell-click/index.ts +8 -1
- package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +20 -0
- package/reactHooks/feed/useFeedLoader.tsx +12 -5
- package/reactHooks/navigation/useRoute.ts +7 -2
- package/reactHooks/navigation/useScreenStateStore.ts +11 -0
- package/storage/ScreenSingleValueProvider.ts +197 -0
- package/storage/ScreenStateMultiSelectProvider.ts +282 -0
- package/storage/StorageMultiSelectProvider.ts +192 -0
- package/storage/StorageSingleSelectProvider.ts +108 -0
- package/utils/index.ts +3 -0
- package/playerUtils/configurationGenerator.ts +0 -2572
|
@@ -18,36 +18,6 @@ describe("mobileProgressBar", () => {
|
|
|
18
18
|
]),
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
// const timeRemainingLabelConditions = (condition) => ({
|
|
22
|
-
// rules: "all_conditions",
|
|
23
|
-
// conditional_fields: compact([
|
|
24
|
-
// {
|
|
25
|
-
// key: "assets/progress_bar_switch",
|
|
26
|
-
// condition_value: true,
|
|
27
|
-
// },
|
|
28
|
-
// {
|
|
29
|
-
// key: "assets/progress_bar_time_remaining_label_enable",
|
|
30
|
-
// condition_value: true,
|
|
31
|
-
// },
|
|
32
|
-
// condition,
|
|
33
|
-
// ]),
|
|
34
|
-
// });
|
|
35
|
-
|
|
36
|
-
// const watchedLabelConditions = (condition) => ({
|
|
37
|
-
// rules: "all_conditions",
|
|
38
|
-
// conditional_fields: compact([
|
|
39
|
-
// {
|
|
40
|
-
// key: "assets/progress_bar_switch",
|
|
41
|
-
// condition_value: true,
|
|
42
|
-
// },
|
|
43
|
-
// {
|
|
44
|
-
// key: "assets/progress_bar_watched_label_enable",
|
|
45
|
-
// condition_value: true,
|
|
46
|
-
// },
|
|
47
|
-
// condition,
|
|
48
|
-
// ]),
|
|
49
|
-
// });
|
|
50
|
-
|
|
51
21
|
it("generate progress-bar configuration - enabled and with bottom_of_cell", () => {
|
|
52
22
|
const enable = true;
|
|
53
23
|
const hideUnwatched = true;
|
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.7900711229",
|
|
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.7900711229",
|
|
31
31
|
"buffer": "^5.2.1",
|
|
32
32
|
"camelize": "^1.0.0",
|
|
33
33
|
"dayjs": "^1.11.10",
|
|
@@ -1,72 +1,8 @@
|
|
|
1
1
|
import * as utils from "../configurationUtils";
|
|
2
2
|
|
|
3
|
-
const {
|
|
4
|
-
|
|
5
|
-
const configuration = {
|
|
6
|
-
general: { fields: [{ key: "general_1", initial_value: true }] },
|
|
7
|
-
styles: { fields: [{ key: "styles_1", initial_value: true }] },
|
|
8
|
-
localizations: {
|
|
9
|
-
fields: [{ key: "localizations_1", initial_value: true, label: "label" }],
|
|
10
|
-
},
|
|
11
|
-
custom_configuration_fields: [
|
|
12
|
-
{ key: "custom_configuration_fields_1", initial_value: true },
|
|
13
|
-
{ key: "custom_configuration_fields_2", initial_value: "black" },
|
|
14
|
-
{
|
|
15
|
-
group: true,
|
|
16
|
-
fields: [{ key: "custom_configuration_fields_3", initial_value: "red" }],
|
|
17
|
-
},
|
|
18
|
-
],
|
|
19
|
-
};
|
|
3
|
+
const { parseLanguageTracks } = utils;
|
|
20
4
|
|
|
21
5
|
describe("utilities", () => {
|
|
22
|
-
describe("modifyDefaultConfigValues", () => {
|
|
23
|
-
it("should not modify the configuration if a map key doesn't exist in configuration ", function () {
|
|
24
|
-
const res = modifyDefaultConfigValues(configuration, {
|
|
25
|
-
custom_configuration_fields: {
|
|
26
|
-
non_existing_key: { initial_value: "true" },
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
expect(res).toEqual(configuration);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("should modify the key from mapping", function () {
|
|
34
|
-
const currentResult = modifyDefaultConfigValues(configuration, {
|
|
35
|
-
styles: { styles_1: { initial_value: false } },
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
expect(currentResult.styles.fields[0].initial_value).toBe(false);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it("should add extra keys the key from mapping", function () {
|
|
42
|
-
const currentResult = modifyDefaultConfigValues(configuration, {
|
|
43
|
-
styles: { styles_1: { extra_key: false } },
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
expect(currentResult.styles.fields[0].extra_key).toBeDefined();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it("should not remove existing keys that aren't being overwritten", function () {
|
|
50
|
-
const currentResult = modifyDefaultConfigValues(configuration, {
|
|
51
|
-
localizations: { localizations_1: { initial_value: false } },
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
expect(currentResult.localizations.fields[0].label).toBeDefined();
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("should modify values in groups as well", function () {
|
|
58
|
-
const currentResult = modifyDefaultConfigValues(configuration, {
|
|
59
|
-
custom_configuration_fields: {
|
|
60
|
-
custom_configuration_fields_3: { initial_value: "blue" },
|
|
61
|
-
},
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
expect(
|
|
65
|
-
currentResult.custom_configuration_fields[2].fields[0].initial_value
|
|
66
|
-
).toBe("blue");
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
|
|
70
6
|
describe("parseLanguageTracks", () => {
|
|
71
7
|
const textTrack = { index: 0, id: "text-0" };
|
|
72
8
|
const audioTrack = { index: 0, id: "audio-0" };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { getAllFields, getConfigurationDiff } from "../utils";
|
|
2
|
+
|
|
3
|
+
describe("getAllFields", () => {
|
|
4
|
+
it("should return all field keys from flat configs", () => {
|
|
5
|
+
const config1 = {
|
|
6
|
+
fields: [{ key: "foo" }, { key: "bar" }],
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const config2 = {
|
|
10
|
+
fields: [{ key: "baz" }],
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
expect(getAllFields(config1, config2)).toEqual(["foo", "bar", "baz"]);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("should handle grouped fields", () => {
|
|
17
|
+
const config = {
|
|
18
|
+
fields: [
|
|
19
|
+
{
|
|
20
|
+
group: true,
|
|
21
|
+
fields: [{ key: "grouped1" }, { key: "grouped2" }],
|
|
22
|
+
},
|
|
23
|
+
{ key: "single" },
|
|
24
|
+
],
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
expect(getAllFields(config)).toEqual(["grouped1", "grouped2", "single"]);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("should filter out fields without a key", () => {
|
|
31
|
+
const config = {
|
|
32
|
+
fields: [{ key: "foo" }, { notAKey: "bar" }],
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
expect(getAllFields(config)).toEqual(["foo"]);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("should return an empty array if no fields are present", () => {
|
|
39
|
+
expect(getAllFields({})).toEqual([]);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe("getConfigurationDiff", () => {
|
|
44
|
+
it("should return keys in defaultConfig not present in config", () => {
|
|
45
|
+
const defaultConfig = ["foo", "bar", "baz"];
|
|
46
|
+
const config = { foo: 1, baz: 2 };
|
|
47
|
+
|
|
48
|
+
expect(getConfigurationDiff(defaultConfig, config)).toEqual(["bar"]);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("should return all keys if config is empty", () => {
|
|
52
|
+
const defaultConfig = ["foo", "bar"];
|
|
53
|
+
const config = {};
|
|
54
|
+
|
|
55
|
+
expect(getConfigurationDiff(defaultConfig, config)).toEqual(["foo", "bar"]);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("should return an empty array if all keys are present", () => {
|
|
59
|
+
const defaultConfig = ["foo"];
|
|
60
|
+
const config = { foo: 1 };
|
|
61
|
+
|
|
62
|
+
expect(getConfigurationDiff(defaultConfig, config)).toEqual([]);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("should return defaultConfig if config has no matching keys", () => {
|
|
66
|
+
const defaultConfig = ["foo", "bar"];
|
|
67
|
+
const config = { baz: 1 };
|
|
68
|
+
|
|
69
|
+
expect(getConfigurationDiff(defaultConfig, config)).toEqual(["foo", "bar"]);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./utils";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
flatMap,
|
|
3
|
+
get,
|
|
4
|
+
flatten,
|
|
5
|
+
difference,
|
|
6
|
+
} from "@applicaster/zapp-react-native-utils/utils";
|
|
7
|
+
|
|
8
|
+
const extractFields = (field: any) => {
|
|
9
|
+
if (field.group === true) {
|
|
10
|
+
return field.fields;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return field;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const getAllFields = (...configs: any[]) => {
|
|
17
|
+
const allFields = flatMap(configs, (config) => get(config, "fields", []));
|
|
18
|
+
|
|
19
|
+
const processedFields = flatten(allFields.map(extractFields))
|
|
20
|
+
.map((field) => get(field, "key"))
|
|
21
|
+
.filter(Boolean);
|
|
22
|
+
|
|
23
|
+
return processedFields;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const getConfigurationDiff = (
|
|
27
|
+
defaultConfig,
|
|
28
|
+
config: Record<string, any>
|
|
29
|
+
) => {
|
|
30
|
+
return difference(defaultConfig, Object.keys(config));
|
|
31
|
+
};
|
|
@@ -1,50 +1,6 @@
|
|
|
1
1
|
import { parseJsonIfNeeded } from "../functionUtils";
|
|
2
2
|
import * as R from "ramda";
|
|
3
3
|
|
|
4
|
-
import { getNativeName as nativeNameUtil } from "../localizationUtils/localeLanguage";
|
|
5
|
-
|
|
6
|
-
export const modifyDefaultConfigValues = (
|
|
7
|
-
configuration: ConfigurationKeys,
|
|
8
|
-
mapping: ConfigValuesMapping
|
|
9
|
-
): DefaultConfiguration => {
|
|
10
|
-
return R.mapObjIndexed((value, key) => {
|
|
11
|
-
const isFieldlessKey = key === "custom_configuration_fields";
|
|
12
|
-
const keyMapping = mapping[key];
|
|
13
|
-
const fields = value?.fields || value;
|
|
14
|
-
|
|
15
|
-
if (!keyMapping) {
|
|
16
|
-
return value;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const mapper = (obj) => {
|
|
20
|
-
if (obj.fields) {
|
|
21
|
-
return R.mergeLeft({ fields: R.map(mapper)(obj.fields) })(obj);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return R.mergeLeft(keyMapping?.[obj.key])(obj);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const mappedFields = R.map(mapper)(fields);
|
|
28
|
-
|
|
29
|
-
return R.unless(() => isFieldlessKey, R.objOf("fields"))(mappedFields);
|
|
30
|
-
})(configuration);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export function nativeName(localeCode) {
|
|
34
|
-
try {
|
|
35
|
-
const {
|
|
36
|
-
getNativeName,
|
|
37
|
-
} = require("@applicaster/zapp-react-native-utils/localizationUtils/localeLanguage");
|
|
38
|
-
|
|
39
|
-
return getNativeName(localeCode);
|
|
40
|
-
} catch (error) {
|
|
41
|
-
// eslint-disable-next-line no-console
|
|
42
|
-
console.warn("Could not load localeLanguage utils from QB", error);
|
|
43
|
-
|
|
44
|
-
return nativeNameUtil(localeCode);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
4
|
const setTrackType = R.curry(
|
|
49
5
|
(
|
|
50
6
|
type: QuickBrickPlayer.TrackType,
|
|
@@ -1,34 +1,37 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import * as R from "ramda";
|
|
3
|
-
import generateConfiguration from "./configurationGenerator";
|
|
4
2
|
import { createLogger } from "../logger";
|
|
3
|
+
import { createConfig } from "../manifestUtils/createConfig";
|
|
4
|
+
import { getAllFields, getConfigurationDiff } from "./_internals";
|
|
5
5
|
|
|
6
6
|
export const logger = createLogger({
|
|
7
7
|
category: "useValidatePlayerConfig",
|
|
8
8
|
subsystem: "useValidatePlayerConfig",
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/** Default Player Configuration */
|
|
12
|
+
const {
|
|
13
|
+
styles,
|
|
14
|
+
general,
|
|
15
|
+
localizations,
|
|
16
|
+
custom_configuration_fields,
|
|
17
|
+
}: DefaultConfiguration = createConfig(
|
|
18
|
+
() => {
|
|
19
|
+
return {};
|
|
20
|
+
},
|
|
21
|
+
{ extend: "player" }
|
|
22
|
+
) as any;
|
|
23
|
+
|
|
24
|
+
const QBPlayerConfigFields = getAllFields(
|
|
25
|
+
styles,
|
|
26
|
+
general,
|
|
27
|
+
localizations,
|
|
28
|
+
custom_configuration_fields
|
|
29
|
+
);
|
|
12
30
|
|
|
13
31
|
export const useValidatePlayerConfig = (config) => {
|
|
14
32
|
React.useEffect(() => {
|
|
15
33
|
try {
|
|
16
|
-
const
|
|
17
|
-
R.map(R.prop("key")),
|
|
18
|
-
R.flatten,
|
|
19
|
-
R.map(R.compose(R.when(R.propEq("group", true), R.prop("fields")))),
|
|
20
|
-
R.concat
|
|
21
|
-
)(
|
|
22
|
-
configuration.styles.fields,
|
|
23
|
-
configuration.general.fields,
|
|
24
|
-
configuration.localizations.fields,
|
|
25
|
-
configuration.custom_configuration_fields
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
const diff = R.compose(
|
|
29
|
-
R.difference(QBPlayerConfigFields),
|
|
30
|
-
R.keys
|
|
31
|
-
)(config);
|
|
34
|
+
const diff = getConfigurationDiff(QBPlayerConfigFields, config);
|
|
32
35
|
|
|
33
36
|
logger.log_info(
|
|
34
37
|
"Missing following configuration properties. Some elements of the player may not work correctly. Check QuickBrickPlayerPlugin for the configuration reference https://github.com/applicaster/QuickBrick/tree/main/plugins/zapp-react-native-default-player/manifests",
|
|
@@ -16,7 +16,8 @@ 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 } from "../screen";
|
|
19
|
+
import { useCurrentScreenData, useScreenContext } from "../screen";
|
|
20
|
+
import { useScreenStateStore } from "../navigation/useScreenStateStore";
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* If onCellTap is defined execute the function and
|
|
@@ -42,10 +43,12 @@ export const useCellClick = ({
|
|
|
42
43
|
}: Props): onPressReturnFn => {
|
|
43
44
|
const { push, currentRoute } = useNavigation();
|
|
44
45
|
const { pathname } = useRoute();
|
|
46
|
+
const screenStateStore = useScreenStateStore();
|
|
45
47
|
|
|
46
48
|
const onCellTap: Option<Function> = React.useContext(CellTapContext);
|
|
47
49
|
const actionExecutor = React.useContext(ActionExecutorContext);
|
|
48
50
|
const screenData = useCurrentScreenData();
|
|
51
|
+
const screenState = useScreenContext()?.options;
|
|
49
52
|
|
|
50
53
|
const cellSelectable = toBooleanWithDefaultTrue(
|
|
51
54
|
component?.rules?.component_cells_selectable
|
|
@@ -83,6 +86,9 @@ export const useCellClick = ({
|
|
|
83
86
|
await actionExecutor?.handleEntryActions(selectedItem, {
|
|
84
87
|
component,
|
|
85
88
|
screenData,
|
|
89
|
+
screenState,
|
|
90
|
+
screenRoute: pathname,
|
|
91
|
+
screenStateStore,
|
|
86
92
|
});
|
|
87
93
|
}
|
|
88
94
|
|
|
@@ -117,6 +123,7 @@ export const useCellClick = ({
|
|
|
117
123
|
push,
|
|
118
124
|
sendAnalyticsOnPress,
|
|
119
125
|
screenData,
|
|
126
|
+
screenState,
|
|
120
127
|
]
|
|
121
128
|
);
|
|
122
129
|
|
|
@@ -138,6 +138,11 @@ 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
|
+
},
|
|
141
146
|
});
|
|
142
147
|
|
|
143
148
|
const store2 = mockStore({
|
|
@@ -179,6 +184,11 @@ describe("useFeedLoader", () => {
|
|
|
179
184
|
expect(loadPipesDataSpy).toBeCalledWith(feedUrl, {
|
|
180
185
|
clearCache: true,
|
|
181
186
|
riverId: undefined,
|
|
187
|
+
resolvers: {
|
|
188
|
+
screen: {
|
|
189
|
+
screenStateStore: undefined,
|
|
190
|
+
},
|
|
191
|
+
},
|
|
182
192
|
});
|
|
183
193
|
|
|
184
194
|
const store2 = mockStore({
|
|
@@ -228,6 +238,11 @@ describe("useFeedLoader", () => {
|
|
|
228
238
|
expect(loadPipesDataSpy).toBeCalledWith(feedUrl, {
|
|
229
239
|
clearCache: true,
|
|
230
240
|
silentRefresh: true,
|
|
241
|
+
resolvers: {
|
|
242
|
+
screen: {
|
|
243
|
+
screenStateStore: undefined,
|
|
244
|
+
},
|
|
245
|
+
},
|
|
231
246
|
});
|
|
232
247
|
|
|
233
248
|
loadPipesDataSpy.mockRestore();
|
|
@@ -267,6 +282,11 @@ describe("useFeedLoader", () => {
|
|
|
267
282
|
expect(loadPipesDataSpy).toBeCalledWith(nextUrl, {
|
|
268
283
|
parentFeed: feedUrlWithNext,
|
|
269
284
|
silentRefresh: true,
|
|
285
|
+
resolvers: {
|
|
286
|
+
screen: {
|
|
287
|
+
screenStateStore: undefined,
|
|
288
|
+
},
|
|
289
|
+
},
|
|
270
290
|
});
|
|
271
291
|
|
|
272
292
|
loadPipesDataSpy.mockRestore();
|
|
@@ -8,6 +8,7 @@ import { reactHooksLogger } from "../logger";
|
|
|
8
8
|
import { shouldDispatchData, useIsInitialRender } from "../utils";
|
|
9
9
|
import { useInflatedUrl } from "./useInflatedUrl";
|
|
10
10
|
import { useRoute } from "../navigation";
|
|
11
|
+
import { useScreenResolvers } from "@applicaster/zapp-react-native-utils/actionsExecutor/screenResolver";
|
|
11
12
|
|
|
12
13
|
const logger = reactHooksLogger.addSubsystem("useFeedLoader");
|
|
13
14
|
|
|
@@ -51,6 +52,7 @@ export const useFeedLoader = ({
|
|
|
51
52
|
const isInitialRender = useIsInitialRender();
|
|
52
53
|
const dispatch = useDispatch();
|
|
53
54
|
const { screenData } = useRoute();
|
|
55
|
+
const resolvers = useScreenResolvers();
|
|
54
56
|
|
|
55
57
|
const callableFeedUrl = useInflatedUrl({ feedUrl, mapping });
|
|
56
58
|
|
|
@@ -69,11 +71,12 @@ export const useFeedLoader = ({
|
|
|
69
71
|
silentRefresh,
|
|
70
72
|
callback,
|
|
71
73
|
riverId,
|
|
74
|
+
resolvers,
|
|
72
75
|
})
|
|
73
76
|
);
|
|
74
77
|
}
|
|
75
78
|
},
|
|
76
|
-
[callableFeedUrl]
|
|
79
|
+
[callableFeedUrl, resolvers]
|
|
77
80
|
);
|
|
78
81
|
|
|
79
82
|
const loadNext: FeedLoaderResponse["loadNext"] = React.useCallback(() => {
|
|
@@ -86,11 +89,12 @@ export const useFeedLoader = ({
|
|
|
86
89
|
silentRefresh: true,
|
|
87
90
|
parentFeed: callableFeedUrl,
|
|
88
91
|
riverId,
|
|
92
|
+
resolvers,
|
|
89
93
|
})
|
|
90
94
|
);
|
|
91
95
|
}
|
|
92
96
|
}
|
|
93
|
-
}, [callableFeedUrl, currentFeed?.data?.next]);
|
|
97
|
+
}, [callableFeedUrl, currentFeed?.data?.next, resolvers]);
|
|
94
98
|
|
|
95
99
|
useEffect(() => {
|
|
96
100
|
if (
|
|
@@ -102,6 +106,7 @@ export const useFeedLoader = ({
|
|
|
102
106
|
...pipesOptions,
|
|
103
107
|
clearCache: true,
|
|
104
108
|
riverId,
|
|
109
|
+
resolvers,
|
|
105
110
|
})
|
|
106
111
|
);
|
|
107
112
|
} else if (!callableFeedUrl) {
|
|
@@ -126,14 +131,16 @@ export const useFeedLoader = ({
|
|
|
126
131
|
jsOnly: true,
|
|
127
132
|
});
|
|
128
133
|
}
|
|
129
|
-
}, []);
|
|
134
|
+
}, [resolvers]);
|
|
130
135
|
|
|
131
136
|
// Reload feed when feedUrl changes, unless skipLoading is true
|
|
132
137
|
useEffect(() => {
|
|
133
138
|
if (!isInitialRender && callableFeedUrl && !pipesOptions.skipLoading) {
|
|
134
|
-
dispatch(
|
|
139
|
+
dispatch(
|
|
140
|
+
loadPipesData(callableFeedUrl, { ...pipesOptions, riverId, resolvers })
|
|
141
|
+
);
|
|
135
142
|
}
|
|
136
|
-
}, [callableFeedUrl]);
|
|
143
|
+
}, [callableFeedUrl, resolvers]);
|
|
137
144
|
|
|
138
145
|
return React.useMemo(() => {
|
|
139
146
|
if (!callableFeedUrl || !feedUrl) {
|
|
@@ -28,14 +28,19 @@ const isHookPathname = (pathname: string) => /^\/hooks\//.test(pathname);
|
|
|
28
28
|
|
|
29
29
|
type VariousScreenData = LegacyNavigationScreenData | ZappRiver | ZappEntry;
|
|
30
30
|
|
|
31
|
-
export const useRoute = (
|
|
31
|
+
export const useRoute = (
|
|
32
|
+
useLegacy = true
|
|
33
|
+
): {
|
|
32
34
|
screenData: VariousScreenData;
|
|
33
35
|
pathname: string;
|
|
34
36
|
} => {
|
|
35
37
|
const pathname = usePathname() || "";
|
|
36
38
|
const navigator = useNavigation();
|
|
39
|
+
const screenContext = useContext(ScreenDataContext);
|
|
37
40
|
|
|
38
|
-
const screenDataContext =
|
|
41
|
+
const screenDataContext = useLegacy
|
|
42
|
+
? legacyScreenData(screenContext)
|
|
43
|
+
: screenContext;
|
|
39
44
|
|
|
40
45
|
const { plugins, contentTypes, rivers } = usePickFromState([
|
|
41
46
|
"plugins",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useRoute } from "./useRoute";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
|
|
4
|
+
export const useScreenStateStore = () => {
|
|
5
|
+
const route = useRoute(false);
|
|
6
|
+
|
|
7
|
+
return useMemo(
|
|
8
|
+
() => route.screenData["screenStateStore"],
|
|
9
|
+
[route.screenData["screenStateStore"]]
|
|
10
|
+
);
|
|
11
|
+
};
|