@stream-io/feeds-client 0.3.5 → 0.3.6

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.6](https://github.com/GetStream/stream-feeds-js/compare/@stream-io/feeds-client-0.3.5...@stream-io/feeds-client-0.3.6) (2025-11-05)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * don't throw error if getOrCreate is called twice with same config ([#160](https://github.com/GetStream/stream-feeds-js/issues/160)) ([200ade9](https://github.com/GetStream/stream-feeds-js/commit/200ade940691c64101d41375ce675139858e8409))
11
+
5
12
  ## [0.3.5](https://github.com/GetStream/stream-feeds-js/compare/@stream-io/feeds-client-0.3.4...@stream-io/feeds-client-0.3.5) (2025-11-04)
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-DLRsdGJc.js");
4
+ const feedsClient = require("../feeds-client-47vliZx_.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-DLRsdGJc.js");
5
+ const feedsClient = require("../feeds-client-47vliZx_.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-0zVMEzPX.mjs";
4
- import { C, a, F, S, b, c, n, m, k, g, e, h, f, j, i, r, s, u, l } from "../feeds-client-0zVMEzPX.mjs";
3
+ import { d as debounce } from "../feeds-client-Cd2LsXp-.mjs";
4
+ import { C, a, F, S, b, c, n, m, k, g, e, h, f, j, i, r, s, u, l } from "../feeds-client-Cd2LsXp-.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-0zVMEzPX.mjs";
3
+ import { F as FeedsClient, g as isCommentResponse, c as checkHasAnotherPage } from "../feeds-client-Cd2LsXp-.mjs";
4
4
  import "axios";
5
5
  var shim = { exports: {} };
6
6
  var useSyncExternalStoreShim_production = {};
@@ -3781,7 +3781,7 @@ const getRateLimitFromResponseHeader = (response_headers) => {
3781
3781
  };
3782
3782
  return result;
3783
3783
  };
3784
- const version = "0.3.5";
3784
+ const version = "0.3.6";
3785
3785
  class ApiClient {
3786
3786
  constructor(apiKey, tokenManager, connectionIdManager, options) {
3787
3787
  this.apiKey = apiKey;
@@ -6076,6 +6076,21 @@ function handleActivityFeedback(event) {
6076
6076
  });
6077
6077
  }
6078
6078
  }
6079
+ const deepEqual = (x, y) => {
6080
+ if (x === y) {
6081
+ return true;
6082
+ } else if (typeof x == "object" && x != null && typeof y == "object" && y != null) {
6083
+ if (Object.keys(x).length != Object.keys(y).length) return false;
6084
+ for (const prop in x) {
6085
+ if (Object.prototype.hasOwnProperty.call(y, prop)) {
6086
+ if (!deepEqual(x[prop], y[prop])) return false;
6087
+ } else return false;
6088
+ }
6089
+ return true;
6090
+ } else {
6091
+ return false;
6092
+ }
6093
+ };
6079
6094
  const _Feed = class _Feed extends FeedApi {
6080
6095
  constructor(client, groupId, id, data, watch = false, addNewActivitiesTo = "start", activityAddedEventFilter) {
6081
6096
  super(client, groupId, id);
@@ -6183,10 +6198,14 @@ const _Feed = class _Feed extends FeedApi {
6183
6198
  async synchronize() {
6184
6199
  const { last_get_or_create_request_config } = this.state.getLatestValue();
6185
6200
  if (last_get_or_create_request_config?.watch) {
6201
+ this.inProgressGetOrCreate = void 0;
6186
6202
  await this.getOrCreate(last_get_or_create_request_config);
6187
6203
  }
6188
6204
  }
6189
6205
  async getOrCreate(request) {
6206
+ if (!request?.next && this.inProgressGetOrCreate && deepEqual(request, this.inProgressGetOrCreate.request)) {
6207
+ return this.inProgressGetOrCreate.promise;
6208
+ }
6190
6209
  if (this.currentState.is_loading_activities) {
6191
6210
  throw new Error("Only one getOrCreate call is allowed at a time");
6192
6211
  }
@@ -6195,7 +6214,11 @@ const _Feed = class _Feed extends FeedApi {
6195
6214
  is_loading_activities: true
6196
6215
  });
6197
6216
  try {
6198
- const response = await super.getOrCreate(request);
6217
+ const responsePromise = super.getOrCreate(request);
6218
+ if (!request?.next) {
6219
+ this.inProgressGetOrCreate = { request, promise: responsePromise };
6220
+ }
6221
+ const response = await responsePromise;
6199
6222
  const currentActivityFeeds = [];
6200
6223
  for (const activity of response.activities) {
6201
6224
  if (activity.current_feed) {
@@ -6267,6 +6290,9 @@ const _Feed = class _Feed extends FeedApi {
6267
6290
  is_loading: false,
6268
6291
  is_loading_activities: false
6269
6292
  });
6293
+ if (!request?.next) {
6294
+ this.inProgressGetOrCreate = void 0;
6295
+ }
6270
6296
  }
6271
6297
  }
6272
6298
  /**
@@ -7329,4 +7355,4 @@ exports.replaceUniqueArrayMerge = replaceUniqueArrayMerge;
7329
7355
  exports.shouldUpdateState = shouldUpdateState;
7330
7356
  exports.uniqueArrayMerge = uniqueArrayMerge;
7331
7357
  exports.updateEntityInArray = updateEntityInArray;
7332
- //# sourceMappingURL=feeds-client-DLRsdGJc.js.map
7358
+ //# sourceMappingURL=feeds-client-47vliZx_.js.map