@stream-io/feeds-client 0.3.37 → 0.3.38

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.
@@ -3985,7 +3985,7 @@ const getRateLimitFromResponseHeader = (response_headers) => {
3985
3985
  };
3986
3986
  return result;
3987
3987
  };
3988
- const version = "0.3.37";
3988
+ const version = "0.3.38";
3989
3989
  const axios = axiosImport.default ?? axiosImport;
3990
3990
  class ApiClient {
3991
3991
  constructor(apiKey, tokenManager, connectionIdManager, options) {
@@ -7373,10 +7373,22 @@ class FeedsClient extends FeedsApi {
7373
7373
  }
7374
7374
  };
7375
7375
  this.pollFromState = (id) => this.polls_by_id.get(id);
7376
+ this.connectAnonymous = () => {
7377
+ this.checkIfUserIsConnected();
7378
+ this.connectionIdManager.resolveConnectionidPromise();
7379
+ this.tokenManager.setTokenOrProvider(void 0);
7380
+ this.setGetBatchOwnFieldsThrottlingInterval(
7381
+ this.query_batch_own_fields_throttling_interval
7382
+ );
7383
+ this.state.partialNext({
7384
+ connected_user: void 0,
7385
+ is_anonymous: true,
7386
+ is_ws_connection_healthy: false
7387
+ });
7388
+ return Promise.resolve();
7389
+ };
7376
7390
  this.connectUser = async (user, tokenProvider) => {
7377
- if (this.state.getLatestValue().connected_user !== void 0 || this.wsConnection) {
7378
- throw new Error(`Can't connect a new user, call "disconnectUser" first`);
7379
- }
7391
+ this.checkIfUserIsConnected();
7380
7392
  this.tokenManager.setTokenOrProvider(tokenProvider);
7381
7393
  this.setGetBatchOwnFieldsThrottlingInterval(
7382
7394
  this.query_batch_own_fields_throttling_interval
@@ -7549,10 +7561,7 @@ class FeedsClient extends FeedsApi {
7549
7561
  this.polls_by_id.clear();
7550
7562
  this.activeActivities = [];
7551
7563
  this.activeFeeds = {};
7552
- this.state.partialNext({
7553
- connected_user: void 0,
7554
- is_ws_connection_healthy: false
7555
- });
7564
+ this.state.partialNext(this.initialState);
7556
7565
  this.cancelGetBatchOwnFieldsTimer();
7557
7566
  clearQueuedFeeds();
7558
7567
  };
@@ -7644,10 +7653,7 @@ class FeedsClient extends FeedsApi {
7644
7653
  }
7645
7654
  return feed;
7646
7655
  };
7647
- this.state = new stateStore.StateStore({
7648
- connected_user: void 0,
7649
- is_ws_connection_healthy: false
7650
- });
7656
+ this.state = new stateStore.StateStore(this.initialState);
7651
7657
  this.moderation = new ModerationClient(apiClient);
7652
7658
  this.tokenManager = tokenManager;
7653
7659
  this.connectionIdManager = connectionIdManager;
@@ -7966,6 +7972,18 @@ class FeedsClient extends FeedsApi {
7966
7972
  feeds.forEach((f) => handleFollowDeleted.bind(f)({ follow }, false));
7967
7973
  });
7968
7974
  }
7975
+ get initialState() {
7976
+ return {
7977
+ connected_user: void 0,
7978
+ is_anonymous: false,
7979
+ is_ws_connection_healthy: false
7980
+ };
7981
+ }
7982
+ checkIfUserIsConnected() {
7983
+ if (this.state.getLatestValue().connected_user !== void 0 || this.wsConnection || this.state.getLatestValue().is_anonymous) {
7984
+ throw new Error(`Can't connect a new user, call "disconnectUser" first`);
7985
+ }
7986
+ }
7969
7987
  }
7970
7988
  exports.ActivityWithStateUpdates = ActivityWithStateUpdates;
7971
7989
  exports.Constants = Constants;
@@ -7988,4 +8006,4 @@ exports.replaceUniqueArrayMerge = replaceUniqueArrayMerge;
7988
8006
  exports.shouldUpdateState = shouldUpdateState;
7989
8007
  exports.uniqueArrayMerge = uniqueArrayMerge;
7990
8008
  exports.updateEntityInArray = updateEntityInArray;
7991
- //# sourceMappingURL=feeds-client-DEV6_pkH.js.map
8009
+ //# sourceMappingURL=feeds-client-eEru7Ibh.js.map