@applicaster/quick-brick-core 15.0.0-alpha.8680244503 → 15.0.0-alpha.9102777840
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/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/useUrlSchemeHandler.test.tsx +1 -1
- package/App/ErrorBoundary/__tests__/store.test.js +1 -1
- package/App/NavigationProvider/NavigationProvider.tsx +8 -5
- package/App/NavigationProvider/__tests__/navigationProvider.test.tsx +52 -0
- package/App/NavigationProvider/navigator/selectors.ts +1 -1
- package/App/NetworkStatusProvider/__tests__/NetworkStatusProvider.test.tsx +4 -4
- package/App/ThemeManager/index.tsx +9 -0
- package/App/ThemeManager/utils.ts +54 -0
- package/App/__tests__/createQuickBrickApp.test.js +1 -1
- package/App/appRemoteDataLoader/index.tsx +2 -2
- package/package.json +8 -8
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
getTargetRoute,
|
|
8
8
|
usesVideoModal,
|
|
9
9
|
} from "@applicaster/zapp-react-native-utils/navigationUtils";
|
|
10
|
-
import { last } from "@applicaster/zapp-react-native-utils/utils";
|
|
10
|
+
import { clone, last } from "@applicaster/zapp-react-native-utils/utils";
|
|
11
11
|
import {
|
|
12
12
|
allowedOrientationsForScreen,
|
|
13
13
|
useGetScreenOrientation,
|
|
@@ -223,6 +223,7 @@ export function NavigationProvider({ children }: Props) {
|
|
|
223
223
|
};
|
|
224
224
|
|
|
225
225
|
const isVideoModalDocked = () =>
|
|
226
|
+
state?.options.videoModal.visible &&
|
|
226
227
|
state?.options.videoModal.mode === "MINIMIZED";
|
|
227
228
|
|
|
228
229
|
// TODO: Remove as it's using a concept of "current" route.
|
|
@@ -245,22 +246,24 @@ export function NavigationProvider({ children }: Props) {
|
|
|
245
246
|
const screen = rivers[screenId];
|
|
246
247
|
const parent = findParent(context, navigator.currentRoute);
|
|
247
248
|
|
|
249
|
+
const entryClone = clone(entry);
|
|
250
|
+
|
|
248
251
|
if (!screen) {
|
|
249
252
|
logger.warn({
|
|
250
253
|
message: `Cannot resolve type mapping for ${screenId} id`,
|
|
251
|
-
data: { entry, screenId },
|
|
254
|
+
data: { entry: entryClone, screenId },
|
|
252
255
|
});
|
|
253
256
|
|
|
254
257
|
return;
|
|
255
258
|
}
|
|
256
259
|
|
|
257
260
|
if (parent) {
|
|
258
|
-
|
|
261
|
+
entryClone.parent = parent?.data;
|
|
259
262
|
|
|
260
|
-
|
|
263
|
+
entryClone.parentId = parent?.id;
|
|
261
264
|
}
|
|
262
265
|
|
|
263
|
-
dispatch(setNestedContent(pathname,
|
|
266
|
+
dispatch(setNestedContent(pathname, entryClone, screen));
|
|
264
267
|
};
|
|
265
268
|
|
|
266
269
|
const pushItem = (item, options = {}) => {
|
|
@@ -450,4 +450,56 @@ describe("<NavigationProvider />", () => {
|
|
|
450
450
|
});
|
|
451
451
|
});
|
|
452
452
|
});
|
|
453
|
+
|
|
454
|
+
describe("setNestedScreenContent", () => {
|
|
455
|
+
it("should clone the entry object before modifying it", () => {
|
|
456
|
+
const originalEntry = {
|
|
457
|
+
id: "test-entry",
|
|
458
|
+
type: {
|
|
459
|
+
value: "feed",
|
|
460
|
+
},
|
|
461
|
+
title: "Test Entry",
|
|
462
|
+
};
|
|
463
|
+
|
|
464
|
+
const entryBeforeCall = structuredClone(originalEntry);
|
|
465
|
+
|
|
466
|
+
act(() => {
|
|
467
|
+
const view = getByTestId(wrapper, "WrapperView");
|
|
468
|
+
view.props.navigator.setNestedScreenContent(originalEntry, "A1234");
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
// Verify that the original entry object has not been modified
|
|
472
|
+
expect(originalEntry).toEqual(entryBeforeCall);
|
|
473
|
+
expect(originalEntry.parent).toBeUndefined();
|
|
474
|
+
expect(originalEntry.parentId).toBeUndefined();
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
it("should not mutate the original entry when parent exists", () => {
|
|
478
|
+
// First push a route to create a parent context
|
|
479
|
+
act(() => {
|
|
480
|
+
const view = getByTestId(wrapper, "WrapperView");
|
|
481
|
+
view.props.navigator.push(rivers.A1234);
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
const originalEntry = {
|
|
485
|
+
id: "test-entry",
|
|
486
|
+
type: {
|
|
487
|
+
value: "feed",
|
|
488
|
+
},
|
|
489
|
+
title: "Test Entry",
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
const entryBeforeCall = structuredClone(originalEntry);
|
|
493
|
+
|
|
494
|
+
act(() => {
|
|
495
|
+
const view = getByTestId(wrapper, "WrapperView");
|
|
496
|
+
view.props.navigator.setNestedScreenContent(originalEntry, "B4567");
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
// Verify that the original entry object has not been modified
|
|
500
|
+
expect(originalEntry).toEqual(entryBeforeCall);
|
|
501
|
+
expect(originalEntry.parent).toBeUndefined();
|
|
502
|
+
expect(originalEntry.parentId).toBeUndefined();
|
|
503
|
+
});
|
|
504
|
+
});
|
|
453
505
|
});
|
|
@@ -60,7 +60,7 @@ export const previousStackEntriesSelector = createSelector(
|
|
|
60
60
|
export const lastEntrySelector = createSelector(
|
|
61
61
|
navigationStackSelector,
|
|
62
62
|
R.compose(R.last, R.when(R.has("mainStack"), R.prop("mainStack")))
|
|
63
|
-
) as (state: any) =>
|
|
63
|
+
) as (state: any) => NavigationScreenState | undefined;
|
|
64
64
|
|
|
65
65
|
// Selector extracting identifiers of plugins requiring startup execution
|
|
66
66
|
export const startUpHookPluginIdentifiersSelector = createSelector(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import * as R from "ramda";
|
|
3
|
-
import { renderHook, act } from "@testing-library/react-
|
|
3
|
+
import { renderHook, act } from "@testing-library/react-native";
|
|
4
4
|
import { NetworkStatusContext } from "@applicaster/zapp-react-native-ui-components/Contexts/NetworkStatusContext";
|
|
5
5
|
import { NetworkStatusProvider } from "../NetworkStatusProvider";
|
|
6
6
|
import { WrappedWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
|
|
@@ -52,7 +52,7 @@ describe("NetworkStatusProvider", function () {
|
|
|
52
52
|
expect(result.current).toStrictEqual(NetInfoMock);
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
-
it("should call onConnectionLost callback when connection type changes to none", function () {
|
|
55
|
+
it("should call onConnectionLost callback when connection type changes to none", async function () {
|
|
56
56
|
const onConnectionLost = jest.fn();
|
|
57
57
|
|
|
58
58
|
const store = {
|
|
@@ -79,7 +79,7 @@ describe("NetworkStatusProvider", function () {
|
|
|
79
79
|
expect(onConnectionLost).toBeCalledTimes(1);
|
|
80
80
|
});
|
|
81
81
|
|
|
82
|
-
it("should call onConnectionRestored callback when connection type switches from none", function () {
|
|
82
|
+
it("should call onConnectionRestored callback when connection type switches from none", async function () {
|
|
83
83
|
const onConnectionRestored = jest.fn();
|
|
84
84
|
|
|
85
85
|
const store = {
|
|
@@ -116,7 +116,7 @@ describe("NetworkStatusProvider", function () {
|
|
|
116
116
|
expect(onConnectionRestored).toBeCalledTimes(1);
|
|
117
117
|
});
|
|
118
118
|
|
|
119
|
-
it("should call onConnectionTypeChanged callback when connection type changes", function () {
|
|
119
|
+
it("should call onConnectionTypeChanged callback when connection type changes", async function () {
|
|
120
120
|
const onConnectionTypeChanged = jest.fn();
|
|
121
121
|
|
|
122
122
|
const store = {
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
partitionByKeys,
|
|
10
10
|
} from "@applicaster/zapp-react-native-utils/objectUtils";
|
|
11
11
|
import { getLocalizations } from "@applicaster/zapp-react-native-utils/appUtils/localizationsHelper";
|
|
12
|
+
import { saveNetworkStatusLocalizations } from "./utils";
|
|
12
13
|
|
|
13
14
|
type Props = {
|
|
14
15
|
children: React.ReactNode;
|
|
@@ -104,6 +105,14 @@ function ThemeManagerComponent({ children, plugins }: Props) {
|
|
|
104
105
|
const [selectedThemeId, setSelectedThemeId] =
|
|
105
106
|
React.useState(DEFAULT_THEME_ID);
|
|
106
107
|
|
|
108
|
+
React.useEffect(() => {
|
|
109
|
+
const selectedTheme = themes[selectedThemeId];
|
|
110
|
+
|
|
111
|
+
if (selectedTheme) {
|
|
112
|
+
saveNetworkStatusLocalizations(selectedTheme);
|
|
113
|
+
}
|
|
114
|
+
}, [themes, selectedThemeId]);
|
|
115
|
+
|
|
107
116
|
return (
|
|
108
117
|
<MemoizedThemeContextProvider
|
|
109
118
|
themes={themes}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage";
|
|
2
|
+
|
|
3
|
+
const NETWORK_STATUS_LOCALIZATIONS_KEY = "network_status_localizations";
|
|
4
|
+
const THEME_STORAGE_NAMESPACE = "quick-brick-theme";
|
|
5
|
+
|
|
6
|
+
const DEFAULT_NETWORK_STATUS_LOCALIZATIONS: Record<string, string> = {
|
|
7
|
+
offline_notification_title: "No internet connection",
|
|
8
|
+
offline_notification_subtitle: "Please check your connection",
|
|
9
|
+
online_notification_title: "You are back online",
|
|
10
|
+
online_notification_subtitle: "Feel free to continue where you left off",
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const NETWORK_STATUS_KEYS = Object.keys(
|
|
14
|
+
DEFAULT_NETWORK_STATUS_LOCALIZATIONS
|
|
15
|
+
) as (keyof typeof DEFAULT_NETWORK_STATUS_LOCALIZATIONS)[];
|
|
16
|
+
|
|
17
|
+
export async function saveNetworkStatusLocalizations(
|
|
18
|
+
themeOrLocalizations: Record<string, unknown>
|
|
19
|
+
) {
|
|
20
|
+
try {
|
|
21
|
+
const storedLocalizations = await sessionStorage.getItem(
|
|
22
|
+
NETWORK_STATUS_LOCALIZATIONS_KEY,
|
|
23
|
+
THEME_STORAGE_NAMESPACE
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
if (storedLocalizations) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const networkStatusLocalizations = NETWORK_STATUS_KEYS.reduce(
|
|
31
|
+
(acc, key) => {
|
|
32
|
+
const value = themeOrLocalizations[key];
|
|
33
|
+
|
|
34
|
+
acc[key] =
|
|
35
|
+
typeof value === "string"
|
|
36
|
+
? value
|
|
37
|
+
: DEFAULT_NETWORK_STATUS_LOCALIZATIONS[key];
|
|
38
|
+
|
|
39
|
+
return acc;
|
|
40
|
+
},
|
|
41
|
+
{} as Record<string, string>
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
if (Object.keys(networkStatusLocalizations).length > 0) {
|
|
45
|
+
await sessionStorage.setItem(
|
|
46
|
+
NETWORK_STATUS_LOCALIZATIONS_KEY,
|
|
47
|
+
JSON.stringify(networkStatusLocalizations),
|
|
48
|
+
THEME_STORAGE_NAMESPACE
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error("Error saving network status localizations", error);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { render } from "@testing-library/react-native";
|
|
4
4
|
import { Provider } from "react-redux";
|
|
5
|
-
import thunk from "redux-thunk";
|
|
5
|
+
import { thunk } from "redux-thunk";
|
|
6
6
|
import configureStore from "redux-mock-store";
|
|
7
7
|
|
|
8
8
|
jest.mock(
|
|
@@ -3,7 +3,7 @@ import * as React from "react";
|
|
|
3
3
|
import { getRemoteContextData } from "../remoteContextReloader/getRemoteContextData";
|
|
4
4
|
|
|
5
5
|
import { coreAppLogger } from "../logger";
|
|
6
|
-
import {
|
|
6
|
+
import { UnknownAction, Dispatch } from "@reduxjs/toolkit";
|
|
7
7
|
import { isAndroidPlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
8
8
|
|
|
9
9
|
const logger = coreAppLogger.addSubsystem("AppRemoteDataLoader");
|
|
@@ -27,7 +27,7 @@ export function appRemoteDataLoader(Component: ReactComponent<any>) {
|
|
|
27
27
|
const [isDataLoaded, setIsDataLoaded] = React.useState(false);
|
|
28
28
|
|
|
29
29
|
const loadRemoteConfigurationJSONs = async (
|
|
30
|
-
dispatch: Dispatch<
|
|
30
|
+
dispatch: Dispatch<UnknownAction>,
|
|
31
31
|
state
|
|
32
32
|
) => {
|
|
33
33
|
if (!__DEV__ || process.env.ENABLE_REMOTE_DATA_IN_DEV === "true") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/quick-brick-core",
|
|
3
|
-
"version": "15.0.0-alpha.
|
|
3
|
+
"version": "15.0.0-alpha.9102777840",
|
|
4
4
|
"description": "Core package for Applicaster's Quick Brick App",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -28,13 +28,13 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@applicaster/applicaster-types": "15.0.0-alpha.
|
|
32
|
-
"@applicaster/quick-brick-core-plugins": "15.0.0-alpha.
|
|
33
|
-
"@applicaster/zapp-pipes-v2-client": "15.0.0-alpha.
|
|
34
|
-
"@applicaster/zapp-react-native-bridge": "15.0.0-alpha.
|
|
35
|
-
"@applicaster/zapp-react-native-redux": "15.0.0-alpha.
|
|
36
|
-
"@applicaster/zapp-react-native-ui-components": "15.0.0-alpha.
|
|
37
|
-
"@applicaster/zapp-react-native-utils": "15.0.0-alpha.
|
|
31
|
+
"@applicaster/applicaster-types": "15.0.0-alpha.9102777840",
|
|
32
|
+
"@applicaster/quick-brick-core-plugins": "15.0.0-alpha.9102777840",
|
|
33
|
+
"@applicaster/zapp-pipes-v2-client": "15.0.0-alpha.9102777840",
|
|
34
|
+
"@applicaster/zapp-react-native-bridge": "15.0.0-alpha.9102777840",
|
|
35
|
+
"@applicaster/zapp-react-native-redux": "15.0.0-alpha.9102777840",
|
|
36
|
+
"@applicaster/zapp-react-native-ui-components": "15.0.0-alpha.9102777840",
|
|
37
|
+
"@applicaster/zapp-react-native-utils": "15.0.0-alpha.9102777840",
|
|
38
38
|
"atob": "^2.1.2",
|
|
39
39
|
"axios": "^0.28.0",
|
|
40
40
|
"btoa": "^1.2.1",
|