@stream-io/feeds-client 0.2.16 → 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.
- package/CHANGELOG.md +13 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/react-bindings.js +1 -1
- package/dist/es/index.mjs +2 -2
- package/dist/es/react-bindings.mjs +1 -1
- package/dist/{index-J3MkoYPN.mjs → index-BZL77zNq.mjs} +166 -27
- package/dist/index-BZL77zNq.mjs.map +1 -0
- package/dist/{index-CaFrpjpl.js → index-nq6SDtbt.js} +166 -27
- package/dist/index-nq6SDtbt.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/feed/event-handlers/activity/handle-activity-reaction-updated.d.ts +14 -0
- package/dist/types/feed/event-handlers/activity/handle-activity-reaction-updated.d.ts.map +1 -0
- package/dist/types/feed/event-handlers/activity/index.d.ts +1 -0
- package/dist/types/feed/event-handlers/activity/index.d.ts.map +1 -1
- package/dist/types/feed/event-handlers/comment/handle-comment-reaction-added.d.ts.map +1 -1
- package/dist/types/feed/event-handlers/comment/handle-comment-reaction-updated.d.ts +6 -0
- package/dist/types/feed/event-handlers/comment/handle-comment-reaction-updated.d.ts.map +1 -0
- package/dist/types/feed/event-handlers/comment/index.d.ts +1 -0
- package/dist/types/feed/event-handlers/comment/index.d.ts.map +1 -1
- package/dist/types/feed/feed.d.ts.map +1 -1
- package/dist/types/feeds-client/feeds-client.d.ts.map +1 -1
- package/dist/types/gen/models/index.d.ts +1 -1
- package/dist/types/gen/models/index.d.ts.map +1 -1
- package/dist/types/utils/state-update-queue.d.ts +5 -1
- package/dist/types/utils/state-update-queue.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/feed/event-handlers/activity/handle-activity-reaction-updated.test.ts +282 -0
- package/src/feed/event-handlers/activity/handle-activity-reaction-updated.ts +140 -0
- package/src/feed/event-handlers/activity/index.ts +1 -0
- package/src/feed/event-handlers/comment/handle-comment-reaction-added.ts +1 -2
- package/src/feed/event-handlers/comment/handle-comment-reaction-updated.test.ts +350 -0
- package/src/feed/event-handlers/comment/handle-comment-reaction-updated.ts +72 -0
- package/src/feed/event-handlers/comment/index.ts +1 -1
- package/src/feed/feed.ts +4 -2
- package/src/feeds-client/feeds-client.ts +15 -3
- package/src/gen/models/index.ts +1 -1
- package/src/test-utils/response-generators.ts +52 -0
- package/src/utils/state-update-queue.ts +14 -2
- package/dist/index-CaFrpjpl.js.map +0 -1
- package/dist/index-J3MkoYPN.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
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
|
+
|
|
5
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)
|
|
6
19
|
|
|
7
20
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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: {} };
|
|
@@ -3722,7 +3722,7 @@ const getRateLimitFromResponseHeader = (response_headers) => {
|
|
|
3722
3722
|
};
|
|
3723
3723
|
return result;
|
|
3724
3724
|
};
|
|
3725
|
-
const version = "0.2.
|
|
3725
|
+
const version = "0.2.17";
|
|
3726
3726
|
class ApiClient {
|
|
3727
3727
|
constructor(apiKey, tokenManager, connectionIdManager, options) {
|
|
3728
3728
|
this.apiKey = apiKey;
|
|
@@ -4531,14 +4531,16 @@ function getStateUpdateQueueId(...args) {
|
|
|
4531
4531
|
return toJoin.concat([data.activity.id]).join("-");
|
|
4532
4532
|
}
|
|
4533
4533
|
case "activity-reaction-created":
|
|
4534
|
-
case "activity-reaction-deleted":
|
|
4534
|
+
case "activity-reaction-deleted":
|
|
4535
|
+
case "activity-reaction-updated": {
|
|
4535
4536
|
return toJoin.concat([
|
|
4536
4537
|
data.activity.id,
|
|
4537
4538
|
data.reaction.type
|
|
4538
4539
|
]).join("-");
|
|
4539
4540
|
}
|
|
4540
4541
|
case "comment-reaction-created":
|
|
4541
|
-
case "comment-reaction-deleted":
|
|
4542
|
+
case "comment-reaction-deleted":
|
|
4543
|
+
case "comment-reaction-updated": {
|
|
4542
4544
|
return toJoin.concat([
|
|
4543
4545
|
data.comment.id,
|
|
4544
4546
|
data.reaction.type
|
|
@@ -4898,7 +4900,6 @@ function handleCommentReactionAdded(payload, fromWs) {
|
|
|
4898
4900
|
newComments[commentIndex] = {
|
|
4899
4901
|
...newComments[commentIndex],
|
|
4900
4902
|
reaction_count: comment.reaction_count ?? 0,
|
|
4901
|
-
// TODO: FIXME this should be handled by the backend
|
|
4902
4903
|
latest_reactions: comment.latest_reactions ?? [],
|
|
4903
4904
|
reaction_groups: comment.reaction_groups ?? {},
|
|
4904
4905
|
own_reactions: ownReactions
|
|
@@ -4963,6 +4964,51 @@ function handleCommentReactionDeleted(payload, fromWs) {
|
|
|
4963
4964
|
};
|
|
4964
4965
|
});
|
|
4965
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
|
+
}
|
|
4966
5012
|
function handleFeedMemberAdded(event) {
|
|
4967
5013
|
const { connected_user: connectedUser } = this.client.state.getLatestValue();
|
|
4968
5014
|
this.state.next((currentState) => {
|
|
@@ -5026,7 +5072,7 @@ function handleFeedMemberRemoved(event) {
|
|
|
5026
5072
|
return newState ?? currentState;
|
|
5027
5073
|
});
|
|
5028
5074
|
}
|
|
5029
|
-
const sharedUpdateActivity$
|
|
5075
|
+
const sharedUpdateActivity$6 = ({
|
|
5030
5076
|
currentActivity,
|
|
5031
5077
|
event,
|
|
5032
5078
|
eventBelongsToCurrentUser
|
|
@@ -5044,7 +5090,7 @@ const sharedUpdateActivity$5 = ({
|
|
|
5044
5090
|
const addBookmarkToActivities = (event, activities, eventBelongsToCurrentUser) => updateEntityInArray({
|
|
5045
5091
|
entities: activities,
|
|
5046
5092
|
matcher: (activity) => activity.id === event.bookmark.activity.id,
|
|
5047
|
-
updater: (matchedActivity) => sharedUpdateActivity$
|
|
5093
|
+
updater: (matchedActivity) => sharedUpdateActivity$6({
|
|
5048
5094
|
currentActivity: matchedActivity,
|
|
5049
5095
|
event,
|
|
5050
5096
|
eventBelongsToCurrentUser
|
|
@@ -5054,7 +5100,7 @@ const addBookmarkToPinnedActivities = (event, pinnedActivities, eventBelongsToCu
|
|
|
5054
5100
|
entities: pinnedActivities,
|
|
5055
5101
|
matcher: (pinnedActivity) => pinnedActivity.activity.id === event.bookmark.activity.id,
|
|
5056
5102
|
updater: (matchedPinnedActivity) => {
|
|
5057
|
-
const newActivity = sharedUpdateActivity$
|
|
5103
|
+
const newActivity = sharedUpdateActivity$6({
|
|
5058
5104
|
currentActivity: matchedPinnedActivity.activity,
|
|
5059
5105
|
event,
|
|
5060
5106
|
eventBelongsToCurrentUser
|
|
@@ -5097,7 +5143,7 @@ function handleBookmarkAdded(event) {
|
|
|
5097
5143
|
const isSameBookmark = (bookmark1, bookmark2) => {
|
|
5098
5144
|
return bookmark1.user.id === bookmark2.user.id && bookmark1.activity.id === bookmark2.activity.id && bookmark1.folder?.id === bookmark2.folder?.id;
|
|
5099
5145
|
};
|
|
5100
|
-
const sharedUpdateActivity$
|
|
5146
|
+
const sharedUpdateActivity$5 = ({
|
|
5101
5147
|
currentActivity,
|
|
5102
5148
|
event,
|
|
5103
5149
|
eventBelongsToCurrentUser
|
|
@@ -5117,7 +5163,7 @@ const sharedUpdateActivity$4 = ({
|
|
|
5117
5163
|
const removeBookmarkFromActivities = (event, activities, eventBelongsToCurrentUser) => updateEntityInArray({
|
|
5118
5164
|
entities: activities,
|
|
5119
5165
|
matcher: (activity) => activity.id === event.bookmark.activity.id,
|
|
5120
|
-
updater: (matchedActivity) => sharedUpdateActivity$
|
|
5166
|
+
updater: (matchedActivity) => sharedUpdateActivity$5({
|
|
5121
5167
|
currentActivity: matchedActivity,
|
|
5122
5168
|
event,
|
|
5123
5169
|
eventBelongsToCurrentUser
|
|
@@ -5127,7 +5173,7 @@ const removeBookmarkFromPinnedActivities = (event, pinnedActivities, eventBelong
|
|
|
5127
5173
|
entities: pinnedActivities,
|
|
5128
5174
|
matcher: (pinnedActivity) => pinnedActivity.activity.id === event.bookmark.activity.id,
|
|
5129
5175
|
updater: (matchedPinnedActivity) => {
|
|
5130
|
-
const newActivity = sharedUpdateActivity$
|
|
5176
|
+
const newActivity = sharedUpdateActivity$5({
|
|
5131
5177
|
currentActivity: matchedPinnedActivity.activity,
|
|
5132
5178
|
event,
|
|
5133
5179
|
eventBelongsToCurrentUser
|
|
@@ -5167,7 +5213,7 @@ function handleBookmarkDeleted(event) {
|
|
|
5167
5213
|
});
|
|
5168
5214
|
}
|
|
5169
5215
|
}
|
|
5170
|
-
const sharedUpdateActivity$
|
|
5216
|
+
const sharedUpdateActivity$4 = ({
|
|
5171
5217
|
currentActivity,
|
|
5172
5218
|
event,
|
|
5173
5219
|
eventBelongsToCurrentUser
|
|
@@ -5191,7 +5237,7 @@ const sharedUpdateActivity$3 = ({
|
|
|
5191
5237
|
const updateBookmarkInActivities = (event, activities, eventBelongsToCurrentUser) => updateEntityInArray({
|
|
5192
5238
|
entities: activities,
|
|
5193
5239
|
matcher: (activity) => activity.id === event.bookmark.activity.id,
|
|
5194
|
-
updater: (matchedActivity) => sharedUpdateActivity$
|
|
5240
|
+
updater: (matchedActivity) => sharedUpdateActivity$4({
|
|
5195
5241
|
currentActivity: matchedActivity,
|
|
5196
5242
|
event,
|
|
5197
5243
|
eventBelongsToCurrentUser
|
|
@@ -5201,7 +5247,7 @@ const updateBookmarkInPinnedActivities = (event, pinnedActivities, eventBelongsT
|
|
|
5201
5247
|
entities: pinnedActivities,
|
|
5202
5248
|
matcher: (pinnedActivity) => pinnedActivity.activity.id === event.bookmark.activity.id,
|
|
5203
5249
|
updater: (matchedPinnedActivity) => {
|
|
5204
|
-
const newActivity = sharedUpdateActivity$
|
|
5250
|
+
const newActivity = sharedUpdateActivity$4({
|
|
5205
5251
|
currentActivity: matchedPinnedActivity.activity,
|
|
5206
5252
|
event,
|
|
5207
5253
|
eventBelongsToCurrentUser
|
|
@@ -5332,7 +5378,7 @@ function handleActivityRemovedFromFeed(event) {
|
|
|
5332
5378
|
}
|
|
5333
5379
|
}
|
|
5334
5380
|
}
|
|
5335
|
-
const sharedUpdateActivity$
|
|
5381
|
+
const sharedUpdateActivity$3 = ({
|
|
5336
5382
|
currentActivity,
|
|
5337
5383
|
event
|
|
5338
5384
|
}) => {
|
|
@@ -5345,7 +5391,7 @@ const sharedUpdateActivity$2 = ({
|
|
|
5345
5391
|
const updateActivityInState = (event, activities) => updateEntityInArray({
|
|
5346
5392
|
entities: activities,
|
|
5347
5393
|
matcher: (activity) => activity.id === event.activity.id,
|
|
5348
|
-
updater: (matchedActivity) => sharedUpdateActivity$
|
|
5394
|
+
updater: (matchedActivity) => sharedUpdateActivity$3({
|
|
5349
5395
|
currentActivity: matchedActivity,
|
|
5350
5396
|
event
|
|
5351
5397
|
})
|
|
@@ -5354,7 +5400,7 @@ const updatePinnedActivityInState = (event, pinnedActivities) => updateEntityInA
|
|
|
5354
5400
|
entities: pinnedActivities,
|
|
5355
5401
|
matcher: (pinnedActivity) => pinnedActivity.activity.id === event.activity.id,
|
|
5356
5402
|
updater: (matchedPinnedActivity) => {
|
|
5357
|
-
const newActivity = sharedUpdateActivity$
|
|
5403
|
+
const newActivity = sharedUpdateActivity$3({
|
|
5358
5404
|
currentActivity: matchedPinnedActivity.activity,
|
|
5359
5405
|
event
|
|
5360
5406
|
});
|
|
@@ -5396,7 +5442,7 @@ function handleActivityUpdated(payload, fromWs) {
|
|
|
5396
5442
|
});
|
|
5397
5443
|
}
|
|
5398
5444
|
}
|
|
5399
|
-
const sharedUpdateActivity$
|
|
5445
|
+
const sharedUpdateActivity$2 = ({
|
|
5400
5446
|
payload,
|
|
5401
5447
|
currentActivity,
|
|
5402
5448
|
eventBelongsToCurrentUser
|
|
@@ -5417,7 +5463,7 @@ const sharedUpdateActivity$1 = ({
|
|
|
5417
5463
|
const addReactionToActivities = (payload, activities, eventBelongsToCurrentUser) => updateEntityInArray({
|
|
5418
5464
|
entities: activities,
|
|
5419
5465
|
matcher: (activity) => activity.id === payload.activity.id,
|
|
5420
|
-
updater: (matchedActivity) => sharedUpdateActivity$
|
|
5466
|
+
updater: (matchedActivity) => sharedUpdateActivity$2({
|
|
5421
5467
|
payload,
|
|
5422
5468
|
currentActivity: matchedActivity,
|
|
5423
5469
|
eventBelongsToCurrentUser
|
|
@@ -5427,7 +5473,7 @@ const addReactionToPinnedActivities = (payload, pinnedActivities, eventBelongsTo
|
|
|
5427
5473
|
entities: pinnedActivities,
|
|
5428
5474
|
matcher: (pinnedActivity) => pinnedActivity.activity.id === payload.activity.id,
|
|
5429
5475
|
updater: (matchedPinnedActivity) => {
|
|
5430
|
-
const updatedActivity = sharedUpdateActivity$
|
|
5476
|
+
const updatedActivity = sharedUpdateActivity$2({
|
|
5431
5477
|
payload,
|
|
5432
5478
|
currentActivity: matchedPinnedActivity.activity,
|
|
5433
5479
|
eventBelongsToCurrentUser
|
|
@@ -5479,7 +5525,7 @@ function handleActivityReactionAdded(payload, fromWs) {
|
|
|
5479
5525
|
});
|
|
5480
5526
|
}
|
|
5481
5527
|
}
|
|
5482
|
-
const sharedUpdateActivity = ({
|
|
5528
|
+
const sharedUpdateActivity$1 = ({
|
|
5483
5529
|
currentActivity,
|
|
5484
5530
|
payload,
|
|
5485
5531
|
eventBelongsToCurrentUser
|
|
@@ -5502,7 +5548,7 @@ const sharedUpdateActivity = ({
|
|
|
5502
5548
|
const removeReactionFromActivities = (payload, activities, eventBelongsToCurrentUser) => updateEntityInArray({
|
|
5503
5549
|
entities: activities,
|
|
5504
5550
|
matcher: (activity) => activity.id === payload.activity.id,
|
|
5505
|
-
updater: (matchedActivity) => sharedUpdateActivity({
|
|
5551
|
+
updater: (matchedActivity) => sharedUpdateActivity$1({
|
|
5506
5552
|
currentActivity: matchedActivity,
|
|
5507
5553
|
payload,
|
|
5508
5554
|
eventBelongsToCurrentUser
|
|
@@ -5512,7 +5558,7 @@ const removeReactionFromPinnedActivities = (payload, activities, eventBelongsToC
|
|
|
5512
5558
|
entities: activities,
|
|
5513
5559
|
matcher: (pinnedActivity) => pinnedActivity.activity.id === payload.activity.id,
|
|
5514
5560
|
updater: (matchedPinnedActivity) => {
|
|
5515
|
-
const newActivity = sharedUpdateActivity({
|
|
5561
|
+
const newActivity = sharedUpdateActivity$1({
|
|
5516
5562
|
currentActivity: matchedPinnedActivity.activity,
|
|
5517
5563
|
payload,
|
|
5518
5564
|
eventBelongsToCurrentUser
|
|
@@ -5564,6 +5610,89 @@ function handleActivityReactionDeleted(payload, fromWs) {
|
|
|
5564
5610
|
});
|
|
5565
5611
|
}
|
|
5566
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
|
+
}
|
|
5567
5696
|
const updateNotificationStatusFromActivityMarked = (event, currentNotificationStatus, aggregatedActivities = []) => {
|
|
5568
5697
|
if (!currentNotificationStatus) {
|
|
5569
5698
|
return {
|
|
@@ -5760,7 +5889,7 @@ const _Feed = class _Feed extends FeedApi {
|
|
|
5760
5889
|
"feeds.activity.deleted": handleActivityDeleted.bind(this),
|
|
5761
5890
|
"feeds.activity.reaction.added": handleActivityReactionAdded.bind(this),
|
|
5762
5891
|
"feeds.activity.reaction.deleted": handleActivityReactionDeleted.bind(this),
|
|
5763
|
-
"feeds.activity.reaction.updated":
|
|
5892
|
+
"feeds.activity.reaction.updated": handleActivityReactionUpdated.bind(this),
|
|
5764
5893
|
"feeds.activity.removed_from_feed": handleActivityRemovedFromFeed.bind(this),
|
|
5765
5894
|
"feeds.activity.updated": handleActivityUpdated.bind(this),
|
|
5766
5895
|
"feeds.bookmark.added": handleBookmarkAdded.bind(this),
|
|
@@ -5781,7 +5910,7 @@ const _Feed = class _Feed extends FeedApi {
|
|
|
5781
5910
|
"feeds.follow.updated": handleFollowUpdated.bind(this),
|
|
5782
5911
|
"feeds.comment.reaction.added": handleCommentReactionAdded.bind(this),
|
|
5783
5912
|
"feeds.comment.reaction.deleted": handleCommentReactionDeleted.bind(this),
|
|
5784
|
-
"feeds.comment.reaction.updated":
|
|
5913
|
+
"feeds.comment.reaction.updated": handleCommentReactionUpdated.bind(this),
|
|
5785
5914
|
"feeds.feed_member.added": handleFeedMemberAdded.bind(this),
|
|
5786
5915
|
"feeds.feed_member.removed": handleFeedMemberRemoved.bind(this),
|
|
5787
5916
|
"feeds.feed_member.updated": handleFeedMemberUpdated.bind(this),
|
|
@@ -6475,9 +6604,14 @@ class FeedsClient extends FeedsApi {
|
|
|
6475
6604
|
return response;
|
|
6476
6605
|
};
|
|
6477
6606
|
this.addActivityReaction = async (request) => {
|
|
6607
|
+
const shouldEnforceUnique = request.enforce_unique;
|
|
6478
6608
|
const response = await super.addActivityReaction(request);
|
|
6479
6609
|
for (const feed of Object.values(this.activeFeeds)) {
|
|
6480
|
-
|
|
6610
|
+
if (shouldEnforceUnique) {
|
|
6611
|
+
handleActivityReactionUpdated.bind(feed)(response, false);
|
|
6612
|
+
} else {
|
|
6613
|
+
handleActivityReactionAdded.bind(feed)(response, false);
|
|
6614
|
+
}
|
|
6481
6615
|
}
|
|
6482
6616
|
return response;
|
|
6483
6617
|
};
|
|
@@ -6492,9 +6626,14 @@ class FeedsClient extends FeedsApi {
|
|
|
6492
6626
|
return response;
|
|
6493
6627
|
};
|
|
6494
6628
|
this.addCommentReaction = async (request) => {
|
|
6629
|
+
const shouldEnforceUnique = request.enforce_unique;
|
|
6495
6630
|
const response = await super.addCommentReaction(request);
|
|
6496
6631
|
for (const feed of Object.values(this.activeFeeds)) {
|
|
6497
|
-
|
|
6632
|
+
if (shouldEnforceUnique) {
|
|
6633
|
+
handleCommentReactionUpdated.bind(feed)(response, false);
|
|
6634
|
+
} else {
|
|
6635
|
+
handleCommentReactionAdded.bind(feed)(response, false);
|
|
6636
|
+
}
|
|
6498
6637
|
}
|
|
6499
6638
|
return response;
|
|
6500
6639
|
};
|
|
@@ -6864,4 +7003,4 @@ export {
|
|
|
6864
7003
|
shouldUpdateState as s,
|
|
6865
7004
|
uniqueArrayMerge as u
|
|
6866
7005
|
};
|
|
6867
|
-
//# sourceMappingURL=index-
|
|
7006
|
+
//# sourceMappingURL=index-BZL77zNq.mjs.map
|