@applicaster/zapp-react-native-ui-components 16.0.0-alpha.1929433645 → 16.0.0-alpha.2105365027
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/FocusableList/index.tsx +7 -0
- package/Components/GeneralContentScreen/GeneralContentScreen.tsx +7 -0
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +12 -3
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/ActionButton.tsx +1 -1
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/PressableView.test.tsx +4 -2
- package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/factory.test.ts +2 -2
- package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +2 -1
- package/Components/MasterCell/__tests__/masterCell.test.js +60 -0
- package/Components/MasterCell/index.tsx +60 -11
- package/Components/MasterCell/utils/__tests__/withoutFocusedState.test.js +20 -0
- package/Components/MasterCell/utils/index.ts +18 -0
- package/Components/ModalComponent/AudioPlayer/Components/Item.tsx +22 -1
- package/Components/ModalComponent/AudioPlayer/Components/__tests__/Item.test.tsx +52 -1
- package/Components/ModalComponent/AudioPlayer/utils/__tests__/mergeStyles.test.ts +77 -0
- package/Components/ModalComponent/AudioPlayer/utils/mergeStyles.ts +58 -16
- package/Components/ModalComponent/BottomSheetModalContent.tsx +9 -74
- package/Components/ModalComponent/SortableList.tsx +2 -3
- package/Components/ModalComponent/__tests__/showTextInput.test.ts +25 -0
- package/Components/ModalComponent/showTextInput.ts +2 -0
- package/Components/OfflineHandler/__tests__/index.test.tsx +109 -0
- package/Components/OfflineHandler/index.tsx +42 -4
- package/Components/PlayerContainer/PlayerContainer.tsx +8 -1
- package/Components/River/ComponentsMap/ComponentsMap.tsx +4 -1
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +2 -0
- package/Components/Transitioner/AnimationManager.js +1 -1
- package/Components/Transitioner/Scene.tsx +4 -3
- package/Components/Transitioner/Transitioner.tsx +71 -33
- package/Components/Transitioner/__tests__/transitioner.test.js +372 -3
- package/Components/VideoModal/PlayerWrapper.tsx +4 -1
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -0
- package/Components/VideoModal/__tests__/playerWrapperStyle.test.ts +58 -0
- package/Components/VideoModal/__tests__/playerWrapperUtils.test.ts +16 -0
- package/Components/VideoModal/playerWrapperStyle.ts +21 -3
- package/Components/VideoModal/playerWrapperUtils.ts +7 -1
- package/Decorators/ZappPipesDataConnector/__tests__/screenToolbox.test.ts +347 -0
- package/Decorators/ZappPipesDataConnector/__tests__/screenToolboxUnavailable.test.ts +53 -0
- package/Decorators/ZappPipesDataConnector/index.tsx +19 -4
- package/Decorators/ZappPipesDataConnector/screenToolbox.ts +384 -0
- package/package.json +5 -5
|
@@ -82,7 +82,7 @@ function mergeItemLabel(
|
|
|
82
82
|
...(override.lineHeight !== undefined
|
|
83
83
|
? { lineHeight: override.lineHeight }
|
|
84
84
|
: {}),
|
|
85
|
-
...(override.fontFamily
|
|
85
|
+
...(typeof override.fontFamily === "string" && override.fontFamily
|
|
86
86
|
? {
|
|
87
87
|
iosFontFamily: override.fontFamily,
|
|
88
88
|
androidFontFamily: override.fontFamily,
|
|
@@ -147,6 +147,8 @@ function mergeItemActionButtonAssets(
|
|
|
147
147
|
...base,
|
|
148
148
|
...(override.removeAsset ? { removeAsset: override.removeAsset } : {}),
|
|
149
149
|
...(override.dragAsset ? { dragAsset: override.dragAsset } : {}),
|
|
150
|
+
...(override.playAsset ? { playAsset: override.playAsset } : {}),
|
|
151
|
+
...(override.pauseAsset ? { pauseAsset: override.pauseAsset } : {}),
|
|
150
152
|
};
|
|
151
153
|
}
|
|
152
154
|
|
|
@@ -379,6 +381,22 @@ export function mergeHeaderConfiguration(
|
|
|
379
381
|
// Button Merging Helpers
|
|
380
382
|
// ---------------------------------------------------------------------------
|
|
381
383
|
|
|
384
|
+
function fontFamilyName(value: unknown): string | undefined {
|
|
385
|
+
if (typeof value === "string" && value.trim()) {
|
|
386
|
+
return value;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
if (value && typeof value === "object") {
|
|
390
|
+
const family = (value as { fontFamily?: unknown }).fontFamily;
|
|
391
|
+
|
|
392
|
+
if (typeof family === "string" && family.trim()) {
|
|
393
|
+
return family;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
return undefined;
|
|
398
|
+
}
|
|
399
|
+
|
|
382
400
|
function mergeButtonBackground(
|
|
383
401
|
base: ButtonBackgroundConfiguration,
|
|
384
402
|
defaultOverride?: Record<string, any>,
|
|
@@ -397,6 +415,9 @@ function mergeButtonBackground(
|
|
|
397
415
|
...(defaultOverride?.backgroundColor
|
|
398
416
|
? { defaultColor: defaultOverride.backgroundColor }
|
|
399
417
|
: {}),
|
|
418
|
+
...(defaultOverride?.inactiveColor
|
|
419
|
+
? { inactiveColor: defaultOverride.inactiveColor }
|
|
420
|
+
: {}),
|
|
400
421
|
...(focusedColor != null && focusedColor !== "" ? { focusedColor } : {}),
|
|
401
422
|
...(defaultOverride?.borderRadius !== undefined
|
|
402
423
|
? { cornerRadius: defaultOverride.borderRadius }
|
|
@@ -413,47 +434,62 @@ function mergeButtonBackground(
|
|
|
413
434
|
...(defaultOverride?.paddingLeft !== undefined
|
|
414
435
|
? { paddingLeft: defaultOverride.paddingLeft }
|
|
415
436
|
: {}),
|
|
437
|
+
...(defaultOverride?.horizontalGutter !== undefined
|
|
438
|
+
? { horizontalGutter: defaultOverride.horizontalGutter }
|
|
439
|
+
: {}),
|
|
416
440
|
};
|
|
417
441
|
}
|
|
418
442
|
|
|
419
443
|
function mergeButtonTitle(
|
|
420
444
|
base: ButtonTitleConfiguration,
|
|
421
|
-
override?: Record<string, any
|
|
445
|
+
override?: Record<string, any>,
|
|
446
|
+
focusedOverride?: Record<string, any>
|
|
422
447
|
): ButtonTitleConfiguration {
|
|
423
|
-
if (!override) return base;
|
|
448
|
+
if (!override && !focusedOverride) return base;
|
|
449
|
+
|
|
450
|
+
const fontFamily = fontFamilyName(override?.fontFamily);
|
|
451
|
+
|
|
452
|
+
const focusedFontColor =
|
|
453
|
+
focusedOverride?.fontColor || override?.focusedFontColor;
|
|
454
|
+
|
|
455
|
+
const inactiveFontColor = override?.inactiveFontColor;
|
|
424
456
|
|
|
425
457
|
return {
|
|
426
458
|
...base,
|
|
427
|
-
...(override
|
|
428
|
-
...(
|
|
429
|
-
...(
|
|
459
|
+
...(override?.fontColor ? { fontColor: override.fontColor } : {}),
|
|
460
|
+
...(focusedFontColor ? { focusedFontColor } : {}),
|
|
461
|
+
...(inactiveFontColor ? { inactiveFontColor } : {}),
|
|
462
|
+
...(override?.fontSize !== undefined
|
|
463
|
+
? { fontSize: override.fontSize }
|
|
464
|
+
: {}),
|
|
465
|
+
...(override?.lineHeight !== undefined
|
|
430
466
|
? { lineHeight: override.lineHeight }
|
|
431
467
|
: {}),
|
|
432
|
-
...(
|
|
468
|
+
...(fontFamily
|
|
433
469
|
? {
|
|
434
|
-
iosFontFamily:
|
|
435
|
-
androidFontFamily:
|
|
470
|
+
iosFontFamily: fontFamily,
|
|
471
|
+
androidFontFamily: fontFamily,
|
|
436
472
|
}
|
|
437
473
|
: {}),
|
|
438
|
-
...(override
|
|
474
|
+
...(override?.iosFontFamily
|
|
439
475
|
? { iosFontFamily: override.iosFontFamily }
|
|
440
476
|
: {}),
|
|
441
|
-
...(override
|
|
477
|
+
...(override?.androidFontFamily
|
|
442
478
|
? { androidFontFamily: override.androidFontFamily }
|
|
443
479
|
: {}),
|
|
444
|
-
...(override
|
|
480
|
+
...(override?.letterSpacing !== undefined
|
|
445
481
|
? {
|
|
446
482
|
iosLetterSpacing: override.letterSpacing,
|
|
447
483
|
androidLetterSpacing: override.letterSpacing,
|
|
448
484
|
}
|
|
449
485
|
: {}),
|
|
450
|
-
...(override
|
|
486
|
+
...(override?.iosLetterSpacing !== undefined
|
|
451
487
|
? { iosLetterSpacing: override.iosLetterSpacing }
|
|
452
488
|
: {}),
|
|
453
|
-
...(override
|
|
489
|
+
...(override?.androidLetterSpacing !== undefined
|
|
454
490
|
? { androidLetterSpacing: override.androidLetterSpacing }
|
|
455
491
|
: {}),
|
|
456
|
-
...(override
|
|
492
|
+
...(override?.textTransform
|
|
457
493
|
? { textTransform: override.textTransform }
|
|
458
494
|
: {}),
|
|
459
495
|
};
|
|
@@ -509,13 +545,19 @@ export function mergeButtonConfiguration(
|
|
|
509
545
|
const titleOverride =
|
|
510
546
|
buttonBlock?.title?.default || actionBlock?.title?.default;
|
|
511
547
|
|
|
548
|
+
const titleFocused =
|
|
549
|
+
buttonBlock?.title?.focused ||
|
|
550
|
+
buttonBlock?.title?.focus ||
|
|
551
|
+
actionBlock?.title?.focused ||
|
|
552
|
+
actionBlock?.title?.focus;
|
|
553
|
+
|
|
512
554
|
const iconsOverride = buttonBlock?.icons || actionBlock?.icons;
|
|
513
555
|
const leadingOverride = buttonBlock?.leadingIcon || actionBlock?.leadingIcon;
|
|
514
556
|
|
|
515
557
|
return {
|
|
516
558
|
...base,
|
|
517
559
|
background: mergeButtonBackground(base.background, bgDefault, bgFocused),
|
|
518
|
-
title: mergeButtonTitle(base.title, titleOverride),
|
|
560
|
+
title: mergeButtonTitle(base.title, titleOverride, titleFocused),
|
|
519
561
|
icons: mergeButtonIcons(base.icons, iconsOverride, leadingOverride),
|
|
520
562
|
};
|
|
521
563
|
}
|
|
@@ -90,6 +90,7 @@ type ModalComponentProps = {
|
|
|
90
90
|
/** Optional body that replaces the items list (header stays DefaultModalHeader). */
|
|
91
91
|
contentComponent?: React.ComponentType<any>;
|
|
92
92
|
contentComponentProps?: Record<string, any>;
|
|
93
|
+
themePluginId?: string;
|
|
93
94
|
styleOverrides?: ModalBlocksConfig | Record<string, any>;
|
|
94
95
|
measurementPhase?: boolean;
|
|
95
96
|
/** Copy under Next Up when the queue has no upcoming items. */
|
|
@@ -115,7 +116,7 @@ function _BottomSheetModalContent(props: ModalComponentProps) {
|
|
|
115
116
|
iconPlacement,
|
|
116
117
|
contentComponent: ContentComponent,
|
|
117
118
|
contentComponentProps = {},
|
|
118
|
-
|
|
119
|
+
themePluginId: themePluginIdProp,
|
|
119
120
|
measurementPhase = false,
|
|
120
121
|
emptyMessage,
|
|
121
122
|
} = props;
|
|
@@ -140,12 +141,14 @@ function _BottomSheetModalContent(props: ModalComponentProps) {
|
|
|
140
141
|
role,
|
|
141
142
|
behavior,
|
|
142
143
|
editableCollection,
|
|
143
|
-
themePluginId,
|
|
144
|
+
themePluginId: themePluginIdFromSheet,
|
|
144
145
|
} = useBottomSheetContent({
|
|
145
146
|
onPress,
|
|
146
147
|
viewModel,
|
|
147
148
|
});
|
|
148
149
|
|
|
150
|
+
const themePluginId = themePluginIdFromSheet || themePluginIdProp;
|
|
151
|
+
|
|
149
152
|
const plugins = usePlugins();
|
|
150
153
|
|
|
151
154
|
const plugin = useMemo(
|
|
@@ -157,78 +160,10 @@ function _BottomSheetModalContent(props: ModalComponentProps) {
|
|
|
157
160
|
const configuration =
|
|
158
161
|
plugin?.configuration || (plugin as any)?.configuration_json;
|
|
159
162
|
|
|
160
|
-
|
|
161
|
-
configuration
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
if (!propStyleOverrides) {
|
|
166
|
-
return parsed;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// hydrate(QueueStyles) only emits sectionHeader after the plugin class
|
|
170
|
-
// includes it. Until then, Studio/local keys in configuration_json still
|
|
171
|
-
// apply via the parser.
|
|
172
|
-
const hydratedSection = propStyleOverrides.sectionHeader;
|
|
173
|
-
|
|
174
|
-
const hasTitleStyle = (style?: Record<string, any>) =>
|
|
175
|
-
Boolean(
|
|
176
|
-
style &&
|
|
177
|
-
(style.fontColor ||
|
|
178
|
-
style.fontSize !== undefined ||
|
|
179
|
-
style.lineHeight !== undefined ||
|
|
180
|
-
style.fontFamily ||
|
|
181
|
-
style.iosFontFamily ||
|
|
182
|
-
style.androidFontFamily ||
|
|
183
|
-
style.letterSpacing !== undefined ||
|
|
184
|
-
style.iosLetterSpacing !== undefined ||
|
|
185
|
-
style.androidLetterSpacing !== undefined ||
|
|
186
|
-
style.textTransform ||
|
|
187
|
-
style.alignment)
|
|
188
|
-
);
|
|
189
|
-
|
|
190
|
-
const hasActionStyle = (style?: Record<string, any>) =>
|
|
191
|
-
Boolean(
|
|
192
|
-
style &&
|
|
193
|
-
(style.backgroundColor ||
|
|
194
|
-
style.fontColor ||
|
|
195
|
-
style.fontSize !== undefined ||
|
|
196
|
-
style.lineHeight !== undefined ||
|
|
197
|
-
style.fontFamily ||
|
|
198
|
-
style.iosFontFamily ||
|
|
199
|
-
style.androidFontFamily ||
|
|
200
|
-
style.letterSpacing !== undefined ||
|
|
201
|
-
style.iosLetterSpacing !== undefined ||
|
|
202
|
-
style.androidLetterSpacing !== undefined ||
|
|
203
|
-
style.textTransform ||
|
|
204
|
-
style.borderRadius !== undefined ||
|
|
205
|
-
style.cornerRadius !== undefined ||
|
|
206
|
-
style.paddingTop !== undefined ||
|
|
207
|
-
style.paddingRight !== undefined ||
|
|
208
|
-
style.paddingBottom !== undefined ||
|
|
209
|
-
style.paddingLeft !== undefined)
|
|
210
|
-
);
|
|
211
|
-
|
|
212
|
-
const actionNode = hydratedSection?.actionButtons;
|
|
213
|
-
|
|
214
|
-
// An empty `default: {}` is truthy and would hide fields set on the flat
|
|
215
|
-
// object or on the focused bucket.
|
|
216
|
-
const hasHydratedSection =
|
|
217
|
-
hasTitleStyle(hydratedSection?.title?.default) ||
|
|
218
|
-
hasTitleStyle(hydratedSection?.title) ||
|
|
219
|
-
hasActionStyle(actionNode?.default) ||
|
|
220
|
-
hasActionStyle(actionNode?.focused) ||
|
|
221
|
-
hasActionStyle(actionNode?.focus) ||
|
|
222
|
-
hasActionStyle(actionNode);
|
|
223
|
-
|
|
224
|
-
return {
|
|
225
|
-
...parsed,
|
|
226
|
-
...propStyleOverrides,
|
|
227
|
-
sectionHeader: hasHydratedSection
|
|
228
|
-
? hydratedSection
|
|
229
|
-
: parsed?.sectionHeader,
|
|
230
|
-
};
|
|
231
|
-
}, [propStyleOverrides, plugin, themePluginId]);
|
|
163
|
+
return configuration && themePluginId
|
|
164
|
+
? parseModalBlocksConfiguration(configuration, themePluginId)
|
|
165
|
+
: null;
|
|
166
|
+
}, [plugin, themePluginId]);
|
|
232
167
|
|
|
233
168
|
const pluginLocalizations = useLocalizedStrings({
|
|
234
169
|
localizations:
|
|
@@ -87,9 +87,7 @@ export const SortableList = ({
|
|
|
87
87
|
const [localData, setLocalData] = useState(sortableData);
|
|
88
88
|
|
|
89
89
|
useEffect(() => {
|
|
90
|
-
setLocalData(
|
|
91
|
-
localData !== sortableData ? sortableData : localData
|
|
92
|
-
);
|
|
90
|
+
setLocalData(sortableData);
|
|
93
91
|
}, [sortableData]);
|
|
94
92
|
|
|
95
93
|
const handleDragEnd = useCallback(
|
|
@@ -142,6 +140,7 @@ export const SortableList = ({
|
|
|
142
140
|
>
|
|
143
141
|
{renderHeader}
|
|
144
142
|
<Sortable.Grid
|
|
143
|
+
key={`sortable-grid-${localData.length}`}
|
|
145
144
|
scrollableRef={scrollableRef}
|
|
146
145
|
customHandle
|
|
147
146
|
columns={columns}
|
|
@@ -92,4 +92,29 @@ describe("showTextInputAction", () => {
|
|
|
92
92
|
expect(result).toBe(ActionResult.Error);
|
|
93
93
|
expect(actionExecutor.handleAction).not.toHaveBeenCalled();
|
|
94
94
|
});
|
|
95
|
+
|
|
96
|
+
it("forwards themePluginId so the sheet can read plugin button styles", async () => {
|
|
97
|
+
const action = {
|
|
98
|
+
type: "showTextInput",
|
|
99
|
+
options: {
|
|
100
|
+
headerTitle: "Create New Playlist",
|
|
101
|
+
inputLabel: "Name your playlist",
|
|
102
|
+
buttonLabel: "Create",
|
|
103
|
+
themePluginId: "playlist-experience",
|
|
104
|
+
actions: [{ type: "sendCloudEvent", options: {} }],
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
await showTextInputAction(action as any);
|
|
109
|
+
|
|
110
|
+
expect(actionExecutor.handleAction).toHaveBeenCalledWith(
|
|
111
|
+
expect.objectContaining({
|
|
112
|
+
type: "openBottomSheet",
|
|
113
|
+
options: expect.objectContaining({
|
|
114
|
+
themePluginId: "playlist-experience",
|
|
115
|
+
}),
|
|
116
|
+
}),
|
|
117
|
+
undefined
|
|
118
|
+
);
|
|
119
|
+
});
|
|
95
120
|
});
|
|
@@ -21,6 +21,7 @@ export async function showTextInputAction(
|
|
|
21
21
|
validationLabel,
|
|
22
22
|
actions,
|
|
23
23
|
maxLength,
|
|
24
|
+
themePluginId,
|
|
24
25
|
} = action.options || {};
|
|
25
26
|
|
|
26
27
|
if (!headerTitle || !buttonLabel || !actions || !actions.length) {
|
|
@@ -34,6 +35,7 @@ export async function showTextInputAction(
|
|
|
34
35
|
header: {
|
|
35
36
|
title: headerTitle,
|
|
36
37
|
},
|
|
38
|
+
...(themePluginId ? { themePluginId } : {}),
|
|
37
39
|
content: {
|
|
38
40
|
component: TextInputContent,
|
|
39
41
|
props: {
|
|
@@ -10,6 +10,28 @@ jest.useFakeTimers({ legacyFakeTimers: true });
|
|
|
10
10
|
// isConnected/isInternetReachable/details fields, so the mock has to mirror
|
|
11
11
|
// that shape for online/offline to actually be distinguishable.
|
|
12
12
|
let mockConnectionStatus = false;
|
|
13
|
+
let mockStillOfflineAfterResumeCount = 0;
|
|
14
|
+
|
|
15
|
+
const mockComponentsLogger = {
|
|
16
|
+
log: jest.fn(),
|
|
17
|
+
debug: jest.fn(),
|
|
18
|
+
info: jest.fn(),
|
|
19
|
+
warning: jest.fn(),
|
|
20
|
+
error: jest.fn(),
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
jest.mock("../../../Helpers/logger", () => {
|
|
24
|
+
const proxy = {
|
|
25
|
+
log: (event) => mockComponentsLogger.log(event),
|
|
26
|
+
debug: (event) => mockComponentsLogger.debug(event),
|
|
27
|
+
info: (event) => mockComponentsLogger.info(event),
|
|
28
|
+
warning: (event) => mockComponentsLogger.warning(event),
|
|
29
|
+
error: (event) => mockComponentsLogger.error(event),
|
|
30
|
+
addSubsystem: () => proxy,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
return { componentsLogger: proxy };
|
|
34
|
+
});
|
|
13
35
|
|
|
14
36
|
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/connection", () => {
|
|
15
37
|
return {
|
|
@@ -20,6 +42,7 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/connection", () => {
|
|
|
20
42
|
details: {},
|
|
21
43
|
isConnected: mockConnectionStatus,
|
|
22
44
|
isInternetReachable: mockConnectionStatus,
|
|
45
|
+
stillOfflineAfterResumeCount: mockStillOfflineAfterResumeCount,
|
|
23
46
|
})),
|
|
24
47
|
};
|
|
25
48
|
});
|
|
@@ -58,6 +81,7 @@ describe("OfflineHandler", () => {
|
|
|
58
81
|
|
|
59
82
|
beforeEach(() => {
|
|
60
83
|
mockConnectionStatus = false;
|
|
84
|
+
mockStillOfflineAfterResumeCount = 0;
|
|
61
85
|
});
|
|
62
86
|
|
|
63
87
|
it("renders its children without wrapping them in a notification view", () => {
|
|
@@ -131,4 +155,89 @@ describe("OfflineHandler", () => {
|
|
|
131
155
|
|
|
132
156
|
unsubscribe();
|
|
133
157
|
});
|
|
158
|
+
|
|
159
|
+
it("re-shows the offline toast when still offline after app resume", () => {
|
|
160
|
+
mockConnectionStatus = false;
|
|
161
|
+
|
|
162
|
+
const handleShowToast = jest.fn();
|
|
163
|
+
const unsubscribe = subscriberFor("showToast", handleShowToast);
|
|
164
|
+
|
|
165
|
+
const { rerender } = render(<OfflineHandler />);
|
|
166
|
+
handleShowToast.mockClear();
|
|
167
|
+
|
|
168
|
+
mockStillOfflineAfterResumeCount = 1;
|
|
169
|
+
rerender(<OfflineHandler />);
|
|
170
|
+
|
|
171
|
+
expect(handleShowToast).toHaveBeenCalledTimes(1);
|
|
172
|
+
|
|
173
|
+
expect(handleShowToast).toHaveBeenCalledWith(
|
|
174
|
+
expect.objectContaining({
|
|
175
|
+
id: "offline-status",
|
|
176
|
+
message: "No internet connection",
|
|
177
|
+
timeout: 5000,
|
|
178
|
+
}),
|
|
179
|
+
expect.any(Function)
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
// further renders with the same counter must not re-emit
|
|
183
|
+
rerender(<OfflineHandler />);
|
|
184
|
+
expect(handleShowToast).toHaveBeenCalledTimes(1);
|
|
185
|
+
|
|
186
|
+
unsubscribe();
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it("does not re-show the offline toast for a counter bump while online", () => {
|
|
190
|
+
mockConnectionStatus = true;
|
|
191
|
+
|
|
192
|
+
const handleShowToast = jest.fn();
|
|
193
|
+
const unsubscribe = subscriberFor("showToast", handleShowToast);
|
|
194
|
+
|
|
195
|
+
const { rerender } = render(<OfflineHandler />);
|
|
196
|
+
|
|
197
|
+
mockStillOfflineAfterResumeCount = 1;
|
|
198
|
+
rerender(<OfflineHandler />);
|
|
199
|
+
|
|
200
|
+
expect(handleShowToast).not.toHaveBeenCalled();
|
|
201
|
+
|
|
202
|
+
unsubscribe();
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
it("does not emit on mount just because the counter is already > 0", () => {
|
|
206
|
+
mockConnectionStatus = true;
|
|
207
|
+
mockStillOfflineAfterResumeCount = 3;
|
|
208
|
+
|
|
209
|
+
const handleShowToast = jest.fn();
|
|
210
|
+
const unsubscribe = subscriberFor("showToast", handleShowToast);
|
|
211
|
+
|
|
212
|
+
render(<OfflineHandler />);
|
|
213
|
+
|
|
214
|
+
expect(handleShowToast).not.toHaveBeenCalled();
|
|
215
|
+
|
|
216
|
+
unsubscribe();
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
it("logs toast emissions at info level", () => {
|
|
220
|
+
mockConnectionStatus = false;
|
|
221
|
+
mockComponentsLogger.info.mockClear();
|
|
222
|
+
mockComponentsLogger.warning.mockClear();
|
|
223
|
+
|
|
224
|
+
const { rerender } = render(<OfflineHandler />);
|
|
225
|
+
|
|
226
|
+
mockConnectionStatus = true;
|
|
227
|
+
rerender(<OfflineHandler />);
|
|
228
|
+
|
|
229
|
+
expect(mockComponentsLogger.info).toHaveBeenCalledWith(
|
|
230
|
+
expect.objectContaining({
|
|
231
|
+
message: "OfflineHandler: device is offline, emit toast",
|
|
232
|
+
})
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
expect(mockComponentsLogger.info).toHaveBeenCalledWith(
|
|
236
|
+
expect.objectContaining({
|
|
237
|
+
message: "OfflineHandler: device is back online, emit toast",
|
|
238
|
+
})
|
|
239
|
+
);
|
|
240
|
+
|
|
241
|
+
expect(mockComponentsLogger.warning).not.toHaveBeenCalled();
|
|
242
|
+
});
|
|
134
243
|
});
|
|
@@ -29,12 +29,22 @@ export const OfflineHandler = ({ children }: Props) => {
|
|
|
29
29
|
const { online } = parseConnectionInfo(connectionInfo);
|
|
30
30
|
const prevOnline = usePrevious(online);
|
|
31
31
|
|
|
32
|
+
const stillOfflineAfterResumeCount =
|
|
33
|
+
connectionInfo?.stillOfflineAfterResumeCount ?? 0;
|
|
34
|
+
|
|
35
|
+
const prevStillOfflineAfterResumeCount = usePrevious(
|
|
36
|
+
stillOfflineAfterResumeCount
|
|
37
|
+
);
|
|
38
|
+
|
|
32
39
|
const emitShowToast = useSubscriberFor(SHOW_TOAST_EVENT);
|
|
33
40
|
|
|
34
41
|
const { message, extraMessage, style } = useOfflineHandlerProps(online);
|
|
35
42
|
|
|
36
43
|
const showOnlineToast = useCallback(() => {
|
|
37
|
-
logger.
|
|
44
|
+
logger.info({
|
|
45
|
+
message: "OfflineHandler: device is back online, emit toast",
|
|
46
|
+
data: { online, prevOnline },
|
|
47
|
+
});
|
|
38
48
|
|
|
39
49
|
emitShowToast({
|
|
40
50
|
id: OFFLINE_STATUS_TOAST_ID,
|
|
@@ -43,10 +53,13 @@ export const OfflineHandler = ({ children }: Props) => {
|
|
|
43
53
|
style,
|
|
44
54
|
timeout: timers.goingOnline,
|
|
45
55
|
});
|
|
46
|
-
}, [emitShowToast, message, extraMessage, style]);
|
|
56
|
+
}, [emitShowToast, message, extraMessage, style, online, prevOnline]);
|
|
47
57
|
|
|
48
58
|
const showOfflineToast = useCallback(() => {
|
|
49
|
-
logger.
|
|
59
|
+
logger.info({
|
|
60
|
+
message: "OfflineHandler: device is offline, emit toast",
|
|
61
|
+
data: { online, prevOnline, stillOfflineAfterResumeCount },
|
|
62
|
+
});
|
|
50
63
|
|
|
51
64
|
emitShowToast({
|
|
52
65
|
id: OFFLINE_STATUS_TOAST_ID,
|
|
@@ -55,7 +68,15 @@ export const OfflineHandler = ({ children }: Props) => {
|
|
|
55
68
|
style,
|
|
56
69
|
timeout: timers.goingOffline,
|
|
57
70
|
});
|
|
58
|
-
}, [
|
|
71
|
+
}, [
|
|
72
|
+
emitShowToast,
|
|
73
|
+
message,
|
|
74
|
+
extraMessage,
|
|
75
|
+
style,
|
|
76
|
+
online,
|
|
77
|
+
prevOnline,
|
|
78
|
+
stillOfflineAfterResumeCount,
|
|
79
|
+
]);
|
|
59
80
|
|
|
60
81
|
useEffect(() => {
|
|
61
82
|
// On mount there is no previous state yet: only surface the offline toast
|
|
@@ -79,5 +100,22 @@ export const OfflineHandler = ({ children }: Props) => {
|
|
|
79
100
|
}
|
|
80
101
|
}, [online, prevOnline, showOfflineToast, showOnlineToast]);
|
|
81
102
|
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
// NetworkStatusProvider bumps this counter when the app resumed while offline
|
|
105
|
+
// and is still offline after the verification delay: remind the user.
|
|
106
|
+
if (
|
|
107
|
+
prevStillOfflineAfterResumeCount !== undefined &&
|
|
108
|
+
stillOfflineAfterResumeCount > prevStillOfflineAfterResumeCount &&
|
|
109
|
+
!online
|
|
110
|
+
) {
|
|
111
|
+
showOfflineToast();
|
|
112
|
+
}
|
|
113
|
+
}, [
|
|
114
|
+
stillOfflineAfterResumeCount,
|
|
115
|
+
prevStillOfflineAfterResumeCount,
|
|
116
|
+
online,
|
|
117
|
+
showOfflineToast,
|
|
118
|
+
]);
|
|
119
|
+
|
|
82
120
|
return children;
|
|
83
121
|
};
|
|
@@ -404,10 +404,17 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
404
404
|
const { eventType } = event;
|
|
405
405
|
|
|
406
406
|
if (!isLanguageOverlayVisible && eventType === "menu") {
|
|
407
|
+
// First Back dismisses Play Next, the next one closes the player
|
|
408
|
+
if (playNextOverlayState) {
|
|
409
|
+
playNextOverlayState.handleUserCancelPlayNext();
|
|
410
|
+
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
|
|
407
414
|
close();
|
|
408
415
|
}
|
|
409
416
|
},
|
|
410
|
-
[close]
|
|
417
|
+
[close, playNextOverlayState]
|
|
411
418
|
);
|
|
412
419
|
|
|
413
420
|
// Effects
|
|
@@ -118,7 +118,10 @@ function ComponentsMapComponent(props: Props) {
|
|
|
118
118
|
};
|
|
119
119
|
|
|
120
120
|
return (
|
|
121
|
-
<ScreenLoadingMeasurementsListItemWrapper
|
|
121
|
+
<ScreenLoadingMeasurementsListItemWrapper
|
|
122
|
+
index={index}
|
|
123
|
+
testID={`component-${item.id}`}
|
|
124
|
+
>
|
|
122
125
|
<RiverItem {...riverItemProps} />
|
|
123
126
|
</ScreenLoadingMeasurementsListItemWrapper>
|
|
124
127
|
);
|
|
@@ -213,6 +213,7 @@ exports[`componentsMap renders renders components map correctly 1`] = `
|
|
|
213
213
|
<View
|
|
214
214
|
onLayout={[Function]}
|
|
215
215
|
style={{}}
|
|
216
|
+
testID="component-A1"
|
|
216
217
|
>
|
|
217
218
|
<View />
|
|
218
219
|
</View>
|
|
@@ -225,6 +226,7 @@ exports[`componentsMap renders renders components map correctly 1`] = `
|
|
|
225
226
|
<View
|
|
226
227
|
onLayout={[Function]}
|
|
227
228
|
style={{}}
|
|
229
|
+
testID="component-A2"
|
|
228
230
|
/>
|
|
229
231
|
</View>
|
|
230
232
|
<View
|
|
@@ -66,7 +66,7 @@ export class AnimationManager {
|
|
|
66
66
|
*
|
|
67
67
|
* @param {object} to contains style to animate and scenes index
|
|
68
68
|
* @param {string} action push|back
|
|
69
|
-
* @param {number} stepsBack number of steps back
|
|
69
|
+
* @param {number} [stepsBack] number of steps back, used by the back action only
|
|
70
70
|
*/
|
|
71
71
|
stateForAction({ to, scenes }, action, stepsBack) {
|
|
72
72
|
let rootIndex = to.index;
|
|
@@ -17,13 +17,14 @@ const fullWidthDimensions = {
|
|
|
17
17
|
type Props = {
|
|
18
18
|
children: any;
|
|
19
19
|
style: any;
|
|
20
|
-
pointerEvents
|
|
21
|
-
overlayStyle
|
|
22
|
-
animating
|
|
20
|
+
pointerEvents?: ViewProps["pointerEvents"];
|
|
21
|
+
overlayStyle?: ViewStyle;
|
|
22
|
+
animating?: boolean;
|
|
23
23
|
contentStyle: ViewStyle;
|
|
24
24
|
pathname: string;
|
|
25
25
|
isActive: boolean;
|
|
26
26
|
screenData: NavigationScreenData;
|
|
27
|
+
screenUniqueId?: string;
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
export function CurrentScreenContextProvider({
|