@applicaster/zapp-react-native-utils 14.0.0-rc.1 → 14.0.0-rc.2
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.
|
@@ -319,68 +319,3 @@ describe("getRiverFromRoute", () => {
|
|
|
319
319
|
expect(getRiverFromRoute({ route, rivers })).toEqual(river);
|
|
320
320
|
});
|
|
321
321
|
});
|
|
322
|
-
|
|
323
|
-
describe("isPreviousRouteHook", () => {
|
|
324
|
-
const { isPreviousRouteHook } = navigationUtils;
|
|
325
|
-
|
|
326
|
-
const history = {
|
|
327
|
-
entries: [],
|
|
328
|
-
};
|
|
329
|
-
|
|
330
|
-
it("returns false if it's a root route", () => {
|
|
331
|
-
history.entries.push({ pathname: "/river/root" });
|
|
332
|
-
const currentResult = isPreviousRouteHook(history.entries);
|
|
333
|
-
expect(currentResult).toBe(false);
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
it("returns false if previous root is not a hook", () => {
|
|
337
|
-
history.entries.push({ pathname: "/almostHooks/secondLevel" });
|
|
338
|
-
const currentResult = isPreviousRouteHook(history.entries);
|
|
339
|
-
expect(currentResult).toBe(false);
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
it("returns true if previous root is a hook", () => {
|
|
343
|
-
history.entries.push({ pathname: "/hooks/ThirdLevel" });
|
|
344
|
-
history.entries.push({ pathname: "/almostHooks/forthLevel" });
|
|
345
|
-
const currentResult = isPreviousRouteHook(history.entries);
|
|
346
|
-
expect(currentResult).toBe(true);
|
|
347
|
-
});
|
|
348
|
-
});
|
|
349
|
-
|
|
350
|
-
describe("getPreviousHooksCount", () => {
|
|
351
|
-
const { getPreviousHooksCount } = navigationUtils;
|
|
352
|
-
|
|
353
|
-
const history = {
|
|
354
|
-
entries: [],
|
|
355
|
-
};
|
|
356
|
-
|
|
357
|
-
it("returns 0 if it's a root route", () => {
|
|
358
|
-
history.entries.push({ pathname: "/river/root" });
|
|
359
|
-
const currentResult = getPreviousHooksCount(history);
|
|
360
|
-
expect(currentResult).toBe(0);
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
it("returns 0 if previous root is not a hook", () => {
|
|
364
|
-
history.entries.push({ pathname: "/almostHooks/secondLevel" });
|
|
365
|
-
const currentResult = getPreviousHooksCount(history);
|
|
366
|
-
expect(currentResult).toBe(0);
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
it("returns 1 if previous root is a hook", () => {
|
|
370
|
-
history.entries = [];
|
|
371
|
-
history.entries.push({ pathname: "/hooks/ThirdLevel" });
|
|
372
|
-
history.entries.push({ pathname: "/almostHooks/forthLevel" });
|
|
373
|
-
const currentResult = getPreviousHooksCount(history);
|
|
374
|
-
expect(currentResult).toBe(1);
|
|
375
|
-
});
|
|
376
|
-
|
|
377
|
-
it("returns 2 if 2 previous routes are a hooks", () => {
|
|
378
|
-
history.entries = [];
|
|
379
|
-
history.entries.push({ pathname: "/almostHooks/forthLevel" });
|
|
380
|
-
history.entries.push({ pathname: "/hooks/myHook" });
|
|
381
|
-
history.entries.push({ pathname: "/hooks/myHook" });
|
|
382
|
-
history.entries.push({ pathname: "/almostHooks/forthLevel" });
|
|
383
|
-
const currentResult = getPreviousHooksCount(history);
|
|
384
|
-
expect(currentResult).toBe(2);
|
|
385
|
-
});
|
|
386
|
-
});
|
package/navigationUtils/index.ts
CHANGED
|
@@ -363,37 +363,6 @@ export function getRiverFromRoute({
|
|
|
363
363
|
return screenType && screenId ? { screenType, screenId } : null;
|
|
364
364
|
}
|
|
365
365
|
|
|
366
|
-
/**
|
|
367
|
-
* Function returns true if the previous route (in the react-router history) is a hook plugin
|
|
368
|
-
* @param {*} entries - React-Router History Object
|
|
369
|
-
* @return boolean
|
|
370
|
-
*/
|
|
371
|
-
export function isPreviousRouteHook(entries: [{ pathname: string }]): boolean {
|
|
372
|
-
const previousRoute = entries[entries.length - 2];
|
|
373
|
-
if (!previousRoute) return false;
|
|
374
|
-
|
|
375
|
-
return R.test(/\/hooks\/.*/g, previousRoute.pathname);
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
/**
|
|
379
|
-
* Function returns number of consecutive hooks that are behind the current route
|
|
380
|
-
* @param {*} history - React-Router History Object
|
|
381
|
-
* @return true
|
|
382
|
-
*/
|
|
383
|
-
export function getPreviousHooksCount(history: {
|
|
384
|
-
entries: [{ pathname: string }];
|
|
385
|
-
}): number {
|
|
386
|
-
let hooksCount = 0;
|
|
387
|
-
let entries = R.clone(history.entries);
|
|
388
|
-
|
|
389
|
-
while (isPreviousRouteHook(entries)) {
|
|
390
|
-
hooksCount++;
|
|
391
|
-
entries = R.init(entries);
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
return hooksCount;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
366
|
export const usesVideoModal = (
|
|
398
367
|
item: ZappEntry,
|
|
399
368
|
rivers: Record<string, ZappRiver>,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "14.0.0-rc.
|
|
3
|
+
"version": "14.0.0-rc.2",
|
|
4
4
|
"description": "Applicaster Zapp React Native utilities package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@applicaster/applicaster-types": "14.0.0-rc.
|
|
30
|
+
"@applicaster/applicaster-types": "14.0.0-rc.2",
|
|
31
31
|
"buffer": "^5.2.1",
|
|
32
32
|
"camelize": "^1.0.0",
|
|
33
33
|
"dayjs": "^1.11.10",
|