@stream-io/feeds-client 0.3.51 → 1.0.0

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.
Files changed (44) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/index.js +2 -1
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/cjs/react-bindings.js +1 -1
  5. package/dist/es/index.mjs +15 -14
  6. package/dist/es/react-bindings.mjs +1 -1
  7. package/dist/{feeds-client-DeAqnd1a.mjs → feeds-client-B03y08Kq.mjs} +184 -67
  8. package/dist/feeds-client-B03y08Kq.mjs.map +1 -0
  9. package/dist/{feeds-client-B4zeBggL.js → feeds-client-tw63OGrd.js} +178 -61
  10. package/dist/feeds-client-tw63OGrd.js.map +1 -0
  11. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  12. package/dist/types/activity-with-state-updates/activity-with-state-updates.d.ts.map +1 -1
  13. package/dist/types/feed/activity-filter.d.ts +11 -0
  14. package/dist/types/feed/activity-filter.d.ts.map +1 -0
  15. package/dist/types/feed/event-handlers/activity/handle-activity-added.d.ts +3 -2
  16. package/dist/types/feed/event-handlers/activity/handle-activity-added.d.ts.map +1 -1
  17. package/dist/types/feed/event-handlers/activity/handle-activity-updated.d.ts.map +1 -1
  18. package/dist/types/feed/event-handlers/comment/handle-comment-updated.d.ts.map +1 -1
  19. package/dist/types/feed/event-handlers/follow/handle-follow-created.d.ts +2 -2
  20. package/dist/types/feed/event-handlers/follow/handle-follow-created.d.ts.map +1 -1
  21. package/dist/types/feed/feed.d.ts +17 -12
  22. package/dist/types/feed/feed.d.ts.map +1 -1
  23. package/dist/types/feeds-client/apply-new-activity-to-active-feeds.d.ts +4 -0
  24. package/dist/types/feeds-client/apply-new-activity-to-active-feeds.d.ts.map +1 -0
  25. package/dist/types/feeds-client/feeds-client.d.ts +6 -8
  26. package/dist/types/feeds-client/feeds-client.d.ts.map +1 -1
  27. package/dist/types/index.d.ts +1 -0
  28. package/dist/types/index.d.ts.map +1 -1
  29. package/dist/types/types.d.ts +15 -0
  30. package/dist/types/types.d.ts.map +1 -1
  31. package/package.json +2 -1
  32. package/src/activity-with-state-updates/activity-with-state-updates.ts +8 -2
  33. package/src/feed/activity-filter.ts +44 -0
  34. package/src/feed/event-handlers/activity/handle-activity-added.ts +22 -8
  35. package/src/feed/event-handlers/activity/handle-activity-updated.ts +5 -1
  36. package/src/feed/event-handlers/comment/handle-comment-updated.ts +11 -10
  37. package/src/feed/event-handlers/follow/handle-follow-created.ts +18 -1
  38. package/src/feed/feed.ts +72 -21
  39. package/src/feeds-client/apply-new-activity-to-active-feeds.ts +9 -0
  40. package/src/feeds-client/feeds-client.ts +46 -28
  41. package/src/index.ts +1 -0
  42. package/src/types.ts +17 -0
  43. package/dist/feeds-client-B4zeBggL.js.map +0 -1
  44. package/dist/feeds-client-DeAqnd1a.mjs.map +0 -1
@@ -2,6 +2,7 @@
2
2
  const stateStore = require("@stream-io/state-store");
3
3
  const loggerInternal = require("@stream-io/logger");
4
4
  const axiosImport = require("axios");
