@@ -51,35 +51,27 @@ export function omniflow<ActivityName extends string>({
51
51
return activityOptions ?. [ environment ] ;
52
52
} ;
53
53
54
- function getOmniInitialParams ( activityName : ActivityName ) {
55
- function impl ( activityName : ActivityName ) :
56
- | {
57
- childName : ActivityName [ ] ;
58
- childParams : ActivityBaseParams [ ] ;
59
- }
60
- | undefined {
61
- const envOptions = getEnvOptions ( activityName ) ;
62
- if ( envOptions ?. subview . initialActivity ) {
63
- const { childName, childParams } =
64
- impl ( envOptions . subview . initialActivity . name ) ?? { } ;
65
- return {
66
- childName : [
67
- envOptions . subview . initialActivity . name ,
68
- ...( childName ?? [ ] ) ,
69
- ] ,
70
- childParams : [
71
- envOptions . subview . initialActivity . params ,
72
- ...( childParams ?? [ ] ) ,
73
- ] ,
74
- } ;
75
- }
54
+ function getOmniInitialParams ( activityName : ActivityName ) :
55
+ | {
56
+ childName : ActivityName [ ] ;
57
+ childParams : ActivityBaseParams [ ] ;
58
+ }
59
+ | undefined {
60
+ const envOptions = getEnvOptions ( activityName ) ;
61
+ if ( envOptions ?. subview . initialActivity ) {
62
+ const { childName, childParams } =
63
+ getOmniInitialParams ( envOptions . subview . initialActivity . name ) ?? { } ;
64
+ return {
65
+ childName : [
66
+ envOptions . subview . initialActivity . name ,
67
+ ...( childName ?? [ ] ) ,
68
+ ] ,
69
+ childParams : [
70
+ envOptions . subview . initialActivity . params ,
71
+ ...( childParams ?? [ ] ) ,
72
+ ] ,
73
+ } ;
76
74
}
77
-
78
- const result = impl ( activityName ) ;
79
- return {
80
- OMNI_childName : JSON . stringify ( result ?. childName ) ,
81
- OMNI_childParams : JSON . stringify ( result ?. childParams ) ,
82
- } ;
83
75
}
84
76
85
77
function getOmniStepParams (
@@ -101,14 +93,18 @@ export function omniflow<ActivityName extends string>({
101
93
const activityName = iterStack [ i ] ;
102
94
const envOptions = getEnvOptions ( activityName ) ;
103
95
if ( envOptions ?. subview . children ?. includes ( newActivityName ) ) {
96
+ const newInitialParams = getOmniInitialParams ( newActivityName ) ;
97
+
104
98
return {
105
99
OMNI_childName : JSON . stringify ( [
106
100
...childNameStack . slice ( 0 , i ) ,
107
101
newActivityName ,
102
+ ...( newInitialParams ?. childName ?? [ ] ) ,
108
103
] ) ,
109
104
OMNI_childParams : JSON . stringify ( [
110
105
...childParamsStack . slice ( 0 , i ) ,
111
106
newActivityParams ,
107
+ ...( newInitialParams ?. childParams ?? [ ] ) ,
112
108
] ) ,
113
109
} ;
114
110
}
@@ -122,11 +118,14 @@ export function omniflow<ActivityName extends string>({
122
118
( e ) => e . name === "Pushed" ,
123
119
) ;
124
120
if ( topActivityEvent ) {
125
- const omniParams = getOmniInitialParams (
121
+ const initialParams = getOmniInitialParams (
126
122
topActivityEvent . activityName as ActivityName ,
127
123
) ;
128
- if ( omniParams ) {
129
- topActivityEvent . activityParams = omniParams ;
124
+ if ( initialParams ) {
125
+ topActivityEvent . activityParams = {
126
+ OMNI_childName : JSON . stringify ( initialParams . childName ) ,
127
+ OMNI_childParams : JSON . stringify ( initialParams . childParams ) ,
128
+ } ;
130
129
}
131
130
}
132
131
return initialEvents ;
@@ -154,7 +153,8 @@ export function omniflow<ActivityName extends string>({
154
153
...actionParams ,
155
154
activityParams : {
156
155
...actionParams . activityParams ,
157
- ...initialParams ,
156
+ OMNI_childName : JSON . stringify ( initialParams . childName ) ,
157
+ OMNI_childParams : JSON . stringify ( initialParams . childParams ) ,
158
158
} ,
159
159
} ) ;
160
160
}
@@ -174,15 +174,16 @@ export function omniflow<ActivityName extends string>({
174
174
}
175
175
}
176
176
177
- const omniParams = getOmniInitialParams (
177
+ const initialParams = getOmniInitialParams (
178
178
actionParams . activityName as ActivityName ,
179
179
) ;
180
- if ( omniParams ) {
180
+ if ( initialParams ) {
181
181
actions . overrideActionParams ( {
182
182
...actionParams ,
183
183
activityParams : {
184
184
...actionParams . activityParams ,
185
- ...omniParams ,
185
+ OMNI_childName : JSON . stringify ( initialParams . childName ) ,
186
+ OMNI_childParams : JSON . stringify ( initialParams . childParams ) ,
186
187
} ,
187
188
} ) ;
188
189
}
0 commit comments