This repository was archived by the owner on Sep 11, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +23
-11
lines changed Expand file tree Collapse file tree 5 files changed +23
-11
lines changed Original file line number Diff line number Diff line change @@ -146,7 +146,6 @@ src/Roles.js
146
146
src/RoomListSorter.js
147
147
src/RoomNotifs.js
148
148
src/Rooms.js
149
- src/RtsClient.js
150
149
src/ScalarAuthClient.js
151
150
src/ScalarMessaging.js
152
151
src/SdkConfig.js
Original file line number Diff line number Diff line change @@ -265,7 +265,11 @@ function _handleRestoreFailure(e) {
265
265
266
266
let rtsClient = null ;
267
267
export function initRtsClient ( url ) {
268
- rtsClient = new RtsClient ( url ) ;
268
+ if ( url ) {
269
+ rtsClient = new RtsClient ( url ) ;
270
+ } else {
271
+ rtsClient = null ;
272
+ }
269
273
}
270
274
271
275
/**
Original file line number Diff line number Diff line change 1
1
import 'whatwg-fetch' ;
2
2
3
+ let fetchFunction = fetch ;
4
+
3
5
function checkStatus ( response ) {
4
6
if ( ! response . ok ) {
5
7
return response . text ( ) . then ( ( text ) => {
@@ -31,7 +33,7 @@ const request = (url, opts) => {
31
33
opts . body = JSON . stringify ( opts . body ) ;
32
34
opts . headers [ 'Content-Type' ] = 'application/json' ;
33
35
}
34
- return fetch ( url , opts )
36
+ return fetchFunction ( url , opts )
35
37
. then ( checkStatus )
36
38
. then ( parseJson ) ;
37
39
} ;
@@ -64,7 +66,7 @@ export default class RtsClient {
64
66
client_secret : clientSecret ,
65
67
} ,
66
68
method : 'POST' ,
67
- }
69
+ } ,
68
70
) ;
69
71
}
70
72
@@ -74,7 +76,7 @@ export default class RtsClient {
74
76
qs : {
75
77
team_token : teamToken ,
76
78
} ,
77
- }
79
+ } ,
78
80
) ;
79
81
}
80
82
@@ -91,7 +93,12 @@ export default class RtsClient {
91
93
qs : {
92
94
user_id : userId ,
93
95
} ,
94
- }
96
+ } ,
95
97
) ;
96
98
}
99
+
100
+ // allow fetch to be replaced, for testing.
101
+ static setFetch ( fn ) {
102
+ fetchFunction = fn ;
103
+ }
97
104
}
Original file line number Diff line number Diff line change @@ -263,11 +263,8 @@ module.exports = React.createClass({
263
263
window . addEventListener ( 'resize' , this . handleResize ) ;
264
264
this . handleResize ( ) ;
265
265
266
- if ( this . props . config . teamServerConfig &&
267
- this . props . config . teamServerConfig . teamServerURL
268
- ) {
269
- Lifecycle . initRtsClient ( this . props . config . teamServerConfig . teamServerURL ) ;
270
- }
266
+ const teamServerConfig = this . props . config . teamServerConfig || { } ;
267
+ Lifecycle . initRtsClient ( teamServerConfig . teamServerURL ) ;
271
268
272
269
// if the user has followed a login or register link, don't reanimate
273
270
// the old creds, but rather go straight to the relevant page
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ limitations under the License.
15
15
*/
16
16
17
17
import Skinner from './Skinner' ;
18
+ import RtsClient from './RtsClient' ;
18
19
19
20
module . exports . loadSkin = function ( skinObject ) {
20
21
Skinner . load ( skinObject ) ;
@@ -27,3 +28,7 @@ module.exports.resetSkin = function() {
27
28
module . exports . getComponent = function ( componentName ) {
28
29
return Skinner . getComponent ( componentName ) ;
29
30
} ;
31
+
32
+ module . exports . setFetch = function ( fetchFunction ) {
33
+ RtsClient . setFetch ( fetchFunction ) ;
34
+ } ;
You can’t perform that action at this time.
0 commit comments