@tinkoff/router 0.5.4 → 0.5.5

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.
@@ -10,8 +10,19 @@ const generateKey = (navigation) => {
10
10
  return `${to.name}_${to.path}`;
11
11
  }
12
12
  };
13
- const generatePreviousNavigateState = (navigation) => {
13
+ const generatePreviousNavigateState = (navigation, currentState) => {
14
14
  const state = {};
15
+ if (navigation.replace) {
16
+ const previousRoute = currentState === null || currentState === void 0 ? void 0 : currentState.navigateState.previousRoute;
17
+ const previousUrl = currentState === null || currentState === void 0 ? void 0 : currentState.navigateState.previousUrl;
18
+ if (previousRoute) {
19
+ state.previousRoute = previousRoute;
20
+ }
21
+ if (previousUrl) {
22
+ state.previousUrl = previousUrl;
23
+ }
24
+ return state;
25
+ }
15
26
  if (navigation.from) {
16
27
  state.previousRoute = navigation.from;
17
28
  }
@@ -22,7 +33,7 @@ const generatePreviousNavigateState = (navigation) => {
22
33
  };
23
34
  const generateState = (navigation, currentState, index = 0) => {
24
35
  const key = generateKey(navigation);
25
- const previousNavigateState = generatePreviousNavigateState(navigation);
36
+ const previousNavigateState = generatePreviousNavigateState(navigation, currentState);
26
37
  let { type } = navigation;
27
38
  if (navigation.replace && currentState) {
28
39
  type = currentState.type === type ? type : 'navigate';
@@ -10,8 +10,19 @@ const generateKey = (navigation) => {
10
10
  return `${to.name}_${to.path}`;
11
11
  }
12
12
  };
13
- const generatePreviousNavigateState = (navigation) => {
13
+ const generatePreviousNavigateState = (navigation, currentState) => {
14
14
  const state = {};
15
+ if (navigation.replace) {
16
+ const previousRoute = currentState === null || currentState === void 0 ? void 0 : currentState.navigateState.previousRoute;
17
+ const previousUrl = currentState === null || currentState === void 0 ? void 0 : currentState.navigateState.previousUrl;
18
+ if (previousRoute) {
19
+ state.previousRoute = previousRoute;
20
+ }
21
+ if (previousUrl) {
22
+ state.previousUrl = previousUrl;
23
+ }
24
+ return state;
25
+ }
15
26
  if (navigation.from) {
16
27
  state.previousRoute = navigation.from;
17
28
  }
@@ -22,7 +33,7 @@ const generatePreviousNavigateState = (navigation) => {
22
33
  };
23
34
  const generateState = (navigation, currentState, index = 0) => {
24
35
  const key = generateKey(navigation);
25
- const previousNavigateState = generatePreviousNavigateState(navigation);
36
+ const previousNavigateState = generatePreviousNavigateState(navigation, currentState);
26
37
  let { type } = navigation;
27
38
  if (navigation.replace && currentState) {
28
39
  type = currentState.type === type ? type : 'navigate';
@@ -14,8 +14,19 @@ const generateKey = (navigation) => {
14
14
  return `${to.name}_${to.path}`;
15
15
  }
16
16
  };
17
- const generatePreviousNavigateState = (navigation) => {
17
+ const generatePreviousNavigateState = (navigation, currentState) => {
18
18
  const state = {};
19
+ if (navigation.replace) {
20
+ const previousRoute = currentState === null || currentState === void 0 ? void 0 : currentState.navigateState.previousRoute;
21
+ const previousUrl = currentState === null || currentState === void 0 ? void 0 : currentState.navigateState.previousUrl;
22
+ if (previousRoute) {
23
+ state.previousRoute = previousRoute;
24
+ }
25
+ if (previousUrl) {
26
+ state.previousUrl = previousUrl;
27
+ }
28
+ return state;
29
+ }
19
30
  if (navigation.from) {
20
31
  state.previousRoute = navigation.from;
21
32
  }
@@ -26,7 +37,7 @@ const generatePreviousNavigateState = (navigation) => {
26
37
  };
27
38
  const generateState = (navigation, currentState, index = 0) => {
28
39
  const key = generateKey(navigation);
29
- const previousNavigateState = generatePreviousNavigateState(navigation);
40
+ const previousNavigateState = generatePreviousNavigateState(navigation, currentState);
30
41
  let { type } = navigation;
31
42
  if (navigation.replace && currentState) {
32
43
  type = currentState.type === type ? type : 'navigate';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinkoff/router",
3
- "version": "0.5.4",
3
+ "version": "0.5.5",
4
4
  "description": "router",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -27,7 +27,7 @@
27
27
  "use-sync-external-store": "^1.2.0"
28
28
  },
29
29
  "peerDependencies": {
30
- "@tramvai/core": "5.1.1",
30
+ "@tramvai/core": "5.1.2",
31
31
  "react": ">=16.14.0",
32
32
  "tslib": "^2.4.0"
33
33
  },