File tree 1 file changed +16
-2
lines changed
1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -17,10 +17,17 @@ Onyx.connect({
17
17
callback : val => credentials = val ,
18
18
} ) ;
19
19
20
+ let isOnyxReady = false ;
20
21
let authToken ;
21
22
Onyx . connect ( {
22
23
key : ONYXKEYS . SESSION ,
23
- callback : val => authToken = val ? val . authToken : null ,
24
+ callback : val => setTimeout ( ( ) => { // TODO: remove setTimeout
25
+ // callback: (val) => {
26
+ authToken = val ? val . authToken : null ;
27
+ isOnyxReady = true ;
28
+
29
+ // },
30
+ } , 1000 ) ,
24
31
} ) ;
25
32
26
33
/**
@@ -80,7 +87,14 @@ function addDefaultValuesToParameters(command, parameters) {
80
87
}
81
88
82
89
// Tie into the network layer to add auth token to the parameters of all requests
83
- Network . registerParameterEnhancer ( addDefaultValuesToParameters ) ;
90
+ Network . registerParameterEnhancer ( ( command , parameters ) => {
91
+ if ( isOnyxReady ) {
92
+ return addDefaultValuesToParameters ( command , parameters ) ;
93
+ }
94
+
95
+ // TODO: log this to the server
96
+ console . debug ( `Onyx is not ready in Network.registerParameterEnhancer with command '${ command } '` ) ;
97
+ } ) ;
84
98
85
99
/**
86
100
* @throws {Error } If the "parameters" object has a null or undefined value for any of the given parameterNames
You can’t perform that action at this time.
0 commit comments