|
5 | 5 | * you may not use this file except in compliance with the License. |
6 | 6 | * You may obtain a copy of the License at |
7 | 7 | * |
8 | | - * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
9 | 9 | * |
10 | 10 | * Unless required by applicable law or agreed to in writing, software |
11 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
@@ -243,19 +243,23 @@ class OptimizelyReactSDKClient implements ReactSDKClient { |
243 | 243 | this.isClientReady = true; |
244 | 244 | }); |
245 | 245 |
|
246 | | - this.dataReadyPromise = Promise.all([this.userPromise, this._client!.onReady()]).then(res => { |
| 246 | + this.dataReadyPromise = Promise.all([this.userPromise, this._client.onReady()]).then( |
| 247 | + ([userResult, clientResult]) => { |
| 248 | + this.isReadyPromiseFulfilled = true; |
247 | 249 |
|
248 | | - // Client and user can become ready synchronously and/or asynchronously. This flag specifically indicates that they became ready asynchronously. |
249 | | - this.isReadyPromiseFulfilled = true; |
250 | | - return { |
251 | | - success: true, |
252 | | - message: 'Successfully resolved datafile and user information.', |
253 | | - }; |
254 | | - }); |
| 250 | + const bothSuccessful = userResult.success && clientResult.success; |
| 251 | + return { |
| 252 | + success: true, // bothSuccessful, |
| 253 | + message: bothSuccessful |
| 254 | + ? 'Successfully resolved user information and client datafile.' |
| 255 | + : 'User information or client datafile was not not ready.', |
| 256 | + }; |
| 257 | + } |
| 258 | + ); |
255 | 259 | } else { |
256 | 260 | logger.warn('Unable to resolve datafile and user information because Optimizely client failed to initialize.'); |
257 | 261 |
|
258 | | - this.dataReadyPromise = new Promise((resolve, reject) => { |
| 262 | + this.dataReadyPromise = new Promise(resolve => { |
259 | 263 | resolve({ |
260 | 264 | success: false, |
261 | 265 | reason: 'NO_CLIENT', |
@@ -308,14 +312,14 @@ class OptimizelyReactSDKClient implements ReactSDKClient { |
308 | 312 |
|
309 | 313 | return Promise.race([this.dataReadyPromise, timeoutPromise]).then(async res => { |
310 | 314 | clearTimeout(timeoutId); |
311 | | - if (res.success) { |
| 315 | + if (res.success && !this.initialConfig.odpOptions?.disabled) { |
312 | 316 | const isSegmentsFetched = await this.fetchQualifiedSegments(); |
313 | 317 | if (!isSegmentsFetched) { |
314 | 318 | return { |
315 | 319 | success: false, |
316 | 320 | reason: 'USER_NOT_READY', |
317 | 321 | message: 'Failed to fetch qualified segments', |
318 | | - } |
| 322 | + }; |
319 | 323 | } |
320 | 324 | } |
321 | 325 | return res; |
|
0 commit comments