@applicaster/zapp-react-native-ui-components 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/Components/AudioPlayer/mobile/Layout.tsx +1 -1
- package/Components/AudioPlayer/tv/helpers.tsx +10 -3
- package/Components/Cell/index.js +1 -1
- package/Components/ComponentResolver/index.ts +1 -1
- package/Components/FeedLoader/index.js +1 -1
- package/Components/Focusable/FocusableiOS.tsx +1 -1
- package/Components/Focusable/index.tsx +1 -1
- package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +42 -59
- package/Components/GeneralContentScreen/utils/useCurationAPI.ts +12 -8
- package/Components/Layout/TV/LayoutBackground.tsx +1 -1
- package/Components/MasterCell/DefaultComponents/Button.tsx +1 -1
- package/Components/MasterCell/DefaultComponents/Image/hoc/withDimensions.tsx +1 -1
- package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +1 -1
- package/Components/MasterCell/utils/behaviorProvider.ts +14 -82
- package/Components/MasterCell/utils/index.ts +3 -23
- package/Components/OfflineHandler/__tests__/index.test.tsx +20 -22
- package/Components/PlayerContainer/ErrorDisplay/index.ts +1 -1
- package/Components/PlayerContainer/ProgramInfo/index.tsx +1 -1
- package/Components/PlayerContainer/index.ts +1 -1
- package/Components/River/ComponentsMap/hooks/__tests__/useLoadingState.test.ts +379 -0
- package/Components/River/ComponentsMap/hooks/useLoadingState.ts +2 -2
- package/Components/River/RefreshControl.tsx +6 -4
- package/Components/River/TV/River.tsx +2 -17
- package/Components/River/TV/index.tsx +3 -1
- package/Components/River/TV/withPipesV1DataLoader.tsx +43 -0
- package/Components/River/TV/withRiverDataLoader.tsx +17 -0
- package/Components/River/index.tsx +1 -1
- package/Components/Screen/__tests__/Screen.test.tsx +23 -12
- package/Components/Transitioner/Scene.tsx +0 -1
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +24 -8
- package/Decorators/RiverFeedLoader/index.tsx +2 -8
- package/Decorators/RiverFeedLoader/utils/index.ts +2 -7
- package/Decorators/RiverResolver/__tests__/riverResolver.test.tsx +3 -6
- package/Decorators/ZappPipesDataConnector/ResolverSelector.tsx +25 -0
- package/Decorators/ZappPipesDataConnector/__tests__/NullFeedResolver.test.tsx +78 -0
- package/Decorators/ZappPipesDataConnector/__tests__/ResolverSelector.test.tsx +205 -0
- package/Decorators/ZappPipesDataConnector/__tests__/StaticFeedResolver.test.tsx +251 -0
- package/Decorators/ZappPipesDataConnector/__tests__/UrlFeedResolver.test.tsx +368 -0
- package/Decorators/ZappPipesDataConnector/__tests__/utils.test.ts +39 -0
- package/Decorators/ZappPipesDataConnector/index.tsx +27 -312
- package/Decorators/ZappPipesDataConnector/resolvers/NullFeedResolver.tsx +25 -0
- package/Decorators/ZappPipesDataConnector/resolvers/StaticFeedResolver.tsx +87 -0
- package/Decorators/ZappPipesDataConnector/resolvers/UrlFeedResolver.tsx +241 -0
- package/Decorators/ZappPipesDataConnector/types.ts +29 -0
- package/package.json +5 -6
|
@@ -27,7 +27,7 @@ export function AudioPlayerMobileLayout({
|
|
|
27
27
|
}: Props) {
|
|
28
28
|
const fadeAnimation = useRef(new Animated.Value(0)).current;
|
|
29
29
|
|
|
30
|
-
const mainContainerStyles = platformSelect({
|
|
30
|
+
const mainContainerStyles: ViewStyle = platformSelect({
|
|
31
31
|
native: {
|
|
32
32
|
backgroundColor: "transparent",
|
|
33
33
|
overflow: "hidden",
|
|
@@ -27,13 +27,20 @@ const LTR = {
|
|
|
27
27
|
justifyContent: "flex-start",
|
|
28
28
|
textAlign: "left",
|
|
29
29
|
alignItems: "flex-end",
|
|
30
|
-
};
|
|
30
|
+
} as const;
|
|
31
31
|
|
|
32
32
|
const RTL = {
|
|
33
33
|
flexDirection: "row-reverse",
|
|
34
34
|
justifyContent: "flex-end",
|
|
35
35
|
textAlign: "right",
|
|
36
36
|
alignItems: "flex-start",
|
|
37
|
-
};
|
|
37
|
+
} as const;
|
|
38
38
|
|
|
39
|
-
export const directionStyles = (
|
|
39
|
+
export const directionStyles = (
|
|
40
|
+
isRTL: boolean
|
|
41
|
+
): {
|
|
42
|
+
flexDirection: "row" | "row-reverse";
|
|
43
|
+
justifyContent: "flex-start" | "flex-end";
|
|
44
|
+
textAlign: "left" | "right";
|
|
45
|
+
alignItems: "flex-end" | "flex-start";
|
|
46
|
+
} => (isRTL ? RTL : LTR);
|
package/Components/Cell/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as R from "ramda";
|
|
2
2
|
|
|
3
|
-
import { connectToStore } from "@applicaster/zapp-react-native-redux";
|
|
3
|
+
import { connectToStore } from "@applicaster/zapp-react-native-redux/utils/connectToStore";
|
|
4
4
|
import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
5
5
|
|
|
6
6
|
import {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as R from "ramda";
|
|
2
2
|
|
|
3
|
-
import { connectToStore } from "@applicaster/zapp-react-native-redux";
|
|
3
|
+
import { connectToStore } from "@applicaster/zapp-react-native-redux/utils/connectToStore";
|
|
4
4
|
|
|
5
5
|
import { ComponentResolverComponent } from "./ComponentResolver";
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as R from "ramda";
|
|
2
2
|
|
|
3
|
-
import { connectToStore } from "@applicaster/zapp-react-native-redux";
|
|
3
|
+
import { connectToStore } from "@applicaster/zapp-react-native-redux/utils/connectToStore";
|
|
4
4
|
import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
|
|
5
5
|
|
|
6
6
|
import { FeedLoaderComponent } from "./FeedLoader";
|
|
@@ -4,7 +4,7 @@ import { FocusableiOS } from "./FocusableiOS";
|
|
|
4
4
|
|
|
5
5
|
import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
6
6
|
|
|
7
|
-
export const Focusable = platformSelect({
|
|
7
|
+
export const Focusable: React.ComponentType<any> = platformSelect({
|
|
8
8
|
tvos: FocusableTvOS,
|
|
9
9
|
ios: FocusableiOS,
|
|
10
10
|
default: FocusableDefault,
|
|
@@ -8,13 +8,10 @@ import {
|
|
|
8
8
|
useCurationAPI,
|
|
9
9
|
} from "../useCurationAPI";
|
|
10
10
|
import * as redux from "react-redux";
|
|
11
|
-
import * as layoutPresets from "@applicaster/zapp-react-native-redux/hooks/useLayoutPresets";
|
|
12
|
-
import * as pipesFeeds from "@applicaster/zapp-react-native-redux/hooks/useZappPipesFeeds";
|
|
13
11
|
import { NavigationContext } from "@applicaster/zapp-react-native-ui-components/Contexts/NavigationContext";
|
|
14
12
|
import { PathnameContext } from "@applicaster/zapp-react-native-ui-components/Contexts/PathnameContext";
|
|
15
13
|
|
|
16
|
-
import {
|
|
17
|
-
import configureStore from "redux-mock-store";
|
|
14
|
+
import { WrappedWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
|
|
18
15
|
|
|
19
16
|
jest.mock(
|
|
20
17
|
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useRoute",
|
|
@@ -42,19 +39,20 @@ const mainStackNavigator = {
|
|
|
42
39
|
},
|
|
43
40
|
};
|
|
44
41
|
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
<
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
{
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
42
|
+
const getWrapper =
|
|
43
|
+
(store) =>
|
|
44
|
+
// eslint-disable-next-line react/display-name, react/prop-types
|
|
45
|
+
({ children }) => (
|
|
46
|
+
<WrappedWithProviders store={store}>
|
|
47
|
+
<NavigationContext.Provider
|
|
48
|
+
value={{ ...mainStackNavigator, currentRoute: homeStack.route }}
|
|
49
|
+
>
|
|
50
|
+
<PathnameContext.Provider value={homeStack.route}>
|
|
51
|
+
{children}
|
|
52
|
+
</PathnameContext.Provider>
|
|
53
|
+
</NavigationContext.Provider>
|
|
54
|
+
</WrappedWithProviders>
|
|
55
|
+
);
|
|
58
56
|
|
|
59
57
|
describe("getTransformedPreset should return the passed components if smartComponents is empty", () => {
|
|
60
58
|
describe("getTransformedPreset function", () => {
|
|
@@ -312,19 +310,10 @@ describe("getTransformedPreset should return the passed components if smartCompo
|
|
|
312
310
|
{ id: "02", component_type: "not_smart_another" },
|
|
313
311
|
];
|
|
314
312
|
|
|
315
|
-
// mock the hooks
|
|
316
|
-
const mockUseZappPipesFeeds = jest.spyOn(pipesFeeds, "useZappPipesFeeds");
|
|
317
|
-
mockUseZappPipesFeeds.mockReturnValue({});
|
|
318
|
-
|
|
319
|
-
const mockUseLayoutPresets = jest.spyOn(
|
|
320
|
-
layoutPresets,
|
|
321
|
-
"useLayoutPresets"
|
|
322
|
-
);
|
|
323
|
-
|
|
324
|
-
mockUseLayoutPresets.mockReturnValue({});
|
|
325
|
-
|
|
326
313
|
const { result } = renderHook(() => useCurationAPI(mockComponents), {
|
|
327
|
-
wrapper
|
|
314
|
+
wrapper: getWrapper({
|
|
315
|
+
zappPipes: {},
|
|
316
|
+
}),
|
|
328
317
|
});
|
|
329
318
|
|
|
330
319
|
// if there are no smart components, it should return the original array
|
|
@@ -366,18 +355,15 @@ describe("getTransformedPreset should return the passed components if smartCompo
|
|
|
366
355
|
"http://curation": { loading: false, data: { entry: mockPresetEntry } },
|
|
367
356
|
};
|
|
368
357
|
|
|
369
|
-
const mockUseZappPipesFeeds = jest.spyOn(pipesFeeds, "useZappPipesFeeds");
|
|
370
|
-
mockUseZappPipesFeeds.mockReturnValue(mockFeeds);
|
|
371
|
-
|
|
372
|
-
const mockUseLayoutPresets = jest.spyOn(
|
|
373
|
-
layoutPresets,
|
|
374
|
-
"useLayoutPresets"
|
|
375
|
-
);
|
|
376
|
-
|
|
377
|
-
mockUseLayoutPresets.mockReturnValue(mockLayoutPresets);
|
|
378
|
-
|
|
379
358
|
const { result } = renderHook(() => useCurationAPI(mockComponents), {
|
|
380
|
-
wrapper
|
|
359
|
+
wrapper: getWrapper({
|
|
360
|
+
zappPipes: mockFeeds,
|
|
361
|
+
presetsMapping: {
|
|
362
|
+
presets_mappings: {
|
|
363
|
+
...mockLayoutPresets,
|
|
364
|
+
},
|
|
365
|
+
},
|
|
366
|
+
}),
|
|
381
367
|
});
|
|
382
368
|
|
|
383
369
|
expect(result.current).toEqual(mockTransformedComponents);
|
|
@@ -437,19 +423,15 @@ describe("getTransformedPreset should return the passed components if smartCompo
|
|
|
437
423
|
},
|
|
438
424
|
};
|
|
439
425
|
|
|
440
|
-
// mock the hooks
|
|
441
|
-
const mockUseZappPipesFeeds = jest.spyOn(pipesFeeds, "useZappPipesFeeds");
|
|
442
|
-
mockUseZappPipesFeeds.mockReturnValue(mockFeeds);
|
|
443
|
-
|
|
444
|
-
const mockUseLayoutPresets = jest.spyOn(
|
|
445
|
-
layoutPresets,
|
|
446
|
-
"useLayoutPresets"
|
|
447
|
-
);
|
|
448
|
-
|
|
449
|
-
mockUseLayoutPresets.mockReturnValue(mockLayoutPresets);
|
|
450
|
-
|
|
451
426
|
const { result } = renderHook(() => useCurationAPI(mockComponents), {
|
|
452
|
-
wrapper
|
|
427
|
+
wrapper: getWrapper({
|
|
428
|
+
zappPipes: mockFeeds,
|
|
429
|
+
presetsMapping: {
|
|
430
|
+
presets_mappings: {
|
|
431
|
+
...mockLayoutPresets,
|
|
432
|
+
},
|
|
433
|
+
},
|
|
434
|
+
}),
|
|
453
435
|
});
|
|
454
436
|
|
|
455
437
|
expect(result.current).toEqual(mockTransformedComponents);
|
|
@@ -495,14 +477,15 @@ describe("getTransformedPreset should return the passed components if smartCompo
|
|
|
495
477
|
"http://curation": { loading: false, data: { entry: mockPresetEntry } },
|
|
496
478
|
};
|
|
497
479
|
|
|
498
|
-
// mock the hooks
|
|
499
|
-
const mockUseZappPipesFeeds = jest.spyOn(pipesFeeds, "useZappPipesFeeds");
|
|
500
|
-
mockUseZappPipesFeeds.mockReturnValue(mockFeeds);
|
|
501
|
-
const mockUseLayoutPresets = jest.spyOn(layoutPresets, "useLayoutPresets");
|
|
502
|
-
mockUseLayoutPresets.mockReturnValue(mockLayoutPresets);
|
|
503
|
-
|
|
504
480
|
const { result } = renderHook(() => useCurationAPI(mockComponents), {
|
|
505
|
-
wrapper
|
|
481
|
+
wrapper: getWrapper({
|
|
482
|
+
zappPipes: mockFeeds,
|
|
483
|
+
presetsMapping: {
|
|
484
|
+
presets_mappings: {
|
|
485
|
+
...mockLayoutPresets,
|
|
486
|
+
},
|
|
487
|
+
},
|
|
488
|
+
}),
|
|
506
489
|
});
|
|
507
490
|
|
|
508
491
|
expect(result.current).toEqual(mockTransformedComponents);
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { all, equals, path, prop, isEmpty, pluck, values } from "ramda";
|
|
2
2
|
|
|
3
3
|
import { useEffect, useMemo } from "react";
|
|
4
|
-
import { useDispatch } from "react-redux";
|
|
5
4
|
|
|
6
5
|
import {
|
|
6
|
+
ZappPipes,
|
|
7
|
+
useAppDispatch,
|
|
7
8
|
useLayoutPresets,
|
|
8
|
-
|
|
9
|
-
} from "@applicaster/zapp-react-native-redux
|
|
10
|
-
import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
|
|
9
|
+
useZappPipesFeed,
|
|
10
|
+
} from "@applicaster/zapp-react-native-redux";
|
|
11
11
|
import { isEmptyOrNil } from "@applicaster/zapp-react-native-utils/cellUtils";
|
|
12
12
|
import { Categories } from "./logger";
|
|
13
13
|
import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
|
|
14
14
|
import { useRoute } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useRoute";
|
|
15
|
+
|
|
15
16
|
import {
|
|
16
17
|
ZappPipesEntryContext,
|
|
17
18
|
ZappPipesScreenContext,
|
|
@@ -26,7 +27,10 @@ import {
|
|
|
26
27
|
import { produce } from "immer";
|
|
27
28
|
// types reference
|
|
28
29
|
|
|
29
|
-
declare
|
|
30
|
+
declare interface CurationEntry {
|
|
31
|
+
preset_name: string;
|
|
32
|
+
feed_url: string;
|
|
33
|
+
}
|
|
30
34
|
|
|
31
35
|
type Feeds = Record<string, ZappPipesData>;
|
|
32
36
|
|
|
@@ -122,7 +126,7 @@ export const getFinalComponents = (
|
|
|
122
126
|
export const useCurationAPI = (
|
|
123
127
|
components: Array<ZappUIComponent>
|
|
124
128
|
): ZappUIComponent[] => {
|
|
125
|
-
const dispatch =
|
|
129
|
+
const dispatch = useAppDispatch();
|
|
126
130
|
|
|
127
131
|
const smartComponents = useMemo(
|
|
128
132
|
() => components?.filter?.(isSmartComponent) ?? [],
|
|
@@ -162,7 +166,7 @@ export const useCurationAPI = (
|
|
|
162
166
|
useEffect(() => {
|
|
163
167
|
urls.forEach((url, index) => {
|
|
164
168
|
if (url) {
|
|
165
|
-
dispatch(loadPipesData(url, { clearCache: false }));
|
|
169
|
+
dispatch(ZappPipes.loadPipesData(url, { clearCache: false }));
|
|
166
170
|
} else {
|
|
167
171
|
logger.log_error("Curation url is empty", {
|
|
168
172
|
componentId: smartComponents?.[index]?.id,
|
|
@@ -171,7 +175,7 @@ export const useCurationAPI = (
|
|
|
171
175
|
});
|
|
172
176
|
}, [urls]);
|
|
173
177
|
|
|
174
|
-
const feeds =
|
|
178
|
+
const feeds = useZappPipesFeed(urls);
|
|
175
179
|
const layoutPresets = useLayoutPresets();
|
|
176
180
|
|
|
177
181
|
const enrichedComponents = useMemo(() => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks
|
|
2
|
+
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
3
3
|
import { getBackgroundImageUrl } from "../utils";
|
|
4
4
|
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
5
5
|
|
|
@@ -4,7 +4,7 @@ import * as R from "ramda";
|
|
|
4
4
|
import { TouchableOpacity } from "react-native";
|
|
5
5
|
// import { SvgUri } from "react-native-svg";
|
|
6
6
|
|
|
7
|
-
import { connectToStore } from "@applicaster/zapp-react-native-redux";
|
|
7
|
+
import { connectToStore } from "@applicaster/zapp-react-native-redux/utils/connectToStore";
|
|
8
8
|
import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
|
|
9
9
|
|
|
10
10
|
import Image from "./Image";
|
|
@@ -20,7 +20,7 @@ const withAppliedDimensions = (style: Style) => (source: Source) => ({
|
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
export const withDimensionsHOC = (Component) => {
|
|
23
|
-
return function WithDimensions(props:
|
|
23
|
+
return function WithDimensions(props: Record<string, unknown>) {
|
|
24
24
|
const theme = useTheme<BaseThemePropertiesMobile>();
|
|
25
25
|
|
|
26
26
|
const useDownScalingImages = toBooleanWithDefaultFalse(
|
|
@@ -13,7 +13,7 @@ export const ImageContainer = (props: Props) => {
|
|
|
13
13
|
const isActive = useIsScreenActive();
|
|
14
14
|
|
|
15
15
|
const Component =
|
|
16
|
-
isVideoPreviewEnabled(props) && isActive ? LiveImage : PureImage;
|
|
16
|
+
isVideoPreviewEnabled(props as Props) && isActive ? LiveImage : PureImage;
|
|
17
17
|
|
|
18
18
|
return <Component {...props} />;
|
|
19
19
|
};
|
|
@@ -1,58 +1,28 @@
|
|
|
1
1
|
import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils";
|
|
2
|
-
import { StorageSingleValueProvider } from "@applicaster/zapp-react-native-
|
|
2
|
+
import { StorageSingleValueProvider } from "@applicaster/zapp-react-native-bridge/ZappStorage/StorageSingleSelectProvider";
|
|
3
3
|
import { PushTopicManager } from "@applicaster/zapp-react-native-bridge/PushNotifications/PushTopicManager";
|
|
4
|
-
import { StorageMultiSelectProvider } from "@applicaster/zapp-react-native-
|
|
4
|
+
import { StorageMultiSelectProvider } from "@applicaster/zapp-react-native-bridge/ZappStorage/StorageMultiSelectProvider";
|
|
5
5
|
import React, { useEffect } from "react";
|
|
6
6
|
import { usePlayer } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/usePlayer";
|
|
7
7
|
import { BehaviorSubject } from "rxjs";
|
|
8
8
|
import { masterCellLogger } from "../logger";
|
|
9
9
|
import get from "lodash/get";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const parseContextKey = (
|
|
16
|
-
key: string,
|
|
17
|
-
context: string = "ctx"
|
|
18
|
-
): string | null => {
|
|
19
|
-
if (!key?.startsWith(`@{${context}/`)) return null;
|
|
20
|
-
|
|
21
|
-
return key.substring(`@{${context}/`.length, key.length - 1);
|
|
10
|
+
|
|
11
|
+
const parseContextKey = (key: string): string | null => {
|
|
12
|
+
if (!key?.startsWith("@{ctx/")) return null;
|
|
13
|
+
|
|
14
|
+
return key.substring("@{ctx/".length, key.length - 1);
|
|
22
15
|
};
|
|
23
16
|
|
|
24
17
|
const getDataSourceProvider = (
|
|
25
|
-
behavior: Behavior
|
|
26
|
-
screenRoute: string,
|
|
27
|
-
screenStateStore: ScreenStateStore
|
|
18
|
+
behavior: Behavior
|
|
28
19
|
): BehaviorSubject<string[] | string> | null => {
|
|
29
20
|
if (!behavior) return null;
|
|
30
21
|
|
|
31
22
|
const selection = String(behavior.current_selection);
|
|
32
|
-
const screenKey = parseContextKey(selection, "screen");
|
|
33
|
-
|
|
34
|
-
if (screenKey) {
|
|
35
|
-
if (behavior.select_mode === "multi") {
|
|
36
|
-
return ScreenMultiSelectProvider.getProvider(
|
|
37
|
-
screenKey,
|
|
38
|
-
screenRoute,
|
|
39
|
-
screenStateStore
|
|
40
|
-
).getObservable();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (behavior.select_mode === "single") {
|
|
44
|
-
return ScreenSingleValueProvider.getProvider(
|
|
45
|
-
screenKey,
|
|
46
|
-
screenRoute,
|
|
47
|
-
screenStateStore
|
|
48
|
-
).getObservable();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
23
|
const contextKey = parseContextKey(selection);
|
|
53
24
|
|
|
54
25
|
if (contextKey) {
|
|
55
|
-
// TODO: Add storage scope to behavior
|
|
56
26
|
if (behavior.select_mode === "multi") {
|
|
57
27
|
return StorageMultiSelectProvider.getProvider(contextKey).getObservable();
|
|
58
28
|
}
|
|
@@ -71,8 +41,6 @@ const getDataSourceProvider = (
|
|
|
71
41
|
|
|
72
42
|
export const useBehaviorUpdate = (behavior: Behavior) => {
|
|
73
43
|
const [lastUpdate, setLastUpdate] = React.useState<number | null>(null);
|
|
74
|
-
const screenRoute = useRoute()?.pathname || "";
|
|
75
|
-
const screenStateStore = useScreenStateStore();
|
|
76
44
|
const player = usePlayer();
|
|
77
45
|
|
|
78
46
|
const triggerUpdate = () => setLastUpdate(Date.now());
|
|
@@ -80,11 +48,7 @@ export const useBehaviorUpdate = (behavior: Behavior) => {
|
|
|
80
48
|
useEffect(() => {
|
|
81
49
|
if (!behavior) return;
|
|
82
50
|
|
|
83
|
-
const dataSource = getDataSourceProvider(
|
|
84
|
-
behavior,
|
|
85
|
-
screenRoute,
|
|
86
|
-
screenStateStore
|
|
87
|
-
);
|
|
51
|
+
const dataSource = getDataSourceProvider(behavior);
|
|
88
52
|
|
|
89
53
|
if (dataSource) {
|
|
90
54
|
const subscription = dataSource.subscribe(triggerUpdate);
|
|
@@ -108,17 +72,10 @@ export const useBehaviorUpdate = (behavior: Behavior) => {
|
|
|
108
72
|
|
|
109
73
|
// We cant use async in this function (its inside render),
|
|
110
74
|
// so we rely on useBehaviorUpdate to update current value and trigger re-render
|
|
111
|
-
export const isCellSelected = (
|
|
112
|
-
item,
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
behavior,
|
|
116
|
-
}: {
|
|
117
|
-
item: ZappEntry;
|
|
118
|
-
screenRoute: string;
|
|
119
|
-
screenStateStore: ScreenStateStore;
|
|
120
|
-
behavior?: Behavior;
|
|
121
|
-
}): boolean => {
|
|
75
|
+
export const isCellSelected = (
|
|
76
|
+
item: ZappEntry,
|
|
77
|
+
behavior?: Behavior
|
|
78
|
+
): boolean => {
|
|
122
79
|
if (!behavior) return false;
|
|
123
80
|
|
|
124
81
|
const id = behavior.selector ? get(item, behavior.selector) : item.id;
|
|
@@ -142,32 +99,7 @@ export const isCellSelected = ({
|
|
|
142
99
|
}
|
|
143
100
|
|
|
144
101
|
const selection = String(behavior.current_selection);
|
|
145
|
-
|
|
146
|
-
const screenKey = parseContextKey(selection, "screen");
|
|
147
|
-
|
|
148
|
-
if (screenKey) {
|
|
149
|
-
if (behavior.select_mode === "single") {
|
|
150
|
-
const selectedItem = ScreenSingleValueProvider.getProvider(
|
|
151
|
-
screenKey,
|
|
152
|
-
screenRoute,
|
|
153
|
-
screenStateStore
|
|
154
|
-
).getValue();
|
|
155
|
-
|
|
156
|
-
return selectedItem === String(id);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (behavior.select_mode === "multi") {
|
|
160
|
-
const selectedItems = ScreenMultiSelectProvider.getProvider(
|
|
161
|
-
screenKey,
|
|
162
|
-
screenRoute,
|
|
163
|
-
screenStateStore
|
|
164
|
-
).getSelectedItems();
|
|
165
|
-
|
|
166
|
-
return selectedItems?.includes(String(id));
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
const contextKey = parseContextKey(selection, "ctx");
|
|
102
|
+
const contextKey = parseContextKey(selection);
|
|
171
103
|
|
|
172
104
|
if (contextKey) {
|
|
173
105
|
if (behavior.select_mode === "single") {
|
|
@@ -8,8 +8,6 @@ import { masterCellLogger } from "../logger";
|
|
|
8
8
|
import { getCellState } from "../../Cell/utils";
|
|
9
9
|
import { getColorFromData } from "@applicaster/zapp-react-native-utils/cellUtils";
|
|
10
10
|
import { isCellSelected, useBehaviorUpdate } from "./behaviorProvider";
|
|
11
|
-
import { useRoute } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
12
|
-
import { useScreenStateStore } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useScreenStateStore";
|
|
13
11
|
|
|
14
12
|
const hasElementSpecificViewType = (viewType) => (element) => {
|
|
15
13
|
if (R.isNil(element)) {
|
|
@@ -192,18 +190,8 @@ export const getFocusedButtonId = (focusable) => {
|
|
|
192
190
|
});
|
|
193
191
|
};
|
|
194
192
|
|
|
195
|
-
export const isSelected = ({
|
|
196
|
-
item,
|
|
197
|
-
screenRoute,
|
|
198
|
-
screenStateStore,
|
|
199
|
-
behavior,
|
|
200
|
-
}: {
|
|
201
|
-
item: ZappEntry;
|
|
202
|
-
screenRoute: string;
|
|
203
|
-
screenStateStore: ScreenStateStore;
|
|
204
|
-
behavior?: Behavior;
|
|
205
|
-
}) => {
|
|
206
|
-
return isCellSelected({ item, screenRoute, screenStateStore, behavior });
|
|
193
|
+
export const isSelected = (item: ZappEntry, behavior?: Behavior) => {
|
|
194
|
+
return isCellSelected(item, behavior);
|
|
207
195
|
};
|
|
208
196
|
|
|
209
197
|
export const useCellState = ({
|
|
@@ -216,17 +204,9 @@ export const useCellState = ({
|
|
|
216
204
|
focused: boolean;
|
|
217
205
|
}): CellState => {
|
|
218
206
|
const lastUpdate = useBehaviorUpdate(behavior);
|
|
219
|
-
const router = useRoute();
|
|
220
|
-
const screenStateStore = useScreenStateStore();
|
|
221
207
|
|
|
222
208
|
const _isSelected = useMemo(
|
|
223
|
-
() =>
|
|
224
|
-
isSelected({
|
|
225
|
-
item,
|
|
226
|
-
screenRoute: router?.pathname,
|
|
227
|
-
screenStateStore,
|
|
228
|
-
behavior,
|
|
229
|
-
}),
|
|
209
|
+
() => isSelected(item, behavior),
|
|
230
210
|
[behavior, item, lastUpdate]
|
|
231
211
|
);
|
|
232
212
|
|
|
@@ -19,29 +19,27 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/utils", () => {
|
|
|
19
19
|
};
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
jest.mock(
|
|
23
|
-
"@applicaster/zapp-react-native-redux/hooks
|
|
24
|
-
() => ({
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}),
|
|
39
|
-
},
|
|
22
|
+
jest.mock("@applicaster/zapp-react-native-redux/hooks", () => ({
|
|
23
|
+
...jest.requireActual("@applicaster/zapp-react-native-redux/hooks"),
|
|
24
|
+
usePickFromState: () => ({
|
|
25
|
+
plugins: [
|
|
26
|
+
{
|
|
27
|
+
name: "offline experience",
|
|
28
|
+
identifier: "offline-experience",
|
|
29
|
+
type: "general",
|
|
30
|
+
module: {
|
|
31
|
+
useOfflineExperienceConfiguration: () => ({
|
|
32
|
+
configurationFields: {},
|
|
33
|
+
localizations: {
|
|
34
|
+
offline_toast_message: "No internet connection",
|
|
35
|
+
online_toast_message: "You are back online",
|
|
36
|
+
},
|
|
37
|
+
}),
|
|
40
38
|
},
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
})
|
|
44
|
-
);
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
}),
|
|
42
|
+
}));
|
|
45
43
|
|
|
46
44
|
jest.mock("react-native-safe-area-context", () => ({
|
|
47
45
|
useSafeAreaInsets: () => ({ top: 44 }),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { connectToStore } from "@applicaster/zapp-react-native-redux";
|
|
1
|
+
import { connectToStore } from "@applicaster/zapp-react-native-redux/utils/connectToStore";
|
|
2
2
|
import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
3
3
|
import { styleKeys } from "@applicaster/zapp-react-native-utils/styleKeysUtils";
|
|
4
4
|
import { transformColorCode as fixColorHexCode } from "@applicaster/zapp-react-native-utils/transform";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as R from "ramda";
|
|
2
2
|
|
|
3
|
-
import { connectToStore } from "@applicaster/zapp-react-native-redux";
|
|
3
|
+
import { connectToStore } from "@applicaster/zapp-react-native-redux/utils/connectToStore";
|
|
4
4
|
import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
|
|
5
5
|
|
|
6
6
|
import { PlayerContainer as PlayerContainerComponent } from "./PlayerContainer";
|