@stream-io/feeds-client 0.3.18 → 0.3.19

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.
@@ -3932,7 +3932,7 @@ const getRateLimitFromResponseHeader = (response_headers) => {
3932
3932
  };
3933
3933
  return result;
3934
3934
  };
3935
- const version = "0.3.18";
3935
+ const version = "0.3.19";
3936
3936
  class ApiClient {
3937
3937
  constructor(apiKey, tokenManager, connectionIdManager, options) {
3938
3938
  this.apiKey = apiKey;
@@ -4875,10 +4875,10 @@ const updateStateFollowDeleted = (follow, currentState, currentFeedId, connected
4875
4875
  // Update FeedResponse fields, that has the new follower/following count
4876
4876
  ...follow.target_feed
4877
4877
  };
4878
- if (source.created_by.id === connectedUserId && currentState.own_follows !== void 0) {
4879
- newState.own_follows = currentState.own_follows.filter(
4878
+ if (source.created_by.id === connectedUserId) {
4879
+ newState.own_follows = currentState.own_follows ? currentState.own_follows.filter(
4880
4880
  (followItem) => followItem.source_feed.feed !== follow.source_feed.feed
4881
- );
4881
+ ) : [];
4882
4882
  }
4883
4883
  if (currentState.followers !== void 0) {
4884
4884
  newState.followers = currentState.followers.filter(
@@ -5526,6 +5526,7 @@ function addActivitiesToState(newActivities, activities, position) {
5526
5526
  ...activities,
5527
5527
  ...position === "end" ? newActivitiesDeduplicated : []
5528
5528
  ];
5529
+ this.newActivitiesAdded(newActivitiesDeduplicated);
5529
5530
  result = { changed: true, activities: updatedActivities };
5530
5531
  }
5531
5532
  return result;
@@ -6244,6 +6245,9 @@ const deepEqual = (x, y) => {
6244
6245
  return false;
6245
6246
  }
6246
6247
  };
6248
+ function getOrCreateActiveFeed(group, id, data, watch) {
6249
+ return this.getOrCreateActiveFeed(group, id, data, watch);
6250
+ }
6247
6251
  const _Feed = class _Feed extends FeedApi {
6248
6252
  constructor(client, groupId, id, data, watch = false, addNewActivitiesTo = "start", activityAddedEventFilter) {
6249
6253
  super(client, groupId, id);
@@ -6436,7 +6440,7 @@ const _Feed = class _Feed extends FeedApi {
6436
6440
  return nextState;
6437
6441
  });
6438
6442
  }
6439
- this.client.hydratePollCache(response.activities);
6443
+ this.newActivitiesAdded(response.activities);
6440
6444
  return response;
6441
6445
  } finally {
6442
6446
  this.state.partialNext({
@@ -6837,6 +6841,18 @@ const _Feed = class _Feed extends FeedApi {
6837
6841
  }
6838
6842
  this.eventDispatcher.dispatch(event);
6839
6843
  }
6844
+ newActivitiesAdded(activities) {
6845
+ this.client.hydratePollCache(activities);
6846
+ activities.forEach((activity) => {
6847
+ if (activity.current_feed) {
6848
+ getOrCreateActiveFeed.bind(this.client)(
6849
+ activity.current_feed.group_id,
6850
+ activity.current_feed.id,
6851
+ activity.current_feed
6852
+ );
6853
+ }
6854
+ });
6855
+ }
6840
6856
  };
6841
6857
  _Feed.noop = () => {
6842
6858
  };
@@ -7381,8 +7397,7 @@ class FeedsClient extends FeedsApi {
7381
7397
  id,
7382
7398
  void 0,
7383
7399
  void 0,
7384
- options2?.addNewActivitiesTo,
7385
- options2?.activityAddedEventFilter
7400
+ options2
7386
7401
  );
7387
7402
  };
7388
7403
  this.activityWithStateUpdates = (id) => {
@@ -7400,20 +7415,30 @@ class FeedsClient extends FeedsApi {
7400
7415
  };
7401
7416
  this.eventDispatcher.dispatch(networkEvent);
7402
7417
  };
7403
- this.getOrCreateActiveFeed = (group, id, data, watch, addNewActivitiesTo, activityAddedEventFilter) => {
7418
+ this.getOrCreateActiveFeed = (group, id, data, watch, options2) => {
7404
7419
  const fid = `${group}:${id}`;
7420
+ let isCreated = false;
7405
7421
  if (!this.activeFeeds[fid]) {
7422
+ isCreated = true;
7406
7423
  this.activeFeeds[fid] = new Feed(
7407
7424
  this,
7408
7425
  group,
7409
7426
  id,
7410
7427
  data,
7411
7428
  watch,
7412
- addNewActivitiesTo,
7413
- activityAddedEventFilter
7429
+ options2?.addNewActivitiesTo,
7430
+ options2?.activityAddedEventFilter
7414
7431
  );
7415
7432
  }
7416
7433
  const feed = this.activeFeeds[fid];
7434
+ if (!isCreated && options2) {
7435
+ if (options2?.addNewActivitiesTo) {
7436
+ feed.addNewActivitiesTo = options2.addNewActivitiesTo;
7437
+ }
7438
+ if (options2?.activityAddedEventFilter) {
7439
+ feed.activityAddedEventFilter = options2.activityAddedEventFilter;
7440
+ }
7441
+ }
7417
7442
  if (!feed.currentState.watch) {
7418
7443
  if (data) handleFeedUpdated.call(feed, { feed: data });
7419
7444
  if (watch) handleWatchStarted.call(feed);
@@ -7685,6 +7710,17 @@ class FeedsClient extends FeedsApi {
7685
7710
  }
7686
7711
  return response;
7687
7712
  }
7713
+ async getFollowSuggestions(...params) {
7714
+ const response = await super.getFollowSuggestions(...params);
7715
+ response.suggestions.forEach((suggestion) => {
7716
+ this.getOrCreateActiveFeed(
7717
+ suggestion.group_id,
7718
+ suggestion.id,
7719
+ suggestion
7720
+ );
7721
+ });
7722
+ return response;
7723
+ }
7688
7724
  findAllActiveFeedsByActivityId(activityId) {
7689
7725
  return [
7690
7726
  ...Object.values(this.activeFeeds),
@@ -7764,4 +7800,4 @@ exports.replaceUniqueArrayMerge = replaceUniqueArrayMerge;
7764
7800
  exports.shouldUpdateState = shouldUpdateState;
7765
7801
  exports.uniqueArrayMerge = uniqueArrayMerge;
7766
7802
  exports.updateEntityInArray = updateEntityInArray;
7767
- //# sourceMappingURL=feeds-client-Be5gS8Xx.js.map
7803
+ //# sourceMappingURL=feeds-client-BwOGqhU9.js.map