@@ -74,7 +74,7 @@ class ReactiveBase extends Component {
7474 ] ,
7575 ( ) => {
7676 this . setStore ( this . props ) ;
77- this . setState ( state => ( {
77+ this . setState ( ( state ) => ( {
7878 key : `${ state . key } -0` ,
7979 } ) ) ;
8080 } ,
@@ -104,30 +104,28 @@ class ReactiveBase extends Component {
104104 }
105105
106106 get headers ( ) {
107- const {
108- enableAppbase, headers, appbaseConfig, mongodb, endpoint,
109- } = this . props ;
107+ const { enableAppbase, headers, appbaseConfig, mongodb, endpoint } = this . props ;
110108 const { enableTelemetry } = appbaseConfig || { } ;
111109 return {
112- ...( enableAppbase
113- && ! mongodb && {
114- 'X-Search-Client' : X_SEARCH_CLIENT ,
115- ...( enableTelemetry === false && { 'X-Enable-Telemetry' : false } ) ,
116- } ) ,
110+ ...( enableAppbase &&
111+ ! mongodb && {
112+ 'X-Search-Client' : X_SEARCH_CLIENT ,
113+ ...( enableTelemetry === false && { 'X-Enable-Telemetry' : false } ) ,
114+ } ) ,
117115 ...headers ,
118- ...( enableAppbase
119- && endpoint
120- && endpoint . headers && {
121- ...endpoint . headers ,
122- } ) ,
116+ ...( enableAppbase &&
117+ endpoint &&
118+ endpoint . headers && {
119+ ...endpoint . headers ,
120+ } ) ,
123121 } ;
124122 }
125123
126124 setStore = ( props ) => {
127125 this . type = props . type ? props . type : '*' ;
128126
129- const credentials
130- = props . url && props . url . trim ( ) !== '' && ! props . credentials ? null : props . credentials ;
127+ const credentials =
128+ props . url && props . url . trim ( ) !== '' && ! props . credentials ? null : props . credentials ;
131129
132130 const appbaseConfig = {
133131 ...props . analyticsConfig , // TODO: remove in 4.0
@@ -157,8 +155,9 @@ class ReactiveBase extends Component {
157155 graphQLUrl : props . graphQLUrl ,
158156 transformResponse : props . transformResponse ,
159157 mongodb : props . mongodb ,
160- ...( props . enableAppbase
161- && props . endpoint instanceof Object && { endpoint : props . endpoint } ) ,
158+ ...( props . enableAppbase &&
159+ props . endpoint instanceof Object && { endpoint : props . endpoint } ) ,
160+ httpRequestTimeout : props . httpRequestTimeout * 1000 ,
162161 } ;
163162
164163 let queryParams = '' ;
@@ -220,12 +219,13 @@ class ReactiveBase extends Component {
220219 if ( this . props . endpoint && this . props . endpoint . url ) {
221220 // Remove parts between '//' and first '/' in the url
222221 analyticsInitConfig . url = this . props . endpoint . url . replace ( / \/ \/ ( .* ?) \/ .* / , '//$1' ) ;
223- const headerCredentials = this . props . endpoint . headers
224- && this . props . endpoint . headers . Authorization ;
225- analyticsInitConfig . credentials = headerCredentials && headerCredentials . replace ( 'Basic ' , '' ) ;
222+ const headerCredentials =
223+ this . props . endpoint . headers && this . props . endpoint . headers . Authorization ;
224+ analyticsInitConfig . credentials =
225+ headerCredentials && headerCredentials . replace ( 'Basic ' , '' ) ;
226226 // Decode the credentials
227- analyticsInitConfig . credentials = analyticsInitConfig . credentials
228- && atob ( analyticsInitConfig . credentials ) ;
227+ analyticsInitConfig . credentials =
228+ analyticsInitConfig . credentials && atob ( analyticsInitConfig . credentials ) ;
229229 }
230230 } catch ( e ) {
231231 console . error ( 'Endpoint not set correctly for analytics' ) ;
@@ -291,6 +291,7 @@ ReactiveBase.defaultProps = {
291291 as : 'div' ,
292292 enableAppbase : false ,
293293 endpoint : null ,
294+ httpRequestTimeout : 30 ,
294295} ;
295296
296297ReactiveBase . propTypes = {
@@ -322,6 +323,7 @@ ReactiveBase.propTypes = {
322323 mongodb : types . mongodb ,
323324 preferences : types . preferences ,
324325 endpoint : types . endpoint ,
326+ httpRequestTimeout : types . number ,
325327} ;
326328
327329export default ReactiveBase ;
0 commit comments