@verdocs/js-sdk 4.2.74 → 4.2.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1285,27 +1285,26 @@ class VerdocsEndpoint {
1285
1285
  if (this.persist) {
1286
1286
  localStorage.setItem(this.sessionStorageKey(), token);
1287
1287
  }
1288
- if (!session.sub || this.sub !== session.sub) {
1289
- // The main purpose for this var is to prevent dupe getCurrentProfile calls and the trigger for the dupe
1290
- // is usually two components calling loadSession() at the same time to ensure we've done all we could
1291
- // to load it. We expose it in case it's useful, but have to set it here instead of in the async callbacks
1292
- // even though their might be a brief window of time where it's set but something might go wrong (profile
1293
- // doesn't load) because we need it to serve that original purpose more.
1294
- window?.console?.debug('[JS_SDK] userId changed, loading current profile...', this.endpointId, this.sub, session.sub);
1295
- this.sub = session.sub;
1296
- getCurrentProfile(this)
1297
- .then((r) => {
1298
- window?.console?.debug('[JS_SDK] Loaded profile', this.endpointId, r);
1299
- this.profile = r || null;
1300
- this.notifySessionListeners();
1301
- })
1302
- .catch((e) => {
1303
- this.profile = null;
1304
- this.sub = null;
1305
- window?.console?.warn('Unable to load profile', e);
1306
- this.notifySessionListeners();
1307
- });
1308
- }
1288
+ // NOTE: We don't attempt to de-dupe session/network operations because there are cases where we
1289
+ // operate within an IFRAME and multiple siblings need to operate on the same session. This happens
1290
+ // a lot in Storybook but may also happen in other environments as well. Rather than try to coordinate
1291
+ // something weird that might break (e.g. in a mobile app), we just allow the dupe calls. We generate
1292
+ // a unique ID for each endpoint just to help with debugging. It should not be taken as a bug if more
1293
+ // than one endpoint ID is seen within the app's logs.
1294
+ window?.console?.debug('[JS_SDK] Loading current profile...', this.endpointId, this.sub, session.sub);
1295
+ this.sub = session.sub;
1296
+ getCurrentProfile(this)
1297
+ .then((r) => {
1298
+ window?.console?.debug('[JS_SDK] Loaded profile', this.endpointId, r);
1299
+ this.profile = r || null;
1300
+ this.notifySessionListeners();
1301
+ })
1302
+ .catch((e) => {
1303
+ this.profile = null;
1304
+ this.sub = null;
1305
+ window?.console?.warn('Unable to load profile', e);
1306
+ this.notifySessionListeners();
1307
+ });
1309
1308
  return this;
1310
1309
  }
1311
1310
  /**