@stream-io/feeds-client 0.3.2 → 0.3.3

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.
@@ -3782,7 +3782,7 @@ const getRateLimitFromResponseHeader = (response_headers) => {
3782
3782
  };
3783
3783
  return result;
3784
3784
  };
3785
- const version = "0.3.2";
3785
+ const version = "0.3.3";
3786
3786
  class ApiClient {
3787
3787
  constructor(apiKey, tokenManager, connectionIdManager, options) {
3788
3788
  this.apiKey = apiKey;
@@ -5379,6 +5379,11 @@ function addActivitiesToState(newActivities, activities, position) {
5379
5379
  return result;
5380
5380
  }
5381
5381
  function handleActivityAdded(event) {
5382
+ if (this.activityAddedEventFilter) {
5383
+ if (!this.activityAddedEventFilter(event)) {
5384
+ return;
5385
+ }
5386
+ }
5382
5387
  const currentActivities = this.currentState.activities;
5383
5388
  const result = addActivitiesToState.bind(this)(
5384
5389
  [event.activity],
@@ -6073,8 +6078,9 @@ function handleActivityFeedback(event) {
6073
6078
  }
6074
6079
  }
6075
6080
  const _Feed = class _Feed extends FeedApi {
6076
- constructor(client, groupId, id, data, watch = false, addNewActivitiesTo = "start") {
6081
+ constructor(client, groupId, id, data, watch = false, addNewActivitiesTo = "start", activityAddedEventFilter) {
6077
6082
  super(client, groupId, id);
6083
+ this.activityAddedEventFilter = activityAddedEventFilter;
6078
6084
  this.indexedActivityIds = /* @__PURE__ */ new Set();
6079
6085
  this.stateUpdateQueue = /* @__PURE__ */ new Set();
6080
6086
  this.eventHandlers = {
@@ -6170,6 +6176,11 @@ const _Feed = class _Feed extends FeedApi {
6170
6176
  hasActivity(activityId) {
6171
6177
  return this.indexedActivityIds.has(activityId);
6172
6178
  }
6179
+ hasPinnedActivity(activityId) {
6180
+ return this.currentState.pinned_activities?.some(
6181
+ (pinnedActivity) => pinnedActivity.activity.id === activityId
6182
+ );
6183
+ }
6173
6184
  async synchronize() {
6174
6185
  const { last_get_or_create_request_config } = this.state.getLatestValue();
6175
6186
  if (last_get_or_create_request_config?.watch) {
@@ -6601,6 +6612,7 @@ const _Feed = class _Feed extends FeedApi {
6601
6612
  following_pagination: {
6602
6613
  limit: 0
6603
6614
  },
6615
+ filter: currentState.last_get_or_create_request_config?.filter,
6604
6616
  next: currentState.next,
6605
6617
  limit: currentState.last_get_or_create_request_config?.limit ?? 20
6606
6618
  });
@@ -7010,7 +7022,8 @@ class FeedsClient extends FeedsApi {
7010
7022
  id,
7011
7023
  void 0,
7012
7024
  void 0,
7013
- options2?.addNewActivitiesTo
7025
+ options2?.addNewActivitiesTo,
7026
+ options2?.activityAddedEventFilter
7014
7027
  );
7015
7028
  };
7016
7029
  this.updateNetworkConnectionStatus = (event) => {
@@ -7020,7 +7033,7 @@ class FeedsClient extends FeedsApi {
7020
7033
  };
7021
7034
  this.eventDispatcher.dispatch(networkEvent);
7022
7035
  };
7023
- this.getOrCreateActiveFeed = (group, id, data, watch, addNewActivitiesTo) => {
7036
+ this.getOrCreateActiveFeed = (group, id, data, watch, addNewActivitiesTo, activityAddedEventFilter) => {
7024
7037
  const fid = `${group}:${id}`;
7025
7038
  if (!this.activeFeeds[fid]) {
7026
7039
  this.activeFeeds[fid] = new Feed(
@@ -7029,7 +7042,8 @@ class FeedsClient extends FeedsApi {
7029
7042
  id,
7030
7043
  data,
7031
7044
  watch,
7032
- addNewActivitiesTo
7045
+ addNewActivitiesTo,
7046
+ activityAddedEventFilter
7033
7047
  );
7034
7048
  }
7035
7049
  const feed = this.activeFeeds[fid];
@@ -7139,13 +7153,13 @@ class FeedsClient extends FeedsApi {
7139
7153
  case "feeds.bookmark.deleted":
7140
7154
  case "feeds.bookmark.updated": {
7141
7155
  const activityId = event.bookmark.activity.id;
7142
- const feeds = this.findActiveFeedByActivityId(activityId);
7156
+ const feeds = this.findActiveFeedsByActivityId(activityId);
7143
7157
  feeds.forEach((f) => f.handleWSEvent(event));
7144
7158
  break;
7145
7159
  }
7146
7160
  case "feeds.activity.feedback": {
7147
7161
  const activityId = event.activity_feedback.activity_id;
7148
- const feeds = this.findActiveFeedByActivityId(activityId);
7162
+ const feeds = this.findActiveFeedsByActivityId(activityId);
7149
7163
  feeds.forEach((f) => f.handleWSEvent(event));
7150
7164
  break;
7151
7165
  }
@@ -7283,11 +7297,9 @@ class FeedsClient extends FeedsApi {
7283
7297
  }
7284
7298
  return response;
7285
7299
  }
7286
- findActiveFeedByActivityId(activityId) {
7300
+ findActiveFeedsByActivityId(activityId) {
7287
7301
  return Object.values(this.activeFeeds).filter(
7288
- (feed) => feed.currentState.activities?.some(
7289
- (activity) => activity.id === activityId
7290
- )
7302
+ (feed) => feed.hasActivity(activityId) || feed.hasPinnedActivity(activityId)
7291
7303
  );
7292
7304
  }
7293
7305
  }
@@ -7312,4 +7324,4 @@ exports.replaceUniqueArrayMerge = replaceUniqueArrayMerge;
7312
7324
  exports.shouldUpdateState = shouldUpdateState;
7313
7325
  exports.uniqueArrayMerge = uniqueArrayMerge;
7314
7326
  exports.updateEntityInArray = updateEntityInArray;
7315
- //# sourceMappingURL=feeds-client-jZwPzici.js.map
7327
+ //# sourceMappingURL=feeds-client-Ddac-BnP.js.map