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 @@ -14,10 +14,17 @@ Onyx.connect({
14
14
callback : val => credentials = val ,
15
15
} ) ;
16
16
17
+ let isOnyxReady = false ;
17
18
let authToken ;
18
19
Onyx . connect ( {
19
20
key : ONYXKEYS . SESSION ,
20
- callback : val => authToken = val ? val . authToken : null ,
21
+ callback : val => setTimeout ( ( ) => { // TODO: remove setTimeout
22
+ // callback: (val) => {
23
+ authToken = val ? val . authToken : null ;
24
+ isOnyxReady = true ;
25
+
26
+ // },
27
+ } , 1000 ) ,
21
28
} ) ;
22
29
23
30
/**
@@ -77,7 +84,14 @@ function addDefaultValuesToParameters(command, parameters) {
77
84
}
78
85
79
86
// Tie into the network layer to add auth token to the parameters of all requests
80
- Network . registerParameterEnhancer ( addDefaultValuesToParameters ) ;
87
+ Network . registerParameterEnhancer ( ( command , parameters ) => {
88
+ if ( isOnyxReady ) {
89
+ return addDefaultValuesToParameters ( command , parameters ) ;
90
+ }
91
+
92
+ // TODO: log this to the server
93
+ console . debug ( `Onyx is not ready in Network.registerParameterEnhancer with command '${ command } '` ) ;
94
+ } ) ;
81
95
82
96
/**
83
97
* @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