@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.
@@ -3763,7 +3763,7 @@ const getRateLimitFromResponseHeader = (response_headers) => {
3763
3763
  };
3764
3764
  return result;
3765
3765
  };
3766
- const version = "0.3.5";
3766
+ const version = "0.3.6";
3767
3767
  class ApiClient {
3768
3768
  constructor(apiKey, tokenManager, connectionIdManager, options) {
3769
3769
  this.apiKey = apiKey;
@@ -6058,6 +6058,21 @@ function handleActivityFeedback(event) {
6058
6058
  });
6059
6059
  }
6060
6060
  }
6061
+ const deepEqual = (x, y) => {
6062
+ if (x === y) {
6063
+ return true;
6064
+ } else if (typeof x == "object" && x != null && typeof y == "object" && y != null) {
6065
+ if (Object.keys(x).length != Object.keys(y).length) return false;
6066
+ for (const prop in x) {
6067
+ if (Object.prototype.hasOwnProperty.call(y, prop)) {
6068
+ if (!deepEqual(x[prop], y[prop])) return false;
6069
+ } else return false;
6070
+ }
6071
+ return true;
6072
+ } else {
6073
+ return false;
6074
+ }
6075
+ };
6061
6076
  const _Feed = class _Feed extends FeedApi {
6062
6077
  constructor(client, groupId, id, data, watch = false, addNewActivitiesTo = "start", activityAddedEventFilter) {
6063
6078
  super(client, groupId, id);
@@ -6165,10 +6180,14 @@ const _Feed = class _Feed extends FeedApi {
6165
6180
  async synchronize() {
6166
6181
  const { last_get_or_create_request_config } = this.state.getLatestValue();
6167
6182
  if (last_get_or_create_request_config?.watch) {
6183
+ this.inProgressGetOrCreate = void 0;
6168
6184
  await this.getOrCreate(last_get_or_create_request_config);
6169
6185
  }
6170
6186
  }
6171
6187
  async getOrCreate(request) {
6188
+ if (!request?.next && this.inProgressGetOrCreate && deepEqual(request, this.inProgressGetOrCreate.request)) {
6189
+ return this.inProgressGetOrCreate.promise;
6190
+ }
6172
6191
  if (this.currentState.is_loading_activities) {
6173
6192
  throw new Error("Only one getOrCreate call is allowed at a time");
6174
6193
  }
@@ -6177,7 +6196,11 @@ const _Feed = class _Feed extends FeedApi {
6177
6196
  is_loading_activities: true
6178
6197
  });
6179
6198
  try {
6180
- const response = await super.getOrCreate(request);
6199
+ const responsePromise = super.getOrCreate(request);
6200
+ if (!request?.next) {
6201
+ this.inProgressGetOrCreate = { request, promise: responsePromise };
6202
+ }
6203
+ const response = await responsePromise;
6181
6204
  const currentActivityFeeds = [];
6182
6205
  for (const activity of response.activities) {
6183
6206
  if (activity.current_feed) {
@@ -6249,6 +6272,9 @@ const _Feed = class _Feed extends FeedApi {
6249
6272
  is_loading: false,
6250
6273
  is_loading_activities: false
6251
6274
  });
6275
+ if (!request?.next) {
6276
+ this.inProgressGetOrCreate = void 0;
6277
+ }
6252
6278
  }
6253
6279
  }
6254
6280
  /**
@@ -7313,4 +7339,4 @@ export {
7313
7339
  shouldUpdateState as s,
7314
7340
  uniqueArrayMerge as u
7315
7341
  };
7316
- //# sourceMappingURL=feeds-client-0zVMEzPX.mjs.map
7342
+ //# sourceMappingURL=feeds-client-Cd2LsXp-.mjs.map