5
+ const filter = require("@stream-io/filter");
5
6
  function _interopNamespaceDefault(e) {
6
7
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
7
8
  if (e) {
@@ -4128,7 +4129,7 @@ const getRateLimitFromResponseHeader = (response_headers) => {
4128
4129
  };
4129
4130
  return result;
4130
4131
  };
4131
- const version = "0.3.51";
4132
+ const version = "1.0.0";
4132
4133
  const axios = axiosImport.default ?? axiosImport;
4133
4134
  class ApiClient {
4134
4135
  constructor(apiKey, tokenManager, connectionIdManager, options) {
@@ -5063,7 +5064,7 @@ function updateEntityInArray({
5063
5064
  updatedEntities[index] = newEntity;
5064
5065
  return { changed: true, entities: updatedEntities };
5065
5066
  }
5066
- const updateStateFollowCreated = (follow, currentState, currentFeedId, connectedUserId) => {
5067
+ const updateStateFollowCreated = (follow, currentState, currentFeedId, connectedUserId, hasOwnFields = false) => {
5067
5068
  if (follow.status !== "accepted") {
5068
5069
  return { changed: false, data: currentState };
5069
5070
  }
@@ -5072,7 +5073,12 @@ const updateStateFollowCreated = (follow, currentState, currentFeedId, connected
5072
5073
  newState = {
5073
5074
  ...newState,
5074
5075
  // Update FeedResponse fields, that has the new follower/following count
5075
- ...follow.source_feed
5076
+ ...follow.source_feed,
5077
+ ...hasOwnFields ? {
5078
+ own_capabilities: follow.source_feed.own_capabilities,
5079
+ own_follows: follow.source_feed.own_follows,
5080
+ own_followings: follow.source_feed.own_followings
5081
+ } : {}
5076
5082
  };
5077
5083
  if (currentState.following !== void 0) {
5078
5084
  newState.following = [follow, ...currentState.following];
@@ -5085,9 +5091,14 @@ const updateStateFollowCreated = (follow, currentState, currentFeedId, connected
5085
5091
  newState = {
5086
5092
  ...newState,
5087
5093
  // Update FeedResponse fields, that has the new follower/following count
5088
- ...follow.target_feed
5089
- };
5090
- if (source.created_by.id === connectedUserId) {
5094
+ ...follow.target_feed,
5095
+ ...hasOwnFields ? {
5096
+ own_capabilities: follow.target_feed.own_capabilities,
5097
+ own_follows: follow.target_feed.own_follows,
5098
+ own_followings: follow.target_feed.own_followings
5099
+ } : {}
5100
+ };
5101
+ if (source.created_by.id === connectedUserId && !hasOwnFields) {
5091
5102
  newState.own_follows = currentState.own_follows ? currentState.own_follows.concat(follow) : [follow];
5092
5103
  }
5093
5104
  if (currentState.followers !== void 0) {
@@ -5096,7 +5107,7 @@ const updateStateFollowCreated = (follow, currentState, currentFeedId, connected
5096
5107
  }
5097
5108
  return { changed: true, data: newState };
5098
5109
  };
5099
- function handleFollowCreated(eventOrResponse, fromWs) {
5110
+ function handleFollowCreated(eventOrResponse, fromWs, hasOwnFields = false) {
5100
5111
  const follow = eventOrResponse.follow;
5101
5112
  if (!shouldUpdateState({
5102
5113
  stateUpdateQueueId: getStateUpdateQueueId(follow, "follow-created"),
@@ -5112,7 +5123,8 @@ function handleFollowCreated(eventOrResponse, fromWs) {
5112
5123
  follow,
5113
5124
  this.currentState,
5114
5125
  this.feed,
5115
- connectedUser?.id
5126
+ connectedUser?.id,
5127
+ hasOwnFields
5116
5128
  );
5117
5129
  if (result.changed) {
5118
5130
  this.state.next(result.data);
@@ -5336,14 +5348,14 @@ function handleCommentUpdated(payload, fromWs) {
5336
5348
  const { comment } = payload;
5337
5349
  const entityId = comment.parent_id ?? comment.object_id;
5338
5350
  if (!shouldUpdateState({
5339
- stateUpdateQueueId: getStateUpdateQueueId(
5340
- payload,
5341
- "comment-updated"
5342
- ),
5351
+ stateUpdateQueueId: getStateUpdateQueueId(payload, "comment-updated"),
5343
5352
  stateUpdateQueue: this.stateUpdateQueue,
5344
5353
  watch: this.currentState.watch,
5345
5354
  fromWs,
5346
- isTriggeredByConnectedUser: eventTriggeredByConnectedUser.call(this, payload)
5355
+ isTriggeredByConnectedUser: eventTriggeredByConnectedUser.call(
5356
+ this,
5357
+ payload
5358
+ )
5347
5359
  })) {
5348
5360
  return;
5349
5361
  }
@@ -5353,7 +5365,10 @@ function handleCommentUpdated(payload, fromWs) {
5353
5365
  const index = this.getCommentIndex(comment, currentState);
5354
5366
  if (index === -1) return currentState;
5355
5367
  const newComments = [...entityState.comments];
5356
- newComments[index] = comment;
5368
+ newComments[index] = {
5369
+ ...comment,
5370
+ own_reactions: entityState.comments[index].own_reactions
5371
+ };
5357
5372
  return {
5358
5373
  ...currentState,
5359
5374
  comments_by_entity_id: {
@@ -5782,7 +5797,13 @@ function handleBookmarkUpdated(event) {
5782
5797
  });
5783
5798
  }
5784
5799
  }
5785
- function addActivitiesToState(newActivities, activities, position, { fromWebSocket } = { fromWebSocket: false }) {
5800
+ function addActivitiesToState(newActivities, activities, position, {
5801
+ hasOwnFields,
5802
+ backfillOwnFields
5803
+ } = {
5804
+ hasOwnFields: true,
5805
+ backfillOwnFields: true
5806
+ }) {
5786
5807
  if (activities === void 0) {
5787
5808
  return {
5788
5809
  changed: false,
@@ -5805,23 +5826,31 @@ function addActivitiesToState(newActivities, activities, position, { fromWebSock
5805
5826
  ...activities,
5806
5827
  ...position === "end" ? newActivitiesDeduplicated : []
5807
5828
  ];
5808
- this.newActivitiesAdded(newActivitiesDeduplicated, { fromWebSocket });
5829
+ this.activitiesAddedOrUpdated(newActivitiesDeduplicated, {
5830
+ hasOwnFields,
5831
+ backfillOwnFields
5832
+ });
5809
5833
  result = { changed: true, activities: updatedActivities };
5810
5834
  }
5811
5835
  return result;
5812
5836
  }
5813
5837
  function handleActivityAdded(event) {
5814
- if (this.activityAddedEventFilter) {
5815
- if (!this.activityAddedEventFilter(event)) {
5816
- return;
5817
- }
5838
+ const currentUser = this.client.state.getLatestValue().connected_user;
5839
+ const decision = this.resolveNewActivityDecision(
5840
+ event.activity,
5841
+ currentUser,
5842
+ false
5843
+ );
5844
+ if (decision === "ignore") {
5845
+ return;
5818
5846
  }
5847
+ const position = decision === "add-to-end" ? "end" : "start";
5819
5848
  const currentActivities = this.currentState.activities;
5820
5849
  const result = addActivitiesToState.bind(this)(
5821
5850
  [event.activity],
5822
5851
  currentActivities,
5823
- this.currentState.addNewActivitiesTo,
5824
- { fromWebSocket: true }
5852
+ position,
5853
+ { hasOwnFields: false, backfillOwnFields: true }
5825
5854
  );
5826
5855
  if (result.changed) {
5827
5856
  const activity = event.activity;
@@ -5938,7 +5967,10 @@ function handleActivityUpdated(payload, fromWs) {
5938
5967
  updatePinnedActivityInState(payload, currentPinnedActivities)
5939
5968
  ];
5940
5969
  if (result1?.changed || result2.changed) {
5941
- this.client.hydratePollCache([payload.activity]);
5970
+ this.activitiesAddedOrUpdated([payload.activity], {
5971
+ hasOwnFields: payload.activity.current_feed?.own_capabilities !== void 0,
5972
+ backfillOwnFields: false
5973
+ });
5942
5974
  this.state.partialNext({
5943
5975
  activities: result1?.changed ? result1.entities : currentActivities,
5944
5976
  pinned_activities: result2.entities
@@ -6450,6 +6482,30 @@ function handleWatchStarted() {
6450
6482
  function handleWatchStopped() {
6451
6483
  this.state.partialNext({ watch: false });
6452
6484
  }
6485
+ const activityResolvers = [
6486
+ {
6487
+ matchesField: (field) => field === "activity_type",
6488
+ resolve: (activity) => activity.type
6489
+ },
6490
+ {
6491
+ matchesField: (field) => field === "within_bounds",
6492
+ resolve: (activity) => activity.location
6493
+ },
6494
+ {
6495
+ matchesField: () => true,
6496
+ resolve: (item, path) => filter.resolveDotPathValue(item, path)
6497
+ }
6498
+ ];
6499
+ function activityFilter(activity, requestConfig) {
6500
+ const filter$1 = requestConfig?.filter;
6501
+ if (!filter$1 || typeof filter$1 !== "object") {
6502
+ return true;
6503
+ }
6504
+ return filter.itemMatchesFilter(activity, filter$1, {
6505
+ resolvers: [...activityResolvers],
6506
+ arrayEqMode: "contains"
6507
+ });
6508
+ }
6453
6509
  const DEFAULT_MAX_RETRIES = 3;
6454
6510
  function isRetryableError(error) {
6455
6511
  if (error instanceof StreamApiError) {
@@ -6641,9 +6697,9 @@ function clearQueuedFeeds() {
6641
6697
  queuedFeeds.clear();
6642
6698
  }
6643
6699
  const _Feed = class _Feed extends FeedApi {
6644
- constructor(client, groupId, id, data, watch = false, addNewActivitiesTo = "start", activityAddedEventFilter) {
6700
+ constructor(client, groupId, id, data, watch = false, onNewActivity) {
6645
6701
  super(client, groupId, id);
6646
- this.activityAddedEventFilter = activityAddedEventFilter;
6702
+ this.onNewActivity = onNewActivity;
6647
6703
  this.indexedActivityIds = /* @__PURE__ */ new Set();
6648
6704
  this.stateUpdateQueue = /* @__PURE__ */ new Set();
6649
6705
  this.eventHandlers = {
@@ -6713,8 +6769,7 @@ const _Feed = class _Feed extends FeedApi {
6713
6769
  is_loading: false,
6714
6770
  is_loading_activities: false,
6715
6771
  comments_by_entity_id: {},
6716
- watch,
6717
- addNewActivitiesTo
6772
+ watch
6718
6773
  });
6719
6774
  this.client = client;
6720
6775
  this.state.subscribeWithSelector(
@@ -6735,9 +6790,6 @@ const _Feed = class _Feed extends FeedApi {
6735
6790
  get currentState() {
6736
6791
  return this.state.getLatestValue();
6737
6792
  }
6738
- set addNewActivitiesTo(value) {
6739
- this.state.partialNext({ addNewActivitiesTo: value });
6740
- }
6741
6793
  hasActivity(activityId) {
6742
6794
  return this.indexedActivityIds.has(activityId);
6743
6795
  }
@@ -6746,6 +6798,24 @@ const _Feed = class _Feed extends FeedApi {
6746
6798
  (pinnedActivity) => pinnedActivity.activity.id === activityId
6747
6799
  );
6748
6800
  }
6801
+ /**
6802
+ * Resolves how to handle a new activity (WS or HTTP): ignore, add-to-start, or add-to-end.
6803
+ * Uses onNewActivity if set; else default (current user + filter match) adds to start.
6804
+ */
6805
+ resolveNewActivityDecision(activity, currentUser, _fromHttp) {
6806
+ if (this.onNewActivity) {
6807
+ return this.onNewActivity({ activity, currentUser });
6808
+ }
6809
+ if (!currentUser) return "ignore";
6810
+ if (activity.user?.id !== currentUser.id) return "ignore";
6811
+ if (!activityFilter(
6812
+ activity,
6813
+ this.currentState.last_get_or_create_request_config
6814
+ )) {
6815
+ return "ignore";
6816
+ }
6817
+ return "add-to-start";
6818
+ }
6749
6819
  async synchronize() {
6750
6820
  const { last_get_or_create_request_config } = this.state.getLatestValue();
6751
6821
  if (last_get_or_create_request_config?.watch) {
@@ -6783,7 +6853,8 @@ const _Feed = class _Feed extends FeedApi {
6783
6853
  const result = addActivitiesToState.bind(this)(
6784
6854
  response.activities,
6785
6855
  currentActivities,
6786
- "end"
6856
+ "end",
6857
+ { hasOwnFields: true, backfillOwnFields: false }
6787
6858
  );
6788
6859
  const aggregatedActivitiesResult = addAggregatedActivitiesToState(
6789
6860
  response.aggregated_activities,
@@ -6832,7 +6903,7 @@ const _Feed = class _Feed extends FeedApi {
6832
6903
  return nextState;
6833
6904
  });
6834
6905
  }
6835
- this.newActivitiesAdded(response.activities);
6906
+ this.activitiesAddedOrUpdated(response.activities);
6836
6907
  return response;
6837
6908
  } finally {
6838
6909
  this.state.partialNext({
@@ -7140,11 +7211,11 @@ const _Feed = class _Feed extends FeedApi {
7140
7211
  * _Note: Useful only for feeds with `groupId` of `user` value._
7141
7212
  */
7142
7213
  async queryFollowers(request) {
7143
- const filter = {
7214
+ const filter2 = {
7144
7215
  target_feed: this.feed
7145
7216
  };
7146
7217
  const response = await this.client.queryFollows({
7147
- filter,
7218
+ filter: filter2,
7148
7219
  ...request
7149
7220
  });
7150
7221
  return response;
@@ -7155,11 +7226,11 @@ const _Feed = class _Feed extends FeedApi {
7155
7226
  * _Note: Useful only for feeds with `groupId` of `timeline` value._
7156
7227
  */
7157
7228
  async queryFollowing(request) {
7158
- const filter = {
7229
+ const filter2 = {
7159
7230
  source_feed: this.feed
7160
7231
  };
7161
7232
  const response = await this.client.queryFollows({
7162
- filter,
7233
+ filter: filter2,
7163
7234
  ...request
7164
7235
  });
7165
7236
  return response;
@@ -7207,11 +7278,41 @@ const _Feed = class _Feed extends FeedApi {
7207
7278
  next: currentState.next
7208
7279
  });
7209
7280
  }
7281
+ /**
7282
+ * Applies a new activity to this feed's state (decision + add to activities).
7283
+ * Used when the activity was added via this feed's addActivity or via client.addActivity.
7284
+ */
7285
+ addActivityFromHTTPResponse(activity) {
7286
+ const currentUser = this.client.state.getLatestValue().connected_user;
7287
+ const decision = this.resolveNewActivityDecision(
7288
+ activity,
7289
+ currentUser,
7290
+ true
7291
+ );
7292
+ if (decision !== "ignore") {
7293
+ const position = decision === "add-to-end" ? "end" : "start";
7294
+ const currentActivities = this.currentState.activities;
7295
+ const result = addActivitiesToState.bind(this)(
7296
+ [activity],
7297
+ currentActivities,
7298
+ position,
7299
+ {
7300
+ hasOwnFields: activity.current_feed?.own_capabilities !== void 0,
7301
+ backfillOwnFields: false
7302
+ }
7303
+ );
7304
+ if (result.changed) {
7305
+ this.client.hydratePollCache([activity]);
7306
+ this.state.partialNext({ activities: result.activities });
7307
+ }
7308
+ }
7309
+ }
7210
7310
  async addActivity(request) {
7211
7311
  const response = await this.client.addActivity({
7212
7312
  ...request,
7213
7313
  feeds: [this.feed]
7214
7314
  });
7315
+ this.addActivityFromHTTPResponse(response.activity);
7215
7316
  return response;
7216
7317
  }
7217
7318
  handleWSEvent(event) {
@@ -7232,7 +7333,7 @@ const _Feed = class _Feed extends FeedApi {
7232
7333
  }
7233
7334
  this.eventDispatcher.dispatch(event);
7234
7335
  }
7235
- newActivitiesAdded(activities, options = { fromWebSocket: false }) {
7336
+ activitiesAddedOrUpdated(activities, options = { hasOwnFields: true, backfillOwnFields: true }) {
7236
7337
  this.client.hydratePollCache(activities);
7237
7338
  this.getOrCreateFeeds(activities, options);
7238
7339
  }
@@ -7250,7 +7351,7 @@ const _Feed = class _Feed extends FeedApi {
7250
7351
  });
7251
7352
  const newFeeds = Array.from(feedsToGetOrCreate.values());
7252
7353
  const fieldsToUpdate = [];
7253
- if (!options.fromWebSocket) {
7354
+ if (options.hasOwnFields) {
7254
7355
  fieldsToUpdate.push("own_membership");
7255
7356
  if (!enrichmentOptions?.skip_own_capabilities) {
7256
7357
  fieldsToUpdate.push("own_capabilities");
@@ -7270,7 +7371,7 @@ const _Feed = class _Feed extends FeedApi {
7270
7371
  fieldsToUpdate
7271
7372
  });
7272
7373
  });
7273
- if (options.fromWebSocket) {
7374
+ if (!options.hasOwnFields && options.backfillOwnFields) {
7274
7375
  const uninitializedFeeds = newFeeds.filter((feedResponse) => {
7275
7376
  const feed = this.client.feed(feedResponse.group_id, feedResponse.id);
7276
7377
  return feed.currentState.own_capabilities === void 0;
@@ -7293,6 +7394,9 @@ const _Feed = class _Feed extends FeedApi {
7293
7394
  _Feed.noop = () => {
7294
7395
  };
7295
7396
  let Feed = _Feed;
7397
+ function applyNewActivityToActiveFeeds(activity) {
7398
+ return this.addActivityFromHTTPResponse(activity);
7399
+ }
7296
7400
  function handleUserUpdated(event) {
7297
7401
  this.state.next((currentState) => {
7298
7402
  let newState;
@@ -7372,7 +7476,9 @@ function disconnectActivityFromFeed(activity) {
7372
7476
  }
7373
7477
  }
7374
7478
  class ActivityWithStateUpdates {
7375
- constructor(id, feedsClient, { fromResponse } = { fromResponse: void 0 }) {
7479
+ constructor(id, feedsClient, { fromResponse } = {
7480
+ fromResponse: void 0
7481
+ }) {
7376
7482
  this.id = id;
7377
7483
  this.feedsClient = feedsClient;
7378
7484
  this.state = new stateStore.StateStore({
@@ -7423,7 +7529,7 @@ class ActivityWithStateUpdates {
7423
7529
  initialState: activityResponse
7424
7530
  });
7425
7531
  if (this.feed) {
7426
- this.feed.activityAddedEventFilter = () => false;
7532
+ this.feed.onNewActivity = () => "ignore";
7427
7533
  }
7428
7534
  if (comments) {
7429
7535
  await this.loadNextPageActivityComments(comments);
@@ -7476,7 +7582,11 @@ class ActivityWithStateUpdates {
7476
7582
  const { activities } = addActivitiesToState.bind(this.feed)(
7477
7583
  [initialState],
7478
7584
  [],
7479
- "start"
7585
+ "start",
7586
+ {
7587
+ hasOwnFields: initialState.current_feed?.own_capabilities !== void 0,
7588
+ backfillOwnFields: false
7589
+ }
7480
7590
  );
7481
7591
  this.feed?.state.partialNext({
7482
7592
  activities
@@ -7834,9 +7944,9 @@ class FeedsClient extends FeedsApi {
7834
7944
  return response;
7835
7945
  };
7836
7946
  this.queryPollAnswers = async (request) => {
7837
- const filter = request.filter ?? {};
7947
+ const filter2 = request.filter ?? {};
7838
7948
  const queryPollAnswersFilter = {
7839
- ...filter,
7949
+ ...filter2,
7840
7950
  is_answer: true
7841
7951
  };
7842
7952
  const queryPollAnswersRequest = {
@@ -7907,18 +8017,12 @@ class FeedsClient extends FeedsApi {
7907
8017
  id,
7908
8018
  data,
7909
8019
  watch,
7910
- options2?.addNewActivitiesTo,
7911
- options2?.activityAddedEventFilter
8020
+ options2?.onNewActivity
7912
8021
  );
7913
8022
  }
7914
8023
  const feed = this.activeFeeds[fid];
7915
- if (!isCreated && options2) {
7916
- if (options2?.addNewActivitiesTo) {
7917
- feed.addNewActivitiesTo = options2.addNewActivitiesTo;
7918
- }
7919
- if (options2?.activityAddedEventFilter) {
7920
- feed.activityAddedEventFilter = options2.activityAddedEventFilter;
7921
- }
8024
+ if (!isCreated && options2?.onNewActivity !== void 0) {
8025
+ feed.onNewActivity = options2.onNewActivity;
7922
8026
  }
7923
8027
  if (!feed.currentState.watch) {
7924
8028
  if (!isCreated && data) {
@@ -8098,6 +8202,16 @@ class FeedsClient extends FeedsApi {
8098
8202
  });
8099
8203
  }
8100
8204
  }
8205
+ async addActivity(request) {
8206
+ const response = await super.addActivity(request);
8207
+ request.feeds.forEach((fid) => {
8208
+ const feed = this.activeFeeds[fid];
8209
+ if (feed) {
8210
+ applyNewActivityToActiveFeeds.call(feed, response.activity);
8211
+ }
8212
+ });
8213
+ return response;
8214
+ }
8101
8215
  async queryFeeds(request) {
8102
8216
  const response = await this._queryFeeds(request);
8103
8217
  const feedResponses = response.feeds;
@@ -8107,12 +8221,12 @@ class FeedsClient extends FeedsApi {
8107
8221
  id: feedResponse.id,
8108
8222
  data: feedResponse,
8109
8223
  watch: request?.watch,
8110
- fieldsToUpdate: [
8224
+ fieldsToUpdate: request?.enrich_own_fields ? [
8111
8225
  "own_capabilities",
8112
8226
  "own_follows",
8113
8227
  "own_membership",
8114
8228
  "own_followings"
8115
- ]
8229
+ ] : []
8116
8230
  })
8117
8231
  );
8118
8232
  return {
@@ -8147,7 +8261,7 @@ class FeedsClient extends FeedsApi {
8147
8261
  // For follow API endpoints we update the state after HTTP response to allow queryFeeds with watch: false
8148
8262
  async follow(request) {
8149
8263
  const response = await super.follow(request);
8150
- this.updateStateFromFollows([response.follow]);
8264
+ this.updateStateFromFollows([response.follow], !!request.enrich_own_fields);
8151
8265
  return response;
8152
8266
  }
8153
8267
  /**
@@ -8157,12 +8271,12 @@ class FeedsClient extends FeedsApi {
8157
8271
  */
8158
8272
  async followBatch(request) {
8159
8273
  const response = await super.followBatch(request);
8160
- this.updateStateFromFollows(response.follows);
8274
+ this.updateStateFromFollows(response.follows, !!request.enrich_own_fields);
8161
8275
  return response;
8162
8276
  }
8163
8277
  async getOrCreateFollows(request) {
8164
8278
  const response = await super.getOrCreateFollows(request);
8165
- this.updateStateFromFollows(response.created);
8279
+ this.updateStateFromFollows(response.created, !!request.enrich_own_fields);
8166
8280
  return response;
8167
8281
  }
8168
8282
  async unfollow(request) {
@@ -8253,13 +8367,15 @@ class FeedsClient extends FeedsApi {
8253
8367
  }).map((a) => getFeed.call(a))
8254
8368
  ];
8255
8369
  }
8256
- updateStateFromFollows(follows) {
8370
+ updateStateFromFollows(follows, hasOwnFields) {
8257
8371
  follows.forEach((follow) => {
8258
8372
  const feeds = [
8259
8373
  ...this.findAllActiveFeedsByFid(follow.source_feed.feed),
8260
8374
  ...this.findAllActiveFeedsByFid(follow.target_feed.feed)
8261
8375
  ];
8262
- feeds.forEach((f) => handleFollowCreated.bind(f)({ follow }, false));
8376
+ feeds.forEach(
8377
+ (f) => handleFollowCreated.bind(f)({ follow }, false, hasOwnFields)
8378
+ );
8263
8379
  });
8264
8380
  }
8265
8381
  updateStateFromUnfollows(follows) {
@@ -8290,6 +8406,7 @@ exports.Feed = Feed;
8290
8406
  exports.FeedsClient = FeedsClient;
8291
8407
  exports.StreamApiError = StreamApiError;
8292
8408
  exports.StreamPoll = StreamPoll;
8409
+ exports.activityFilter = activityFilter;
8293
8410
  exports.checkHasAnotherPage = checkHasAnotherPage;
8294
8411
  exports.debounce = debounce;
8295
8412
  exports.ensureExhausted = ensureExhausted;
@@ -8305,4 +8422,4 @@ exports.replaceUniqueArrayMerge = replaceUniqueArrayMerge;
8305
8422
  exports.shouldUpdateState = shouldUpdateState;
8306
8423
  exports.uniqueArrayMerge = uniqueArrayMerge;
8307
8424
  exports.updateEntityInArray = updateEntityInArray;
8308
- //# sourceMappingURL=feeds-client-B4zeBggL.js.map
8425
+ //# sourceMappingURL=feeds-client-tw63OGrd.js.map