@stream-io/feeds-client 0.2.15 → 0.2.17

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 (43) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/index.js +1 -1
  3. package/dist/cjs/react-bindings.js +1 -1
  4. package/dist/es/index.mjs +2 -2
  5. package/dist/es/react-bindings.mjs +1 -1
  6. package/dist/{index-BSzSBlMh.mjs → index-BZL77zNq.mjs} +184 -27
  7. package/dist/index-BZL77zNq.mjs.map +1 -0
  8. package/dist/{index-DRX66SIx.js → index-nq6SDtbt.js} +184 -27
  9. package/dist/index-nq6SDtbt.js.map +1 -0
  10. package/dist/tsconfig.tsbuildinfo +1 -1
  11. package/dist/types/feed/event-handlers/activity/handle-activity-reaction-updated.d.ts +14 -0
  12. package/dist/types/feed/event-handlers/activity/handle-activity-reaction-updated.d.ts.map +1 -0
  13. package/dist/types/feed/event-handlers/activity/index.d.ts +1 -0
  14. package/dist/types/feed/event-handlers/activity/index.d.ts.map +1 -1
  15. package/dist/types/feed/event-handlers/comment/handle-comment-reaction-added.d.ts.map +1 -1
  16. package/dist/types/feed/event-handlers/comment/handle-comment-reaction-updated.d.ts +6 -0
  17. package/dist/types/feed/event-handlers/comment/handle-comment-reaction-updated.d.ts.map +1 -0
  18. package/dist/types/feed/event-handlers/comment/index.d.ts +1 -0
  19. package/dist/types/feed/event-handlers/comment/index.d.ts.map +1 -1
  20. package/dist/types/feed/feed.d.ts.map +1 -1
  21. package/dist/types/feeds-client/feeds-client.d.ts.map +1 -1
  22. package/dist/types/gen/feeds/FeedsApi.d.ts +4 -1
  23. package/dist/types/gen/feeds/FeedsApi.d.ts.map +1 -1
  24. package/dist/types/gen/models/index.d.ts +7 -0
  25. package/dist/types/gen/models/index.d.ts.map +1 -1
  26. package/dist/types/utils/state-update-queue.d.ts +5 -1
  27. package/dist/types/utils/state-update-queue.d.ts.map +1 -1
  28. package/package.json +1 -1
  29. package/src/feed/event-handlers/activity/handle-activity-reaction-updated.test.ts +282 -0
  30. package/src/feed/event-handlers/activity/handle-activity-reaction-updated.ts +140 -0
  31. package/src/feed/event-handlers/activity/index.ts +1 -0
  32. package/src/feed/event-handlers/comment/handle-comment-reaction-added.ts +1 -2
  33. package/src/feed/event-handlers/comment/handle-comment-reaction-updated.test.ts +350 -0
  34. package/src/feed/event-handlers/comment/handle-comment-reaction-updated.ts +72 -0
  35. package/src/feed/event-handlers/comment/index.ts +1 -1
  36. package/src/feed/feed.ts +4 -2
  37. package/src/feeds-client/feeds-client.ts +15 -3
  38. package/src/gen/feeds/FeedsApi.ts +28 -0
  39. package/src/gen/models/index.ts +10 -0
  40. package/src/test-utils/response-generators.ts +52 -0
  41. package/src/utils/state-update-queue.ts +14 -2
  42. package/dist/index-BSzSBlMh.mjs.map +0 -1
  43. package/dist/index-DRX66SIx.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,26 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [0.2.17](https://github.com/GetStream/stream-feeds-js/compare/@stream-io/feeds-client-0.2.16...@stream-io/feeds-client-0.2.17) (2025-10-09)
6
+
7
+
8
+ ### Features
9
+
10
+ * add support for unique reactions ([#130](https://github.com/GetStream/stream-feeds-js/issues/130)) ([004722f](https://github.com/GetStream/stream-feeds-js/commit/004722f9b369f1e3757de9aaf41b17b24107832a))
11
+ * new aggregation format for notifications ([#131](https://github.com/GetStream/stream-feeds-js/issues/131)) ([318f5f5](https://github.com/GetStream/stream-feeds-js/commit/318f5f53b7a422c9815546de4a2af439565397b8))
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * Change response to FeedOwnCapability instead of string ([#135](https://github.com/GetStream/stream-feeds-js/issues/135)) ([c45b38a](https://github.com/GetStream/stream-feeds-js/commit/c45b38a1b638e1a208dc4e70abd5a130cf63f7e2))
17
+
18
+ ## [0.2.16](https://github.com/GetStream/stream-feeds-js/compare/@stream-io/feeds-client-0.2.15...@stream-io/feeds-client-0.2.16) (2025-10-07)
19
+
20
+
21
+ ### Features
22
+
23
+ * New own_capabilities batch endpoint ([#134](https://github.com/GetStream/stream-feeds-js/issues/134)) ([973f297](https://github.com/GetStream/stream-feeds-js/commit/973f297d74e073ecde7f0acb64b14466b0fb4726))
24
+
5
25
  ## [0.2.15](https://github.com/GetStream/stream-feeds-js/compare/@stream-io/feeds-client-0.2.14...@stream-io/feeds-client-0.2.15) (2025-10-02)
6
26
 
7
27
 
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 index = require("../index-DRX66SIx.js");
4
+ const index = require("../index-nq6SDtbt.js");
5
5
  const loggerInternal = require("@stream-io/logger");
6
6
  class SearchController {
7
7
  constructor({ config, sources } = {}) {
@@ -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 index = require("../index-DRX66SIx.js");
5
+ const index = require("../index-nq6SDtbt.js");
6
6
  require("@stream-io/logger");
7
7
  require("axios");
8
8
  var shim = { exports: {} };
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 "../index-BSzSBlMh.mjs";
4
- import { C, f, a, b, F, S, c, e, o, q, p, m, j, g, k, h, l, i, r, s, u, n } from "../index-BSzSBlMh.mjs";
3
+ import { d as debounce } from "../index-BZL77zNq.mjs";
4
+ import { C, f, a, b, F, S, c, e, o, q, p, m, j, g, k, h, l, i, r, s, u, n } from "../index-BZL77zNq.mjs";
5
5
  import { LogLevelEnum, restoreDefaults } from "@stream-io/logger";
6
6
  class SearchController {
7
7
  constructor({ config, sources } = {}) {
@@ -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, j as isCommentResponse, e as checkHasAnotherPage, b as FeedOwnCapability } from "../index-BSzSBlMh.mjs";
3
+ import { F as FeedsClient, j as isCommentResponse, e as checkHasAnotherPage, b as FeedOwnCapability } from "../index-BZL77zNq.mjs";
4
4
  import "@stream-io/logger";
5
5
  import "axios";
6
6
  var shim = { exports: {} };
@@ -2384,6 +2384,24 @@ class FeedsApi {
2384
2384
  decoders.CreateFeedsBatchResponse?.(response.body);
2385
2385
  return { ...response.body, metadata: response.metadata };
2386
2386
  }
2387
+ async ownCapabilitiesBatch(request) {
2388
+ const queryParams = {
2389
+ connection_id: request?.connection_id
2390
+ };
2391
+ const body = {
2392
+ feeds: request?.feeds
2393
+ };
2394
+ const response = await this.apiClient.sendRequest(
2395
+ "POST",
2396
+ "/api/v2/feeds/feeds/own_capabilities/batch",
2397
+ void 0,
2398
+ queryParams,
2399
+ body,
2400
+ "application/json"
2401
+ );
2402
+ decoders.OwnCapabilitiesBatchResponse?.(response.body);
2403
+ return { ...response.body, metadata: response.metadata };
2404
+ }
2387
2405
  async _queryFeeds(request) {
2388
2406
  const queryParams = {
2389
2407
  connection_id: request?.connection_id
@@ -3704,7 +3722,7 @@ const getRateLimitFromResponseHeader = (response_headers) => {
3704
3722
  };
3705
3723
  return result;
3706
3724
  };
3707
- const version = "0.2.15";
3725
+ const version = "0.2.17";
3708
3726
  class ApiClient {
3709
3727
  constructor(apiKey, tokenManager, connectionIdManager, options) {
3710
3728
  this.apiKey = apiKey;
@@ -4513,14 +4531,16 @@ function getStateUpdateQueueId(...args) {
4513
4531
  return toJoin.concat([data.activity.id]).join("-");
4514
4532
  }
4515
4533
  case "activity-reaction-created":
4516
- case "activity-reaction-deleted": {
4534
+ case "activity-reaction-deleted":
4535
+ case "activity-reaction-updated": {
4517
4536
  return toJoin.concat([
4518
4537
  data.activity.id,
4519
4538
  data.reaction.type
4520
4539
  ]).join("-");
4521
4540
  }
4522
4541
  case "comment-reaction-created":
4523
- case "comment-reaction-deleted": {
4542
+ case "comment-reaction-deleted":
4543
+ case "comment-reaction-updated": {
4524
4544
  return toJoin.concat([
4525
4545
  data.comment.id,
4526
4546
  data.reaction.type
@@ -4880,7 +4900,6 @@ function handleCommentReactionAdded(payload, fromWs) {
4880
4900
  newComments[commentIndex] = {
4881
4901
  ...newComments[commentIndex],
4882
4902
  reaction_count: comment.reaction_count ?? 0,
4883
- // TODO: FIXME this should be handled by the backend
4884
4903
  latest_reactions: comment.latest_reactions ?? [],
4885
4904
  reaction_groups: comment.reaction_groups ?? {},
4886
4905
  own_reactions: ownReactions
@@ -4945,6 +4964,51 @@ function handleCommentReactionDeleted(payload, fromWs) {
4945
4964
  };
4946
4965
  });
4947
4966
  }
4967
+ function handleCommentReactionUpdated(payload, fromWs) {
4968
+ const { comment, reaction } = payload;
4969
+ const connectedUser = this.client.state.getLatestValue().connected_user;
4970
+ const isOwnReaction = reaction.user.id === connectedUser?.id;
4971
+ if (!shouldUpdateState({
4972
+ stateUpdateQueueId: getStateUpdateQueueId(
4973
+ payload,
4974
+ "comment-reaction-updated"
4975
+ ),
4976
+ stateUpdateQueue: this.stateUpdateQueue,
4977
+ watch: this.currentState.watch,
4978
+ fromWs,
4979
+ isTriggeredByConnectedUser: isOwnReaction
4980
+ })) {
4981
+ return;
4982
+ }
4983
+ this.state.next((currentState) => {
4984
+ const commentIndex = this.getCommentIndex(comment, currentState);
4985
+ if (commentIndex === -1) return currentState;
4986
+ const forId = comment.parent_id ?? comment.object_id;
4987
+ const entityState = currentState.comments_by_entity_id[forId];
4988
+ const newComments = entityState?.comments?.concat([]) ?? [];
4989
+ let ownReactions = newComments[commentIndex].own_reactions;
4990
+ if (isOwnReaction) {
4991
+ ownReactions = [reaction];
4992
+ }
4993
+ newComments[commentIndex] = {
4994
+ ...newComments[commentIndex],
4995
+ reaction_count: comment.reaction_count ?? 0,
4996
+ latest_reactions: comment.latest_reactions ?? [],
4997
+ reaction_groups: comment.reaction_groups ?? {},
4998
+ own_reactions: ownReactions
4999
+ };
5000
+ return {
5001
+ ...currentState,
5002
+ comments_by_entity_id: {
5003
+ ...currentState.comments_by_entity_id,
5004
+ [forId]: {
5005
+ ...entityState,
5006
+ comments: newComments
5007
+ }
5008
+ }
5009
+ };
5010
+ });
5011
+ }
4948
5012
  function handleFeedMemberAdded(event) {
4949
5013
  const { connected_user: connectedUser } = this.client.state.getLatestValue();
4950
5014
  this.state.next((currentState) => {
@@ -5008,7 +5072,7 @@ function handleFeedMemberRemoved(event) {
5008
5072
  return newState ?? currentState;
5009
5073
  });
5010
5074
  }
5011
- const sharedUpdateActivity$5 = ({
5075
+ const sharedUpdateActivity$6 = ({
5012
5076
  currentActivity,
5013
5077
  event,
5014
5078
  eventBelongsToCurrentUser
@@ -5026,7 +5090,7 @@ const sharedUpdateActivity$5 = ({
5026
5090
  const addBookmarkToActivities = (event, activities, eventBelongsToCurrentUser) => updateEntityInArray({
5027
5091
  entities: activities,
5028
5092
  matcher: (activity) => activity.id === event.bookmark.activity.id,
5029
- updater: (matchedActivity) => sharedUpdateActivity$5({
5093
+ updater: (matchedActivity) => sharedUpdateActivity$6({
5030
5094
  currentActivity: matchedActivity,
5031
5095
  event,
5032
5096
  eventBelongsToCurrentUser
@@ -5036,7 +5100,7 @@ const addBookmarkToPinnedActivities = (event, pinnedActivities, eventBelongsToCu
5036
5100
  entities: pinnedActivities,
5037
5101
  matcher: (pinnedActivity) => pinnedActivity.activity.id === event.bookmark.activity.id,
5038
5102
  updater: (matchedPinnedActivity) => {
5039
- const newActivity = sharedUpdateActivity$5({
5103
+ const newActivity = sharedUpdateActivity$6({
5040
5104
  currentActivity: matchedPinnedActivity.activity,
5041
5105
  event,
5042
5106
  eventBelongsToCurrentUser
@@ -5079,7 +5143,7 @@ function handleBookmarkAdded(event) {
5079
5143
  const isSameBookmark = (bookmark1, bookmark2) => {
5080
5144
  return bookmark1.user.id === bookmark2.user.id && bookmark1.activity.id === bookmark2.activity.id && bookmark1.folder?.id === bookmark2.folder?.id;
5081
5145
  };
5082
- const sharedUpdateActivity$4 = ({
5146
+ const sharedUpdateActivity$5 = ({
5083
5147
  currentActivity,
5084
5148
  event,
5085
5149
  eventBelongsToCurrentUser
@@ -5099,7 +5163,7 @@ const sharedUpdateActivity$4 = ({
5099
5163
  const removeBookmarkFromActivities = (event, activities, eventBelongsToCurrentUser) => updateEntityInArray({
5100
5164
  entities: activities,
5101
5165
  matcher: (activity) => activity.id === event.bookmark.activity.id,
5102
- updater: (matchedActivity) => sharedUpdateActivity$4({
5166
+ updater: (matchedActivity) => sharedUpdateActivity$5({
5103
5167
  currentActivity: matchedActivity,
5104
5168
  event,
5105
5169
  eventBelongsToCurrentUser
@@ -5109,7 +5173,7 @@ const removeBookmarkFromPinnedActivities = (event, pinnedActivities, eventBelong
5109
5173
  entities: pinnedActivities,
5110
5174
  matcher: (pinnedActivity) => pinnedActivity.activity.id === event.bookmark.activity.id,
5111
5175
  updater: (matchedPinnedActivity) => {
5112
- const newActivity = sharedUpdateActivity$4({
5176
+ const newActivity = sharedUpdateActivity$5({
5113
5177
  currentActivity: matchedPinnedActivity.activity,
5114
5178
  event,
5115
5179
  eventBelongsToCurrentUser
@@ -5149,7 +5213,7 @@ function handleBookmarkDeleted(event) {
5149
5213
  });
5150
5214
  }
5151
5215
  }
5152
- const sharedUpdateActivity$3 = ({
5216
+ const sharedUpdateActivity$4 = ({
5153
5217
  currentActivity,
5154
5218
  event,
5155
5219
  eventBelongsToCurrentUser
@@ -5173,7 +5237,7 @@ const sharedUpdateActivity$3 = ({
5173
5237
  const updateBookmarkInActivities = (event, activities, eventBelongsToCurrentUser) => updateEntityInArray({
5174
5238
  entities: activities,
5175
5239
  matcher: (activity) => activity.id === event.bookmark.activity.id,
5176
- updater: (matchedActivity) => sharedUpdateActivity$3({
5240
+ updater: (matchedActivity) => sharedUpdateActivity$4({
5177
5241
  currentActivity: matchedActivity,
5178
5242
  event,
5179
5243
  eventBelongsToCurrentUser
@@ -5183,7 +5247,7 @@ const updateBookmarkInPinnedActivities = (event, pinnedActivities, eventBelongsT
5183
5247
  entities: pinnedActivities,
5184
5248
  matcher: (pinnedActivity) => pinnedActivity.activity.id === event.bookmark.activity.id,
5185
5249
  updater: (matchedPinnedActivity) => {
5186
- const newActivity = sharedUpdateActivity$3({
5250
+ const newActivity = sharedUpdateActivity$4({
5187
5251
  currentActivity: matchedPinnedActivity.activity,
5188
5252
  event,
5189
5253
  eventBelongsToCurrentUser
@@ -5314,7 +5378,7 @@ function handleActivityRemovedFromFeed(event) {
5314
5378
  }
5315
5379
  }
5316
5380
  }
5317
- const sharedUpdateActivity$2 = ({
5381
+ const sharedUpdateActivity$3 = ({
5318
5382
  currentActivity,
5319
5383
  event
5320
5384
  }) => {
@@ -5327,7 +5391,7 @@ const sharedUpdateActivity$2 = ({
5327
5391
  const updateActivityInState = (event, activities) => updateEntityInArray({
5328
5392
  entities: activities,
5329
5393
  matcher: (activity) => activity.id === event.activity.id,
5330
- updater: (matchedActivity) => sharedUpdateActivity$2({
5394
+ updater: (matchedActivity) => sharedUpdateActivity$3({
5331
5395
  currentActivity: matchedActivity,
5332
5396
  event
5333
5397
  })
@@ -5336,7 +5400,7 @@ const updatePinnedActivityInState = (event, pinnedActivities) => updateEntityInA
5336
5400
  entities: pinnedActivities,
5337
5401
  matcher: (pinnedActivity) => pinnedActivity.activity.id === event.activity.id,
5338
5402
  updater: (matchedPinnedActivity) => {
5339
- const newActivity = sharedUpdateActivity$2({
5403
+ const newActivity = sharedUpdateActivity$3({
5340
5404
  currentActivity: matchedPinnedActivity.activity,
5341
5405
  event
5342
5406
  });
@@ -5378,7 +5442,7 @@ function handleActivityUpdated(payload, fromWs) {
5378
5442
  });
5379
5443
  }
5380
5444
  }
5381
- const sharedUpdateActivity$1 = ({
5445
+ const sharedUpdateActivity$2 = ({
5382
5446
  payload,
5383
5447
  currentActivity,
5384
5448
  eventBelongsToCurrentUser
@@ -5399,7 +5463,7 @@ const sharedUpdateActivity$1 = ({
5399
5463
  const addReactionToActivities = (payload, activities, eventBelongsToCurrentUser) => updateEntityInArray({
5400
5464
  entities: activities,
5401
5465
  matcher: (activity) => activity.id === payload.activity.id,
5402
- updater: (matchedActivity) => sharedUpdateActivity$1({
5466
+ updater: (matchedActivity) => sharedUpdateActivity$2({
5403
5467
  payload,
5404
5468
  currentActivity: matchedActivity,
5405
5469
  eventBelongsToCurrentUser
@@ -5409,7 +5473,7 @@ const addReactionToPinnedActivities = (payload, pinnedActivities, eventBelongsTo
5409
5473
  entities: pinnedActivities,
5410
5474
  matcher: (pinnedActivity) => pinnedActivity.activity.id === payload.activity.id,
5411
5475
  updater: (matchedPinnedActivity) => {
5412
- const updatedActivity = sharedUpdateActivity$1({
5476
+ const updatedActivity = sharedUpdateActivity$2({
5413
5477
  payload,
5414
5478
  currentActivity: matchedPinnedActivity.activity,
5415
5479
  eventBelongsToCurrentUser
@@ -5461,7 +5525,7 @@ function handleActivityReactionAdded(payload, fromWs) {
5461
5525
  });
5462
5526
  }
5463
5527
  }
5464
- const sharedUpdateActivity = ({
5528
+ const sharedUpdateActivity$1 = ({
5465
5529
  currentActivity,
5466
5530
  payload,
5467
5531
  eventBelongsToCurrentUser
@@ -5484,7 +5548,7 @@ const sharedUpdateActivity = ({
5484
5548
  const removeReactionFromActivities = (payload, activities, eventBelongsToCurrentUser) => updateEntityInArray({
5485
5549
  entities: activities,
5486
5550
  matcher: (activity) => activity.id === payload.activity.id,
5487
- updater: (matchedActivity) => sharedUpdateActivity({
5551
+ updater: (matchedActivity) => sharedUpdateActivity$1({
5488
5552
  currentActivity: matchedActivity,
5489
5553
  payload,
5490
5554
  eventBelongsToCurrentUser
@@ -5494,7 +5558,7 @@ const removeReactionFromPinnedActivities = (payload, activities, eventBelongsToC
5494
5558
  entities: activities,
5495
5559
  matcher: (pinnedActivity) => pinnedActivity.activity.id === payload.activity.id,
5496
5560
  updater: (matchedPinnedActivity) => {
5497
- const newActivity = sharedUpdateActivity({
5561
+ const newActivity = sharedUpdateActivity$1({
5498
5562
  currentActivity: matchedPinnedActivity.activity,
5499
5563
  payload,
5500
5564
  eventBelongsToCurrentUser
@@ -5546,6 +5610,89 @@ function handleActivityReactionDeleted(payload, fromWs) {
5546
5610
  });
5547
5611
  }
5548
5612
  }
5613
+ const sharedUpdateActivity = ({
5614
+ payload,
5615
+ currentActivity,
5616
+ eventBelongsToCurrentUser
5617
+ }) => {
5618
+ const { activity: newActivity, reaction: newReaction } = payload;
5619
+ let ownReactions = currentActivity.own_reactions;
5620
+ if (eventBelongsToCurrentUser) {
5621
+ ownReactions = [newReaction];
5622
+ }
5623
+ return {
5624
+ ...currentActivity,
5625
+ latest_reactions: newActivity.latest_reactions,
5626
+ reaction_groups: newActivity.reaction_groups,
5627
+ reaction_count: newActivity.reaction_count,
5628
+ own_reactions: ownReactions
5629
+ };
5630
+ };
5631
+ const updateReactionInActivities = (payload, activities, eventBelongsToCurrentUser) => updateEntityInArray({
5632
+ entities: activities,
5633
+ matcher: (activity) => activity.id === payload.activity.id,
5634
+ updater: (matchedActivity) => sharedUpdateActivity({
5635
+ payload,
5636
+ currentActivity: matchedActivity,
5637
+ eventBelongsToCurrentUser
5638
+ })
5639
+ });
5640
+ const updateReactionInPinnedActivities = (payload, pinnedActivities, eventBelongsToCurrentUser) => updateEntityInArray({
5641
+ entities: pinnedActivities,
5642
+ matcher: (pinnedActivity) => pinnedActivity.activity.id === payload.activity.id,
5643
+ updater: (matchedPinnedActivity) => {
5644
+ const updatedActivity = sharedUpdateActivity({
5645
+ payload,
5646
+ currentActivity: matchedPinnedActivity.activity,
5647
+ eventBelongsToCurrentUser
5648
+ });
5649
+ if (updatedActivity === matchedPinnedActivity.activity) {
5650
+ return matchedPinnedActivity;
5651
+ }
5652
+ return {
5653
+ ...matchedPinnedActivity,
5654
+ activity: updatedActivity
5655
+ };
5656
+ }
5657
+ });
5658
+ function handleActivityReactionUpdated(payload, fromWs) {
5659
+ const connectedUser = this.client.state.getLatestValue().connected_user;
5660
+ const eventBelongsToCurrentUser = typeof connectedUser !== "undefined" && payload.reaction.user.id === connectedUser.id;
5661
+ if (!shouldUpdateState({
5662
+ stateUpdateQueueId: getStateUpdateQueueId(
5663
+ payload,
5664
+ "activity-reaction-updated"
5665
+ ),
5666
+ stateUpdateQueue: this.stateUpdateQueue,
5667
+ watch: this.currentState.watch,
5668
+ fromWs,
5669
+ isTriggeredByConnectedUser: eventBelongsToCurrentUser
5670
+ })) {
5671
+ return;
5672
+ }
5673
+ const {
5674
+ activities: currentActivities,
5675
+ pinned_activities: currentPinnedActivities
5676
+ } = this.currentState;
5677
+ const [result1, result2] = [
5678
+ this.hasActivity(payload.activity.id) ? updateReactionInActivities(
5679
+ payload,
5680
+ currentActivities,
5681
+ eventBelongsToCurrentUser
5682
+ ) : void 0,
5683
+ updateReactionInPinnedActivities(
5684
+ payload,
5685
+ currentPinnedActivities,
5686
+ eventBelongsToCurrentUser
5687
+ )
5688
+ ];
5689
+ if (result1?.changed || result2.changed) {
5690
+ this.state.partialNext({
5691
+ ...result1 ? { activities: result1.entities } : {},
5692
+ pinned_activities: result2.entities
5693
+ });
5694
+ }
5695
+ }
5549
5696
  const updateNotificationStatusFromActivityMarked = (event, currentNotificationStatus, aggregatedActivities = []) => {
5550
5697
  if (!currentNotificationStatus) {
5551
5698
  return {
@@ -5742,7 +5889,7 @@ const _Feed = class _Feed extends FeedApi {
5742
5889
  "feeds.activity.deleted": handleActivityDeleted.bind(this),
5743
5890
  "feeds.activity.reaction.added": handleActivityReactionAdded.bind(this),
5744
5891
  "feeds.activity.reaction.deleted": handleActivityReactionDeleted.bind(this),
5745
- "feeds.activity.reaction.updated": _Feed.noop,
5892
+ "feeds.activity.reaction.updated": handleActivityReactionUpdated.bind(this),
5746
5893
  "feeds.activity.removed_from_feed": handleActivityRemovedFromFeed.bind(this),
5747
5894
  "feeds.activity.updated": handleActivityUpdated.bind(this),
5748
5895
  "feeds.bookmark.added": handleBookmarkAdded.bind(this),
@@ -5763,7 +5910,7 @@ const _Feed = class _Feed extends FeedApi {
5763
5910
  "feeds.follow.updated": handleFollowUpdated.bind(this),
5764
5911
  "feeds.comment.reaction.added": handleCommentReactionAdded.bind(this),
5765
5912
  "feeds.comment.reaction.deleted": handleCommentReactionDeleted.bind(this),
5766
- "feeds.comment.reaction.updated": _Feed.noop,
5913
+ "feeds.comment.reaction.updated": handleCommentReactionUpdated.bind(this),
5767
5914
  "feeds.feed_member.added": handleFeedMemberAdded.bind(this),
5768
5915
  "feeds.feed_member.removed": handleFeedMemberRemoved.bind(this),
5769
5916
  "feeds.feed_member.updated": handleFeedMemberUpdated.bind(this),
@@ -6457,9 +6604,14 @@ class FeedsClient extends FeedsApi {
6457
6604
  return response;
6458
6605
  };
6459
6606
  this.addActivityReaction = async (request) => {
6607
+ const shouldEnforceUnique = request.enforce_unique;
6460
6608
  const response = await super.addActivityReaction(request);
6461
6609
  for (const feed of Object.values(this.activeFeeds)) {
6462
- handleActivityReactionAdded.bind(feed)(response, false);
6610
+ if (shouldEnforceUnique) {
6611
+ handleActivityReactionUpdated.bind(feed)(response, false);
6612
+ } else {
6613
+ handleActivityReactionAdded.bind(feed)(response, false);
6614
+ }
6463
6615
  }
6464
6616
  return response;
6465
6617
  };
@@ -6474,9 +6626,14 @@ class FeedsClient extends FeedsApi {
6474
6626
  return response;
6475
6627
  };
6476
6628
  this.addCommentReaction = async (request) => {
6629
+ const shouldEnforceUnique = request.enforce_unique;
6477
6630
  const response = await super.addCommentReaction(request);
6478
6631
  for (const feed of Object.values(this.activeFeeds)) {
6479
- handleCommentReactionAdded.bind(feed)(response, false);
6632
+ if (shouldEnforceUnique) {
6633
+ handleCommentReactionUpdated.bind(feed)(response, false);
6634
+ } else {
6635
+ handleCommentReactionAdded.bind(feed)(response, false);
6636
+ }
6480
6637
  }
6481
6638
  return response;
6482
6639
  };
@@ -6846,4 +7003,4 @@ export {
6846
7003
  shouldUpdateState as s,
6847
7004
  uniqueArrayMerge as u
6848
7005
  };
6849
- //# sourceMappingURL=index-BSzSBlMh.mjs.map
7006
+ //# sourceMappingURL=index-BZL77zNq.mjs.map