@stream-io/feeds-client 0.3.17 → 0.3.18

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.
@@ -3914,7 +3914,7 @@ const getRateLimitFromResponseHeader = (response_headers) => {
3914
3914
  };
3915
3915
  return result;
3916
3916
  };
3917
- const version = "0.3.17";
3917
+ const version = "0.3.18";
3918
3918
  class ApiClient {
3919
3919
  constructor(apiKey, tokenManager, connectionIdManager, options) {
3920
3920
  this.apiKey = apiKey;
@@ -5279,13 +5279,10 @@ const sharedUpdateActivity$6 = ({
5279
5279
  if (eventBelongsToCurrentUser) {
5280
5280
  newOwnBookmarks = [...newOwnBookmarks, event.bookmark];
5281
5281
  }
5282
- if (!event.bookmark.activity.current_feed && event.bookmark.activity.feeds.length === 1 && currentActivity.current_feed) {
5283
- event.bookmark.activity.current_feed = currentActivity.current_feed;
5284
- }
5285
5282
  return {
5286
- ...event.bookmark.activity,
5287
- own_bookmarks: newOwnBookmarks,
5288
- own_reactions: currentActivity.own_reactions
5283
+ ...currentActivity,
5284
+ bookmark_count: event.bookmark.activity.bookmark_count,
5285
+ own_bookmarks: newOwnBookmarks
5289
5286
  };
5290
5287
  };
5291
5288
  const addBookmarkToActivities = (event, activities, eventBelongsToCurrentUser) => updateEntityInArray({
@@ -5355,13 +5352,10 @@ const sharedUpdateActivity$5 = ({
5355
5352
  (bookmark) => !isSameBookmark(bookmark, event.bookmark)
5356
5353
  );
5357
5354
  }
5358
- if (!event.bookmark.activity.current_feed && event.bookmark.activity.feeds.length === 1 && currentActivity.current_feed) {
5359
- event.bookmark.activity.current_feed = currentActivity.current_feed;
5360
- }
5361
5355
  return {
5362
- ...event.bookmark.activity,
5363
- own_bookmarks: newOwnBookmarks,
5364
- own_reactions: currentActivity.own_reactions
5356
+ ...currentActivity,
5357
+ bookmark_count: event.bookmark.activity.bookmark_count,
5358
+ own_bookmarks: newOwnBookmarks
5365
5359
  };
5366
5360
  };
5367
5361
  const removeBookmarkFromActivities = (event, activities, eventBelongsToCurrentUser) => updateEntityInArray({
@@ -5433,9 +5427,9 @@ const sharedUpdateActivity$4 = ({
5433
5427
  }
5434
5428
  }
5435
5429
  return {
5436
- ...event.bookmark.activity,
5437
- own_bookmarks: newOwnBookmarks,
5438
- own_reactions: currentActivity.own_reactions
5430
+ ...currentActivity,
5431
+ bookmark_count: event.bookmark.activity.bookmark_count,
5432
+ own_bookmarks: newOwnBookmarks
5439
5433
  };
5440
5434
  };
5441
5435
  const updateBookmarkInActivities = (event, activities, eventBelongsToCurrentUser) => updateEntityInArray({
@@ -5593,9 +5587,6 @@ const updateActivity = ({
5593
5587
  currentActivity,
5594
5588
  newActivtiy
5595
5589
  }) => {
5596
- if (!newActivtiy.current_feed && newActivtiy.feeds.length === 1 && currentActivity.current_feed) {
5597
- newActivtiy.current_feed = currentActivity.current_feed;
5598
- }
5599
5590
  return {
5600
5591
  ...newActivtiy,
5601
5592
  own_reactions: currentActivity.own_reactions,
@@ -5645,12 +5636,6 @@ function handleActivityUpdated(payload, fromWs) {
5645
5636
  activities: currentActivities,
5646
5637
  pinned_activities: currentPinnedActivities
5647
5638
  } = this.currentState;
5648
- const currentActivity = currentActivities?.find(
5649
- (a) => a.id === payload.activity.id
5650
- );
5651
- if (!payload.activity.current_feed && payload.activity.feeds.length === 1 && currentActivity?.current_feed) {
5652
- payload.activity.current_feed = currentActivity.current_feed;
5653
- }
5654
5639
  const [result1, result2] = [
5655
5640
  this.hasActivity(payload.activity.id) ? updateActivityInState(payload, currentActivities) : void 0,
5656
5641
  updatePinnedActivityInState(payload, currentPinnedActivities)
@@ -6814,6 +6799,19 @@ const _Feed = class _Feed extends FeedApi {
6814
6799
  handleWSEvent(event) {
6815
6800
  const eventHandler = this.eventHandlers[event.type];
6816
6801
  if (eventHandler !== _Feed.noop) {
6802
+ if ("activity" in event && this.hasActivity(event.activity.id)) {
6803
+ const currentActivity = this.currentState.activities?.find(
6804
+ (a) => a.id === event.activity.id
6805
+ );
6806
+ if (event.activity.feeds.length > 1 && !event.activity.current_feed && currentActivity?.current_feed) {
6807
+ event.activity.current_feed = currentActivity.current_feed;
6808
+ }
6809
+ if (event.activity.feeds.length === 1 && event.activity.current_feed && currentActivity?.current_feed) {
6810
+ event.activity.current_feed.own_capabilities = currentActivity.current_feed.own_capabilities;
6811
+ event.activity.current_feed.own_follows = currentActivity.current_feed.own_follows;
6812
+ event.activity.current_feed.own_membership = currentActivity.current_feed.own_membership;
6813
+ }
6814
+ }
6817
6815
  eventHandler?.(event);
6818
6816
  }
6819
6817
  if (typeof eventHandler === "undefined") {
@@ -7750,4 +7748,4 @@ export {
7750
7748
  shouldUpdateState as s,
7751
7749
  uniqueArrayMerge as u
7752
7750
  };
7753
- //# sourceMappingURL=feeds-client-Bq_SWnZW.mjs.map
7751
+ //# sourceMappingURL=feeds-client-DT_p8LU4.mjs.map