@applicaster/zapp-react-native-utils 16.0.0-rc.99 → 17.0.0-alpha.1102403272
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/actionUtils/index.ts +3 -1
- package/actionsExecutor/ActionExecutor.ts +2 -2
- package/actionsExecutor/ActionExecutorContext.tsx +2 -2
- package/actionsExecutor/__tests__/StorageActions.test.ts +98 -0
- package/actionsExecutor/__tests__/feedDecorator.test.ts +30 -0
- package/actionsExecutor/__tests__/screenToggleFlag.test.ts +90 -0
- package/actionsExecutor/actions/__tests__/navigateToScreen.test.ts +186 -5
- package/actionsExecutor/actions/__tests__/openBottomSheet.customContent.test.ts +24 -0
- package/actionsExecutor/actions/__tests__/openBottomSheet.inlineItems.test.ts +72 -0
- package/actionsExecutor/actions/appRestart.ts +2 -2
- package/actionsExecutor/actions/confirmDialog.ts +2 -2
- package/actionsExecutor/actions/dismissBottomSheet.ts +2 -2
- package/actionsExecutor/actions/goBack.ts +2 -2
- package/actionsExecutor/actions/goHome.ts +2 -2
- package/actionsExecutor/actions/navigateToScreen.ts +46 -45
- package/actionsExecutor/actions/openBottomSheet.ts +4 -2
- package/actionsExecutor/actions/presentScreen.ts +2 -2
- package/actionsExecutor/actions/refreshComponent.ts +2 -2
- package/actionsExecutor/actions/screenToggleFlag.ts +1 -3
- package/actionsExecutor/actions/sendCloudEvent.ts +2 -2
- package/actionsExecutor/actions/showAlert.ts +2 -2
- package/actionsExecutor/actions/switchLayout.ts +2 -2
- package/actionsExecutor/feedDecorator.ts +8 -2
- package/actionsExecutor/types.ts +7 -0
- package/analyticsUtils/__tests__/playerAnalyticsSafeguard.test.ts +62 -0
- package/analyticsUtils/logger.ts +9 -4
- package/analyticsUtils/playerAnalyticsTracker.ts +1 -0
- package/appUtils/HooksManager/index.ts +10 -2
- package/appUtils/HooksManager/logger.ts +5 -2
- package/appUtils/accessibilityManager/logger.ts +2 -4
- package/appUtils/accessibilityManager/utils.ts +1 -1
- package/appUtils/contextKeysManager/__tests__/getKey/failure.test.ts +1 -22
- package/appUtils/contextKeysManager/__tests__/getKey/success/fullSearch.test.ts +1 -25
- package/appUtils/contextKeysManager/__tests__/getKey/success/searchInSecure.test.ts +1 -7
- package/appUtils/contextKeysManager/__tests__/removeKey/failure.test.ts +0 -25
- package/appUtils/contextKeysManager/__tests__/removeKey/success.test.ts +0 -6
- package/appUtils/contextKeysManager/__tests__/setKey/failure/failedToSaveInStorage.test.ts +0 -40
- package/appUtils/contextKeysManager/__tests__/setKey/{success/saveItemAndReference.test.ts → success.test.ts} +2 -42
- package/appUtils/contextKeysManager/index.ts +30 -131
- package/appUtils/focusManager/__tests__/focusManager.test.js +33 -0
- package/appUtils/focusManager/__tests__/focusToolbox.test.ts +357 -0
- package/appUtils/focusManager/focusToolbox.ts +223 -0
- package/appUtils/focusManager/index.ios.ts +7 -1
- package/appUtils/focusManager/index.ts +3 -3
- package/appUtils/focusManager/logger.ts +2 -2
- package/appUtils/focusManagerAux/index.ts +2 -2
- package/appUtils/orientationHelper.ts +2 -2
- package/appUtils/platform/platformUtils.ts +6 -22
- package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +1 -1
- package/appUtils/playerManager/__tests__/playerDiagnostics.test.ts +62 -0
- package/appUtils/playerManager/__tests__/playerNative.test.ts +76 -0
- package/appUtils/playerManager/__tests__/playerNativeCommand.test.ts +62 -0
- package/appUtils/playerManager/__tests__/playerToolbox.test.ts +281 -0
- package/appUtils/playerManager/__tests__/usePlayerControllerSetup.test.tsx +62 -0
- package/appUtils/playerManager/const.ts +13 -0
- package/appUtils/playerManager/index.ts +9 -2
- package/appUtils/playerManager/player.ts +28 -1
- package/appUtils/playerManager/playerNative.ts +23 -1
- package/appUtils/playerManager/playerNativeCommand.ts +3 -6
- package/appUtils/playerManager/playerToolbox.ts +196 -0
- package/appUtils/playerManager/usePlayNextOverlay.tsx +2 -2
- package/appUtils/playerManager/usePlayerControllerSetup.tsx +6 -0
- package/appUtils/playerManager/userCellPlayerMutedPreference.ts +1 -1
- package/appUtils/playerManager/userLanguagePreference.ts +1 -1
- package/arrayUtils/__tests__/reorderByIds.test.ts +13 -0
- package/arrayUtils/index.ts +26 -43
- package/cellUtils/__tests__/getButtonsEnabled.test.ts +28 -0
- package/cellUtils/__tests__/getCellNavigationEnabled.test.ts +36 -0
- package/cellUtils/__tests__/getIsCellNavigationEnabled.test.ts +35 -0
- package/cellUtils/__tests__/isCellNavigationEnabled.test.ts +21 -0
- package/cellUtils/index.ts +40 -0
- package/cellUtils/logger.ts +2 -2
- package/configurationUtils/__tests__/modalBlocksParser.test.ts +134 -0
- package/configurationUtils/modalBlocksParser.ts +38 -0
- package/debugging/DebugFeatues.tsx +2 -25
- package/debugging/DebugFeatures.ts +495 -0
- package/debugging/__tests__/DebugFeatures.test.ts +313 -0
- package/debugging/index.ts +3 -0
- package/domUtils/logger.ts +2 -2
- package/entryActions/aliasPresentation.ts +1 -0
- package/entryActions/buildEntryActions.ts +1 -1
- package/errorUtils/index.ts +2 -0
- package/focusManager/FocusManager.ts +43 -6
- package/focusManager/__tests__/FocusManager.test.ts +124 -3
- package/focusManager/focusToolbox.ts +208 -0
- package/focusManager/index.ts +7 -0
- package/focusManager/logger.ts +2 -6
- package/headersUtils/index.ts +2 -2
- package/localizationUtils/index.ts +12 -6
- package/logger/__tests__/subsystems.test.ts +148 -0
- package/logger/__tests__/xrayToolbox.test.ts +69 -0
- package/logger/index.ts +48 -9
- package/logger/subsystems.ts +112 -0
- package/logger/xrayToolbox.ts +69 -0
- package/manifestUtils/__tests__/createConfig.test.js +17 -7
- package/manifestUtils/_internals/getDefaultConfiguration.js +9 -11
- package/manifestUtils/defaultManifestConfigurations/player.js +8 -0
- package/manifestUtils/keys.js +7 -2
- package/manifestUtils/mobileAction/container/__tests__/mobileActionButtonsContainer.test.js +21 -0
- package/manifestUtils/mobileAction/groups/__tests__/buildMobileActionButtonGroups.test.js +1 -1
- package/manifestUtils/mobileAction/groups/defaults.js +2 -1
- package/modalState/EditableCollectionRegistry.ts +1 -1
- package/modalState/ModalOrchestrator.ts +1 -0
- package/modalState/RemoteEditableCollection.ts +1 -1
- package/modalState/__tests__/ModalOrchestrator.phase3.test.ts +23 -0
- package/modalState/index.ts +2 -0
- package/modalState/types.ts +11 -0
- package/navigationUtils/index.ts +5 -2
- package/navigationUtils/xrayNavigator.ts +12 -0
- package/numberUtils/index.ts +2 -2
- package/package.json +3 -2
- package/playerUtils/PlayerTTS/PlayerTTS.ts +1 -1
- package/playerUtils/imaScriptDom.ts +1 -1
- package/playerUtils/useValidatePlayerConfig.tsx +1 -1
- package/pluginUtils/logger.ts +2 -2
- package/quickBrickAssets/__tests__/index.test.ts +18 -0
- package/quickBrickAssets/index.ts +35 -0
- package/reactHooks/__tests__/getPluginConfiguration.test.ts +82 -0
- package/reactHooks/actions/index.ts +29 -23
- package/reactHooks/cell-click/__tests__/index.test.js +67 -1
- package/reactHooks/cell-click/helpers.ts +3 -1
- package/reactHooks/cell-click/index.ts +10 -2
- package/reactHooks/connection/index.tsx +8 -5
- package/reactHooks/feed/__tests__/feedInvalidation.test.tsx +338 -0
- package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +8 -2
- package/reactHooks/feed/__tests__/useMarkPipesDataStale.test.tsx +243 -0
- package/reactHooks/feed/useBuildPipesUrl.ts +5 -2
- package/reactHooks/feed/useFeedLoader.tsx +30 -3
- package/reactHooks/feed/useLoadPipesDataDispatch.ts +12 -11
- package/reactHooks/feed/useMarkPipesDataStale.ts +68 -23
- package/reactHooks/hookModal/hooks/useHookModalScreenData.ts +5 -2
- package/reactHooks/logger.ts +5 -2
- package/reactHooks/navigation/usePresentScreen.ts +19 -6
- package/reactHooks/player/TVSeekControlller/TVSeekController.ts +2 -2
- package/reactHooks/resolvers/useComponentResolver.ts +10 -0
- package/reactHooks/screen/useScreenData.ts +2 -2
- package/reactHooks/usePluginConfiguration.ts +84 -46
- package/reactHooks/videoModal/hooks/useChangeOrientation.ts +2 -7
- package/reactHooks/videoModal/hooks/useVideoModalScreenData.tsx +1 -1
- package/reactUtils/__tests__/deviceTargetGuards.test.js +73 -0
- package/reactUtils/createContext/helpers.ts +2 -2
- package/reactUtils/index.ts +28 -0
- package/reactUtils/logger.ts +2 -2
- package/riverComponetsMeasurementProvider/index.tsx +5 -5
- package/storage/ScreenSingleValueProvider.ts +1 -1
- package/storage/ScreenStateMultiSelectProvider.ts +1 -1
- package/storage/StorageMultiSelectProvider.ts +1 -1
- package/storage/StorageSingleSelectProvider.ts +1 -1
- package/stylesUtils/logger.ts +2 -2
- package/uiActionsRegistrator/__tests__/subscribe.test.ts +26 -0
- package/uiActionsRegistrator/registry.ts +17 -1
- package/uiActionsRegistrator/resolveActionIdentifiers.ts +6 -2
- package/uiActionsRegistrator/usableActionItems.ts +1 -1
- package/zappFrameworkUtils/HookCallback/callbackNavigationAction.ts +2 -1
- package/zappFrameworkUtils/loginPluginUtils.ts +2 -1
- package/zappFrameworkUtils/presentPluginOneTime.ts +2 -1
- package/appUtils/contextKeysManager/__tests__/getKey/success/byReference.test.ts +0 -56
- package/appUtils/contextKeysManager/__tests__/getKeyByReference/failure.test.ts +0 -265
- package/appUtils/contextKeysManager/__tests__/getKeyByReference/success.test.ts +0 -303
- package/appUtils/contextKeysManager/__tests__/removeReferenceForKey/failure.test.ts +0 -82
- package/appUtils/contextKeysManager/__tests__/removeReferenceForKey/success.test.ts +0 -41
- package/appUtils/contextKeysManager/__tests__/setKey/success/saveItemButNotReference.test.ts +0 -208
- package/appUtils/contextKeysManager/__tests__/setReferenceForKey/failure.test.ts +0 -93
- package/appUtils/contextKeysManager/__tests__/setReferenceForKey/success.test.ts +0 -45
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { renderHook } from "@testing-library/react-native";
|
|
2
|
+
import * as zappPipesModule from "@applicaster/zapp-react-native-redux/ZappPipes";
|
|
3
|
+
import * as useRouteHook from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useRoute";
|
|
4
|
+
import * as useNavigationHooks from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
|
|
5
|
+
import * as useIsScreenActiveHook from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useIsScreenActive";
|
|
6
|
+
import { refreshCoordinator } from "../../../refreshUtils/RefreshCoordinator";
|
|
7
|
+
import { useMarkPipesDataStale } from "../useMarkPipesDataStale";
|
|
8
|
+
|
|
9
|
+
const mockDispatch = jest.fn();
|
|
10
|
+
|
|
11
|
+
jest.mock("@applicaster/zapp-react-native-redux", () => ({
|
|
12
|
+
...jest.requireActual("@applicaster/zapp-react-native-redux"),
|
|
13
|
+
useAppDispatch: () => mockDispatch,
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
jest.mock(
|
|
17
|
+
"@applicaster/zapp-react-native-ui-components/Decorators/RiverFeedLoader/utils/getDatasourceUrl",
|
|
18
|
+
() => ({
|
|
19
|
+
getDatasourceUrl: jest.fn(
|
|
20
|
+
(_ctx, component) => component?.data?.source || null
|
|
21
|
+
),
|
|
22
|
+
})
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
jest.mock(
|
|
26
|
+
"@applicaster/zapp-react-native-ui-components/Decorators/RiverFeedLoader/utils/usePipesContexts",
|
|
27
|
+
() => ({
|
|
28
|
+
usePipesContexts: jest.fn(() => ({})),
|
|
29
|
+
})
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
describe("useMarkPipesDataStale", () => {
|
|
33
|
+
let mockNavigator: any;
|
|
34
|
+
let mockRoute: any;
|
|
35
|
+
let mockIsActive: boolean;
|
|
36
|
+
|
|
37
|
+
const riverId = "river-123";
|
|
38
|
+
|
|
39
|
+
const refreshableComponent: any = {
|
|
40
|
+
id: "comp-1",
|
|
41
|
+
rules: { clear_cache_on_reload: true },
|
|
42
|
+
data: { source: "https://feed.example.com/data1" },
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const stringBooleanComponent: any = {
|
|
46
|
+
id: "comp-2",
|
|
47
|
+
rules: { clear_cache_on_reload: "true" },
|
|
48
|
+
data: { source: "https://feed.example.com/data2" },
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const nonRefreshableComponent: any = {
|
|
52
|
+
id: "comp-3",
|
|
53
|
+
rules: { clear_cache_on_reload: false },
|
|
54
|
+
data: { source: "https://feed.example.com/data3" },
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const noSourceComponent: any = {
|
|
58
|
+
id: "comp-4",
|
|
59
|
+
rules: { clear_cache_on_reload: true },
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const allComponents = [
|
|
63
|
+
refreshableComponent,
|
|
64
|
+
stringBooleanComponent,
|
|
65
|
+
nonRefreshableComponent,
|
|
66
|
+
noSourceComponent,
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
beforeEach(() => {
|
|
70
|
+
jest.clearAllMocks();
|
|
71
|
+
|
|
72
|
+
mockIsActive = true;
|
|
73
|
+
|
|
74
|
+
mockNavigator = {
|
|
75
|
+
currentRoute: "river/river-123",
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
mockRoute = {
|
|
79
|
+
pathname: "river/river-123",
|
|
80
|
+
screenData: { id: riverId },
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
jest
|
|
84
|
+
.spyOn(useNavigationHooks, "useNavigation")
|
|
85
|
+
.mockImplementation(() => mockNavigator);
|
|
86
|
+
|
|
87
|
+
jest.spyOn(useRouteHook, "useRoute").mockImplementation(() => mockRoute);
|
|
88
|
+
|
|
89
|
+
jest
|
|
90
|
+
.spyOn(useIsScreenActiveHook, "useIsScreenActive")
|
|
91
|
+
.mockImplementation(() => mockIsActive);
|
|
92
|
+
|
|
93
|
+
jest
|
|
94
|
+
.spyOn(refreshCoordinator, "triggerRefresh")
|
|
95
|
+
.mockImplementation(jest.fn());
|
|
96
|
+
|
|
97
|
+
jest
|
|
98
|
+
.spyOn(zappPipesModule, "markPipesDataStale")
|
|
99
|
+
.mockImplementation(
|
|
100
|
+
(url, opts) => ({ type: "MARK_STALE", url, opts }) as any
|
|
101
|
+
);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
describe("on unmount", () => {
|
|
105
|
+
it("marks clear_cache_on_reload feeds stale on unmount", () => {
|
|
106
|
+
const { unmount } = renderHook(() =>
|
|
107
|
+
useMarkPipesDataStale(riverId, allComponents)
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
expect(mockDispatch).not.toHaveBeenCalled();
|
|
111
|
+
|
|
112
|
+
unmount();
|
|
113
|
+
|
|
114
|
+
expect(zappPipesModule.markPipesDataStale).toHaveBeenCalledWith(
|
|
115
|
+
"https://feed.example.com/data1",
|
|
116
|
+
{ riverId }
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
expect(zappPipesModule.markPipesDataStale).toHaveBeenCalledWith(
|
|
120
|
+
"https://feed.example.com/data2",
|
|
121
|
+
{ riverId }
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
expect(zappPipesModule.markPipesDataStale).not.toHaveBeenCalledWith(
|
|
125
|
+
"https://feed.example.com/data3",
|
|
126
|
+
expect.anything()
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
expect(mockDispatch).toHaveBeenCalledTimes(2);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it("does not mark stale on unmount if pathname includes videoModal", () => {
|
|
133
|
+
mockRoute.pathname = "videoModal/item-123";
|
|
134
|
+
|
|
135
|
+
const { unmount } = renderHook(() =>
|
|
136
|
+
useMarkPipesDataStale(riverId, allComponents)
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
unmount();
|
|
140
|
+
|
|
141
|
+
expect(mockDispatch).not.toHaveBeenCalled();
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
describe("on screen return (screen not unmounted in Transitioner)", () => {
|
|
146
|
+
it("does not trigger refresh on initial mount", () => {
|
|
147
|
+
renderHook(() => useMarkPipesDataStale(riverId, allComponents));
|
|
148
|
+
|
|
149
|
+
expect(refreshCoordinator.triggerRefresh).not.toHaveBeenCalled();
|
|
150
|
+
expect(mockDispatch).not.toHaveBeenCalled();
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it("triggers refresh and marks stale when returning from a deeper screen", () => {
|
|
154
|
+
const { rerender } = renderHook(() =>
|
|
155
|
+
useMarkPipesDataStale(riverId, allComponents)
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
// 1. User navigates away to a deeper screen
|
|
159
|
+
mockNavigator.currentRoute = "river/deeper-screen";
|
|
160
|
+
mockIsActive = false;
|
|
161
|
+
rerender({});
|
|
162
|
+
|
|
163
|
+
expect(refreshCoordinator.triggerRefresh).not.toHaveBeenCalled();
|
|
164
|
+
expect(mockDispatch).not.toHaveBeenCalled();
|
|
165
|
+
|
|
166
|
+
// 2. User presses back and returns to original screen
|
|
167
|
+
mockNavigator.currentRoute = "river/river-123";
|
|
168
|
+
mockIsActive = true;
|
|
169
|
+
rerender({});
|
|
170
|
+
|
|
171
|
+
expect(refreshCoordinator.triggerRefresh).toHaveBeenCalledTimes(1);
|
|
172
|
+
|
|
173
|
+
expect(refreshCoordinator.triggerRefresh).toHaveBeenCalledWith(
|
|
174
|
+
[refreshableComponent, stringBooleanComponent],
|
|
175
|
+
riverId
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
expect(zappPipesModule.markPipesDataStale).toHaveBeenCalledWith(
|
|
179
|
+
"https://feed.example.com/data1",
|
|
180
|
+
{ riverId }
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
expect(zappPipesModule.markPipesDataStale).toHaveBeenCalledWith(
|
|
184
|
+
"https://feed.example.com/data2",
|
|
185
|
+
{ riverId }
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
expect(mockDispatch).toHaveBeenCalledTimes(2);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it("does not trigger duplicate refreshes on subsequent re-renders on the same screen", () => {
|
|
192
|
+
const { rerender } = renderHook(() =>
|
|
193
|
+
useMarkPipesDataStale(riverId, allComponents)
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
// Navigate away
|
|
197
|
+
mockNavigator.currentRoute = "river/deeper-screen";
|
|
198
|
+
mockIsActive = false;
|
|
199
|
+
rerender({});
|
|
200
|
+
|
|
201
|
+
// Return
|
|
202
|
+
mockNavigator.currentRoute = "river/river-123";
|
|
203
|
+
mockIsActive = true;
|
|
204
|
+
rerender({});
|
|
205
|
+
|
|
206
|
+
expect(refreshCoordinator.triggerRefresh).toHaveBeenCalledTimes(1);
|
|
207
|
+
|
|
208
|
+
// Subsequent re-render without navigation
|
|
209
|
+
rerender({});
|
|
210
|
+
rerender({});
|
|
211
|
+
|
|
212
|
+
expect(refreshCoordinator.triggerRefresh).toHaveBeenCalledTimes(1);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it("triggers refresh again if user navigates away a second time and returns", () => {
|
|
216
|
+
const { rerender } = renderHook(() =>
|
|
217
|
+
useMarkPipesDataStale(riverId, allComponents)
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
// First trip: navigate away and return
|
|
221
|
+
mockNavigator.currentRoute = "river/screen-2";
|
|
222
|
+
mockIsActive = false;
|
|
223
|
+
rerender({});
|
|
224
|
+
|
|
225
|
+
mockNavigator.currentRoute = "river/river-123";
|
|
226
|
+
mockIsActive = true;
|
|
227
|
+
rerender({});
|
|
228
|
+
|
|
229
|
+
expect(refreshCoordinator.triggerRefresh).toHaveBeenCalledTimes(1);
|
|
230
|
+
|
|
231
|
+
// Second trip: navigate away to another screen and return
|
|
232
|
+
mockNavigator.currentRoute = "river/screen-3";
|
|
233
|
+
mockIsActive = false;
|
|
234
|
+
rerender({});
|
|
235
|
+
|
|
236
|
+
mockNavigator.currentRoute = "river/river-123";
|
|
237
|
+
mockIsActive = true;
|
|
238
|
+
rerender({});
|
|
239
|
+
|
|
240
|
+
expect(refreshCoordinator.triggerRefresh).toHaveBeenCalledTimes(2);
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
});
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { RequestBuilder } from "@applicaster/zapp-pipes-v2-client";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { useInflatedUrl } from "@applicaster/zapp-react-native-utils/reactHooks/feed/useInflatedUrl";
|
|
4
|
-
import {
|
|
4
|
+
import { subsystemLogger } from "../../logger";
|
|
5
5
|
|
|
6
|
-
export const logger =
|
|
6
|
+
export const logger = subsystemLogger(
|
|
7
|
+
"core/react_hooks/pipes_url",
|
|
8
|
+
"BuildPipesUrl"
|
|
9
|
+
);
|
|
7
10
|
|
|
8
11
|
type PipesBuildRequestObject = {
|
|
9
12
|
url: string;
|
|
@@ -2,12 +2,12 @@ import React, { useEffect } from "react";
|
|
|
2
2
|
|
|
3
3
|
import { useZappPipesFeed } from "@applicaster/zapp-react-native-redux";
|
|
4
4
|
|
|
5
|
-
import { reactHooksLogger } from "../logger";
|
|
6
5
|
import { shouldDispatchData, useIsInitialRender } from "../utils";
|
|
7
6
|
import { useInflatedUrl } from "./useInflatedUrl";
|
|
8
7
|
import { useLoadPipesDataDispatch } from "./useLoadPipesDataDispatch";
|
|
8
|
+
import { subsystemLogger } from "../../logger";
|
|
9
9
|
|
|
10
|
-
const logger =
|
|
10
|
+
const logger = subsystemLogger("core/react_hooks/feed_loader", "UseFeedLoader");
|
|
11
11
|
|
|
12
12
|
type Props = {
|
|
13
13
|
feedUrl: string | null;
|
|
@@ -15,6 +15,7 @@ type Props = {
|
|
|
15
15
|
pipesOptions?: {
|
|
16
16
|
clearCache?: boolean;
|
|
17
17
|
loadLocalFavourites?: boolean;
|
|
18
|
+
loadLocalFavorites?: boolean;
|
|
18
19
|
silentRefresh?: boolean;
|
|
19
20
|
method?: "get" | "post";
|
|
20
21
|
bodyParams?: Record<string, unknown>;
|
|
@@ -45,11 +46,36 @@ export const useFeedLoader = ({
|
|
|
45
46
|
|
|
46
47
|
const loadPipesDataDispatcher = useLoadPipesDataDispatch();
|
|
47
48
|
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (
|
|
51
|
+
currentFeed?.stale &&
|
|
52
|
+
!currentFeed.refreshing &&
|
|
53
|
+
(!currentFeed.error || isInitialRender) &&
|
|
54
|
+
!pipesOptions.skipLoading
|
|
55
|
+
) {
|
|
56
|
+
loadPipesDataDispatcher(
|
|
57
|
+
callableFeedUrl,
|
|
58
|
+
{ ...pipesOptions, clearCache: false, silentRefresh: true },
|
|
59
|
+
{ withResolvers: true }
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
}, [
|
|
63
|
+
callableFeedUrl,
|
|
64
|
+
currentFeed?.stale,
|
|
65
|
+
currentFeed?.invalidationVersion,
|
|
66
|
+
currentFeed?.refreshing,
|
|
67
|
+
currentFeed?.error,
|
|
68
|
+
pipesOptions,
|
|
69
|
+
loadPipesDataDispatcher,
|
|
70
|
+
isInitialRender,
|
|
71
|
+
]);
|
|
72
|
+
|
|
48
73
|
const reloadData = React.useCallback<ReloadDataFunction>(
|
|
49
74
|
(silentRefresh = true, callback) => {
|
|
50
75
|
loadPipesDataDispatcher(
|
|
51
76
|
callableFeedUrl,
|
|
52
77
|
{
|
|
78
|
+
...pipesOptions,
|
|
53
79
|
clearCache: true,
|
|
54
80
|
silentRefresh,
|
|
55
81
|
callback,
|
|
@@ -59,7 +85,7 @@ export const useFeedLoader = ({
|
|
|
59
85
|
}
|
|
60
86
|
);
|
|
61
87
|
},
|
|
62
|
-
[callableFeedUrl]
|
|
88
|
+
[callableFeedUrl, pipesOptions, loadPipesDataDispatcher]
|
|
63
89
|
);
|
|
64
90
|
|
|
65
91
|
const loadNext: FeedLoaderResponse["loadNext"] = React.useCallback(() => {
|
|
@@ -81,6 +107,7 @@ export const useFeedLoader = ({
|
|
|
81
107
|
|
|
82
108
|
useEffect(() => {
|
|
83
109
|
if (
|
|
110
|
+
!currentFeed?.stale &&
|
|
84
111
|
shouldDispatchData(callableFeedUrl, currentFeed, pipesOptions.clearCache)
|
|
85
112
|
) {
|
|
86
113
|
if (callableFeedUrl && !pipesOptions.skipLoading) {
|
|
@@ -19,14 +19,6 @@ export const useLoadPipesDataDispatch = () => {
|
|
|
19
19
|
(screenData as LegacyNavigationScreenData)?.targetScreen?.id ??
|
|
20
20
|
screenData?.id;
|
|
21
21
|
|
|
22
|
-
const onLoadCB = (options) => (data, _err) => {
|
|
23
|
-
options?.callback?.();
|
|
24
|
-
|
|
25
|
-
if (data) {
|
|
26
|
-
applyScreenRouteDefaults(data, screenStateStore, pathname);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
|
|
30
22
|
return React.useCallback(
|
|
31
23
|
(
|
|
32
24
|
url: string,
|
|
@@ -36,6 +28,9 @@ export const useLoadPipesDataDispatch = () => {
|
|
|
36
28
|
clearCache?: boolean;
|
|
37
29
|
silentRefresh?: boolean;
|
|
38
30
|
parentFeed?: string;
|
|
31
|
+
method?: "get" | "post";
|
|
32
|
+
bodyParams?: Record<string, unknown>;
|
|
33
|
+
loadLocalFavorites?: boolean;
|
|
39
34
|
} = {},
|
|
40
35
|
{
|
|
41
36
|
withResolvers = false,
|
|
@@ -46,18 +41,24 @@ export const useLoadPipesDataDispatch = () => {
|
|
|
46
41
|
} = {}
|
|
47
42
|
) => {
|
|
48
43
|
if (url) {
|
|
49
|
-
dispatch(
|
|
44
|
+
return dispatch(
|
|
50
45
|
ZappPipes.loadPipesData(url, {
|
|
51
46
|
riverId,
|
|
52
47
|
resolvers: withResolvers ? resolvers : undefined,
|
|
53
48
|
...options,
|
|
54
49
|
callback: withScreenRouteMapping
|
|
55
|
-
?
|
|
50
|
+
? (data, error) => {
|
|
51
|
+
options.callback?.(data, error);
|
|
52
|
+
|
|
53
|
+
if (data) {
|
|
54
|
+
applyScreenRouteDefaults(data, screenStateStore, pathname);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
56
57
|
: options?.callback,
|
|
57
58
|
})
|
|
58
59
|
);
|
|
59
60
|
}
|
|
60
61
|
},
|
|
61
|
-
[]
|
|
62
|
+
[dispatch, riverId, resolvers, screenStateStore, pathname]
|
|
62
63
|
);
|
|
63
64
|
};
|
|
@@ -3,46 +3,91 @@ import React from "react";
|
|
|
3
3
|
import { getDatasourceUrl } from "@applicaster/zapp-react-native-ui-components/Decorators/RiverFeedLoader/utils/getDatasourceUrl";
|
|
4
4
|
import { usePipesContexts } from "@applicaster/zapp-react-native-ui-components/Decorators/RiverFeedLoader/utils/usePipesContexts";
|
|
5
5
|
import { markPipesDataStale } from "@applicaster/zapp-react-native-redux/ZappPipes";
|
|
6
|
-
|
|
7
|
-
import { useRoute } from "../navigation";
|
|
8
6
|
import { useAppDispatch } from "@applicaster/zapp-react-native-redux";
|
|
7
|
+
import { isTrue } from "../../booleanUtils";
|
|
8
|
+
import { refreshCoordinator } from "../../refreshUtils/RefreshCoordinator";
|
|
9
|
+
import { useNavigation, useRoute } from "../navigation";
|
|
10
|
+
import { usePrevious } from "../utils";
|
|
11
|
+
|
|
12
|
+
const getRefreshableComponents = (components: ZappUIComponent[]) =>
|
|
13
|
+
components?.filter(
|
|
14
|
+
(c) => isTrue(c?.rules?.clear_cache_on_reload) && c?.data?.source
|
|
15
|
+
) || [];
|
|
9
16
|
|
|
10
17
|
/**
|
|
11
18
|
* Mark a river's `clear_cache_on_reload` feeds as stale when the screen is
|
|
12
19
|
* unmounted. The cached data is kept (so a screen sharing the same feed does
|
|
13
20
|
* not lose it mid-mount) and revalidated on next access.
|
|
21
|
+
*
|
|
22
|
+
* Also triggers refresh for mounted components and marks feeds stale when
|
|
23
|
+
* returning back to this screen from a deeper route in the Transitioner
|
|
24
|
+
* (where the screen was kept mounted in the background).
|
|
25
|
+
*
|
|
14
26
|
* @param {string} riverId screen id
|
|
15
27
|
* @param {Array} riverComponents list of UI components
|
|
16
28
|
*/
|
|
17
|
-
export const useMarkPipesDataStale = (
|
|
29
|
+
export const useMarkPipesDataStale = (
|
|
30
|
+
riverId: string,
|
|
31
|
+
riverComponents: ZappUIComponent[]
|
|
32
|
+
) => {
|
|
18
33
|
const dispatch = useAppDispatch();
|
|
19
34
|
const { screenData, pathname } = useRoute();
|
|
20
35
|
const pipesContexts = usePipesContexts(riverId, pathname);
|
|
36
|
+
const { currentRoute } = useNavigation();
|
|
37
|
+
const prevRoute = usePrevious(currentRoute);
|
|
21
38
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
component
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
if (url) {
|
|
40
|
-
dispatch(markPipesDataStale(url, { riverId }));
|
|
41
|
-
}
|
|
39
|
+
const isBackToScreen = Boolean(
|
|
40
|
+
prevRoute && prevRoute !== currentRoute && currentRoute === pathname
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const invalidateComponents = React.useCallback(
|
|
44
|
+
(components: ZappUIComponent[]) => {
|
|
45
|
+
components.forEach((component) => {
|
|
46
|
+
const url = getDatasourceUrl(
|
|
47
|
+
{ screenData, ...pipesContexts },
|
|
48
|
+
component
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
if (url) {
|
|
52
|
+
dispatch(markPipesDataStale(url, { riverId }));
|
|
42
53
|
}
|
|
43
54
|
});
|
|
55
|
+
},
|
|
56
|
+
[dispatch, screenData, pipesContexts, riverId]
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
// Stale invalidation on unmount (existing behavior)
|
|
60
|
+
/* eslint-disable @wogns3623/better-exhaustive-deps/exhaustive-deps */
|
|
61
|
+
React.useEffect(() => {
|
|
62
|
+
return () => {
|
|
63
|
+
if (pathname?.includes("videoModal")) return;
|
|
64
|
+
|
|
65
|
+
invalidateComponents(getRefreshableComponents(riverComponents));
|
|
44
66
|
};
|
|
45
67
|
}, []);
|
|
68
|
+
/* eslint-enable @wogns3623/better-exhaustive-deps/exhaustive-deps */
|
|
69
|
+
|
|
70
|
+
// Reload when returning back to this screen from another screen
|
|
71
|
+
React.useEffect(() => {
|
|
72
|
+
if (!isBackToScreen || pathname?.includes("videoModal")) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const refreshable = getRefreshableComponents(riverComponents);
|
|
77
|
+
|
|
78
|
+
if (refreshable.length === 0) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
invalidateComponents(refreshable);
|
|
83
|
+
refreshCoordinator.triggerRefresh(refreshable, riverId);
|
|
84
|
+
}, [
|
|
85
|
+
isBackToScreen,
|
|
86
|
+
pathname,
|
|
87
|
+
riverComponents,
|
|
88
|
+
riverId,
|
|
89
|
+
invalidateComponents,
|
|
90
|
+
]);
|
|
46
91
|
};
|
|
47
92
|
|
|
48
93
|
/**
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { reactHooksLogger } from "../../logger";
|
|
2
1
|
import { useZappHookModalStore } from "@applicaster/zapp-react-native-ui-components/Contexts/ZappHookModalContext";
|
|
2
|
+
import { subsystemLogger } from "../../../logger";
|
|
3
3
|
|
|
4
|
-
const logger =
|
|
4
|
+
const logger = subsystemLogger(
|
|
5
|
+
"core/react_hooks/hook_modal",
|
|
6
|
+
"UseHookModalScreenData"
|
|
7
|
+
);
|
|
5
8
|
|
|
6
9
|
type VariousScreenData = LegacyNavigationScreenData | ZappRiver | ZappEntry;
|
|
7
10
|
|
package/reactHooks/logger.ts
CHANGED
|
@@ -9,8 +9,8 @@ import { createLogger } from "../../logger";
|
|
|
9
9
|
import { useRivers } from "../state";
|
|
10
10
|
|
|
11
11
|
const { log_error, log_info } = createLogger({
|
|
12
|
-
subsystem: "
|
|
13
|
-
category: "
|
|
12
|
+
subsystem: "core/react_hooks/present_screen",
|
|
13
|
+
category: "UsePresentScreen",
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
export interface PresentScreenArgs {
|
|
@@ -44,8 +44,11 @@ interface Dependencies {
|
|
|
44
44
|
contentTypes: ZappContentTypes;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
const failure = (
|
|
48
|
-
|
|
47
|
+
const failure = (
|
|
48
|
+
error: string,
|
|
49
|
+
data?: Record<string, unknown>
|
|
50
|
+
): Promise<PresentScreenResult> => {
|
|
51
|
+
log_error(`presentScreen: ${error}`, data);
|
|
49
52
|
|
|
50
53
|
return Promise.resolve({ success: false, cancelled: false, error });
|
|
51
54
|
};
|
|
@@ -77,13 +80,23 @@ export const presentScreen = ({
|
|
|
77
80
|
const screenId = contentTypes?.[typeMapping]?.screen_id;
|
|
78
81
|
|
|
79
82
|
if (!screenId) {
|
|
80
|
-
return failure(`can not resolve screen type mapping: ${typeMapping}
|
|
83
|
+
return failure(`can not resolve screen type mapping: ${typeMapping}`, {
|
|
84
|
+
// For X-Ray diagnostics: keep when the message is reworded.
|
|
85
|
+
diagnostic: {
|
|
86
|
+
code: "action-type-mapping",
|
|
87
|
+
case: contentTypes?.[typeMapping] ? "no_screen" : "missing",
|
|
88
|
+
},
|
|
89
|
+
type_mapping: typeMapping,
|
|
90
|
+
});
|
|
81
91
|
}
|
|
82
92
|
|
|
83
93
|
const river = rivers?.[screenId];
|
|
84
94
|
|
|
85
95
|
if (!river) {
|
|
86
|
-
return failure(`can not resolve river for screen id: ${screenId}
|
|
96
|
+
return failure(`can not resolve river for screen id: ${screenId}`, {
|
|
97
|
+
diagnostic: { code: "action-type-mapping", case: "screen_deleted" },
|
|
98
|
+
type_mapping: typeMapping,
|
|
99
|
+
});
|
|
87
100
|
}
|
|
88
101
|
|
|
89
102
|
return new Promise<PresentScreenResult>((resolve) => {
|
|
@@ -13,8 +13,8 @@ import {
|
|
|
13
13
|
|
|
14
14
|
export const { log_warning, log_debug, log_info, log_error, log_verbose } =
|
|
15
15
|
createLogger({
|
|
16
|
-
category: "
|
|
17
|
-
subsystem: "
|
|
16
|
+
category: "TVSeekController",
|
|
17
|
+
subsystem: "player/seek",
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
export enum SEEK_STRATEGY {
|
|
@@ -39,6 +39,16 @@ export function useComponentResolver(
|
|
|
39
39
|
if (!component) {
|
|
40
40
|
coreLogger.warn({
|
|
41
41
|
message: `useComponentResolver: Component of type ${componentType} not found`,
|
|
42
|
+
data: {
|
|
43
|
+
// For X-Ray diagnostics: keep when the message is reworded. Not for a plugin that is in
|
|
44
|
+
// the build and only has no component to give.
|
|
45
|
+
...(!plugins?.some(
|
|
46
|
+
(plugin) => plugin?.identifier === componentType
|
|
47
|
+
) && {
|
|
48
|
+
diagnostic: { code: "component-plugin-missing" },
|
|
49
|
+
}),
|
|
50
|
+
component: { component_type: componentType },
|
|
51
|
+
},
|
|
42
52
|
});
|
|
43
53
|
}
|
|
44
54
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { utilsLogger } from "../../logger";
|
|
2
1
|
import React from "react";
|
|
3
2
|
import { useRivers } from "../state";
|
|
3
|
+
import { subsystemLogger } from "../../logger";
|
|
4
4
|
|
|
5
|
-
const logger =
|
|
5
|
+
const logger = subsystemLogger("core/react_hooks/screen_data", "UseScreenData");
|
|
6
6
|
|
|
7
7
|
export const useScreenData = (screenId: string): ZappRiver => {
|
|
8
8
|
const rivers = useRivers();
|