@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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [0.3.19](https://github.com/GetStream/stream-feeds-js/compare/@stream-io/feeds-client-0.3.18...@stream-io/feeds-client-0.3.19) (2025-12-11)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * reactive state updates for follow/unfollow ([#188](https://github.com/GetStream/stream-feeds-js/issues/188)) ([841d436](https://github.com/GetStream/stream-feeds-js/commit/841d43605a5f47cc929b3865f6c13ad26dbbf4c0))
11
+
5
12
  ## [0.3.18](https://github.com/GetStream/stream-feeds-js/compare/@stream-io/feeds-client-0.3.17...@stream-io/feeds-client-0.3.18) (2025-12-10)
6
13
 
7
14
 
package/dist/cjs/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const stateStore = require("@stream-io/state-store");
4
- const feedsClient = require("../feeds-client-Be5gS8Xx.js");
4
+ const feedsClient = require("../feeds-client-BwOGqhU9.js");
5
5
  const loggerInternal = require("@stream-io/logger");
6
6
  const ChannelOwnCapability = {
7
7
  BAN_CHANNEL_MEMBERS: "ban-channel-members",
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const require$$0 = require("react");
4
4
  require("@stream-io/state-store");
5
- const feedsClient = require("../feeds-client-Be5gS8Xx.js");
5
+ const feedsClient = require("../feeds-client-BwOGqhU9.js");
6
6
  require("axios");
7
7
  var shim = { exports: {} };
8
8
  var useSyncExternalStoreShim_production = {};
package/dist/es/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { StateStore } from "@stream-io/state-store";
2
2
  export * from "@stream-io/state-store";
3
- import { d as debounce } from "../feeds-client-DT_p8LU4.mjs";
4
- import { A, C, a, F, S, b, c, n, m, k, g, e, h, f, j, i, r, s, u, l } from "../feeds-client-DT_p8LU4.mjs";
3
+ import { d as debounce } from "../feeds-client-BseA5k3b.mjs";
4
+ import { A, C, a, F, S, b, c, n, m, k, g, e, h, f, j, i, r, s, u, l } from "../feeds-client-BseA5k3b.mjs";
5
5
  import { LogLevelEnum } from "@stream-io/logger";
6
6
  const ChannelOwnCapability = {
7
7
  BAN_CHANNEL_MEMBERS: "ban-channel-members",
@@ -1,6 +1,6 @@
1
1
  import require$$0, { useCallback, useMemo, useState, useEffect, createContext, useContext, useRef } from "react";
2
2
  import "@stream-io/state-store";
3
- import { F as FeedsClient, g as isCommentResponse, c as checkHasAnotherPage } from "../feeds-client-DT_p8LU4.mjs";
3
+ import { F as FeedsClient, g as isCommentResponse, c as checkHasAnotherPage } from "../feeds-client-BseA5k3b.mjs";
4
4
  import "axios";
5
5
  var shim = { exports: {} };
6
6
  var useSyncExternalStoreShim_production = {};
@@ -3914,7 +3914,7 @@ const getRateLimitFromResponseHeader = (response_headers) => {
3914
3914
  };
3915
3915
  return result;
3916
3916
  };
3917
- const version = "0.3.18";
3917
+ const version = "0.3.19";
3918
3918
  class ApiClient {
3919
3919
  constructor(apiKey, tokenManager, connectionIdManager, options) {
3920
3920
  this.apiKey = apiKey;
@@ -4857,10 +4857,10 @@ const updateStateFollowDeleted = (follow, currentState, currentFeedId, connected
4857
4857
  // Update FeedResponse fields, that has the new follower/following count
4858
4858
  ...follow.target_feed
4859
4859
  };
4860
- if (source.created_by.id === connectedUserId && currentState.own_follows !== void 0) {
4861
- newState.own_follows = currentState.own_follows.filter(
4860
+ if (source.created_by.id === connectedUserId) {
4861
+ newState.own_follows = currentState.own_follows ? currentState.own_follows.filter(
4862
4862
  (followItem) => followItem.source_feed.feed !== follow.source_feed.feed
4863
- );
4863
+ ) : [];
4864
4864
  }
4865
4865
  if (currentState.followers !== void 0) {
4866
4866
  newState.followers = currentState.followers.filter(
@@ -5508,6 +5508,7 @@ function addActivitiesToState(newActivities, activities, position) {
5508
5508
  ...activities,
5509
5509
  ...position === "end" ? newActivitiesDeduplicated : []
5510
5510
  ];
5511
+ this.newActivitiesAdded(newActivitiesDeduplicated);
5511
5512
  result = { changed: true, activities: updatedActivities };
5512
5513
  }
5513
5514
  return result;
@@ -6226,6 +6227,9 @@ const deepEqual = (x, y) => {
6226
6227
  return false;
6227
6228
  }
6228
6229
  };
6230
+ function getOrCreateActiveFeed(group, id, data, watch) {
6231
+ return this.getOrCreateActiveFeed(group, id, data, watch);
6232
+ }
6229
6233
  const _Feed = class _Feed extends FeedApi {
6230
6234
  constructor(client, groupId, id, data, watch = false, addNewActivitiesTo = "start", activityAddedEventFilter) {
6231
6235
  super(client, groupId, id);
@@ -6418,7 +6422,7 @@ const _Feed = class _Feed extends FeedApi {
6418
6422
  return nextState;
6419
6423
  });
6420
6424
  }
6421
- this.client.hydratePollCache(response.activities);
6425
+ this.newActivitiesAdded(response.activities);
6422
6426
  return response;
6423
6427
  } finally {
6424
6428
  this.state.partialNext({
@@ -6819,6 +6823,18 @@ const _Feed = class _Feed extends FeedApi {
6819
6823
  }
6820
6824
  this.eventDispatcher.dispatch(event);
6821
6825
  }
6826
+ newActivitiesAdded(activities) {
6827
+ this.client.hydratePollCache(activities);
6828
+ activities.forEach((activity) => {
6829
+ if (activity.current_feed) {
6830
+ getOrCreateActiveFeed.bind(this.client)(
6831
+ activity.current_feed.group_id,
6832
+ activity.current_feed.id,
6833
+ activity.current_feed
6834
+ );
6835
+ }
6836
+ });
6837
+ }
6822
6838
  };
6823
6839
  _Feed.noop = () => {
6824
6840
  };
@@ -7363,8 +7379,7 @@ class FeedsClient extends FeedsApi {
7363
7379
  id,
7364
7380
  void 0,
7365
7381
  void 0,
7366
- options2?.addNewActivitiesTo,
7367
- options2?.activityAddedEventFilter
7382
+ options2
7368
7383
  );
7369
7384
  };
7370
7385
  this.activityWithStateUpdates = (id) => {
@@ -7382,20 +7397,30 @@ class FeedsClient extends FeedsApi {
7382
7397
  };
7383
7398
  this.eventDispatcher.dispatch(networkEvent);
7384
7399
  };
7385
- this.getOrCreateActiveFeed = (group, id, data, watch, addNewActivitiesTo, activityAddedEventFilter) => {
7400
+ this.getOrCreateActiveFeed = (group, id, data, watch, options2) => {
7386
7401
  const fid = `${group}:${id}`;
7402
+ let isCreated = false;
7387
7403
  if (!this.activeFeeds[fid]) {
7404
+ isCreated = true;
7388
7405
  this.activeFeeds[fid] = new Feed(
7389
7406
  this,
7390
7407
  group,
7391
7408
  id,
7392
7409
  data,
7393
7410
  watch,
7394
- addNewActivitiesTo,
7395
- activityAddedEventFilter
7411
+ options2?.addNewActivitiesTo,
7412
+ options2?.activityAddedEventFilter
7396
7413
  );
7397
7414
  }
7398
7415
  const feed = this.activeFeeds[fid];
7416
+ if (!isCreated && options2) {
7417
+ if (options2?.addNewActivitiesTo) {
7418
+ feed.addNewActivitiesTo = options2.addNewActivitiesTo;
7419
+ }
7420
+ if (options2?.activityAddedEventFilter) {
7421
+ feed.activityAddedEventFilter = options2.activityAddedEventFilter;
7422
+ }
7423
+ }
7399
7424
  if (!feed.currentState.watch) {
7400
7425
  if (data) handleFeedUpdated.call(feed, { feed: data });
7401
7426
  if (watch) handleWatchStarted.call(feed);
@@ -7667,6 +7692,17 @@ class FeedsClient extends FeedsApi {
7667
7692
  }
7668
7693
  return response;
7669
7694
  }
7695
+ async getFollowSuggestions(...params) {
7696
+ const response = await super.getFollowSuggestions(...params);
7697
+ response.suggestions.forEach((suggestion) => {
7698
+ this.getOrCreateActiveFeed(
7699
+ suggestion.group_id,
7700
+ suggestion.id,
7701
+ suggestion
7702
+ );
7703
+ });
7704
+ return response;
7705
+ }
7670
7706
  findAllActiveFeedsByActivityId(activityId) {
7671
7707
  return [
7672
7708
  ...Object.values(this.activeFeeds),
@@ -7748,4 +7784,4 @@ export {
7748
7784
  shouldUpdateState as s,
7749
7785
  uniqueArrayMerge as u
7750
7786
  };
7751
- //# sourceMappingURL=feeds-client-DT_p8LU4.mjs.map
7787
+ //# sourceMappingURL=feeds-client-BseA5k3b.mjs.map