@stream-io/feeds-client 0.2.12 → 0.2.13
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 +7 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/react-bindings.js +22 -14
- package/dist/cjs/react-bindings.js.map +1 -1
- package/dist/es/index.mjs +2 -2
- package/dist/es/react-bindings.mjs +22 -14
- package/dist/es/react-bindings.mjs.map +1 -1
- package/dist/{index-o7AeSkxa.js → index-RzB4c4g6.js} +81 -9
- package/dist/index-RzB4c4g6.js.map +1 -0
- package/dist/{index-D7QtnkUs.mjs → index-gvcJhGPH.mjs} +81 -9
- package/dist/index-gvcJhGPH.mjs.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/bindings/react/hooks/feed-state-hooks/useAggregatedActivities.d.ts +9 -4
- package/dist/types/bindings/react/hooks/feed-state-hooks/useAggregatedActivities.d.ts.map +1 -1
- package/dist/types/bindings/react/hooks/feed-state-hooks/useIsAggregatedActivityRead.d.ts.map +1 -1
- package/dist/types/feed/event-handlers/notification-feed/handle-notification-feed-updated.d.ts +8 -1
- package/dist/types/feed/event-handlers/notification-feed/handle-notification-feed-updated.d.ts.map +1 -1
- package/dist/types/feed/feed.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/bindings/react/hooks/feed-state-hooks/useAggregatedActivities.ts +28 -4
- package/src/bindings/react/hooks/feed-state-hooks/useIsAggregatedActivityRead.ts +4 -5
- package/src/feed/event-handlers/notification-feed/handle-notification-feed-updated.test.ts +309 -11
- package/src/feed/event-handlers/notification-feed/handle-notification-feed-updated.ts +89 -6
- package/src/feed/feed.ts +21 -1
- package/dist/index-D7QtnkUs.mjs.map +0 -1
- package/dist/index-o7AeSkxa.js.map +0 -1
|
@@ -3693,7 +3693,7 @@ const getRateLimitFromResponseHeader = (response_headers) => {
|
|
|
3693
3693
|
};
|
|
3694
3694
|
return result;
|
|
3695
3695
|
};
|
|
3696
|
-
const version = "0.2.
|
|
3696
|
+
const version = "0.2.13";
|
|
3697
3697
|
class ApiClient {
|
|
3698
3698
|
constructor(apiKey, tokenManager, connectionIdManager, options) {
|
|
3699
3699
|
this.apiKey = apiKey;
|
|
@@ -5562,13 +5562,70 @@ function handleActivityMarked(event) {
|
|
|
5562
5562
|
function handleFeedUpdated(event) {
|
|
5563
5563
|
this.state.partialNext({ ...event.feed });
|
|
5564
5564
|
}
|
|
5565
|
-
const
|
|
5565
|
+
const addAggregatedActivitiesToState = (newAggregatedActivities, aggregatedActivities, position) => {
|
|
5566
|
+
let result;
|
|
5567
|
+
if (newAggregatedActivities.length === 0) {
|
|
5568
|
+
result = {
|
|
5569
|
+
changed: false,
|
|
5570
|
+
aggregated_activities: []
|
|
5571
|
+
};
|
|
5572
|
+
} else {
|
|
5573
|
+
result = {
|
|
5574
|
+
changed: true,
|
|
5575
|
+
aggregated_activities: []
|
|
5576
|
+
};
|
|
5577
|
+
}
|
|
5578
|
+
result.aggregated_activities = position === "start" ? uniqueArrayMerge(
|
|
5579
|
+
newAggregatedActivities,
|
|
5580
|
+
aggregatedActivities ?? [],
|
|
5581
|
+
(a) => a.group
|
|
5582
|
+
) : uniqueArrayMerge(
|
|
5583
|
+
aggregatedActivities ?? [],
|
|
5584
|
+
newAggregatedActivities,
|
|
5585
|
+
(a) => a.group
|
|
5586
|
+
);
|
|
5587
|
+
return result;
|
|
5588
|
+
};
|
|
5589
|
+
const updateNotificationStatus = (newNotificationStatus, currentNotificationStatus) => {
|
|
5590
|
+
if (!newNotificationStatus && !currentNotificationStatus) {
|
|
5591
|
+
return {
|
|
5592
|
+
changed: false,
|
|
5593
|
+
notification_status: void 0
|
|
5594
|
+
};
|
|
5595
|
+
} else if (!newNotificationStatus) {
|
|
5596
|
+
return {
|
|
5597
|
+
changed: false,
|
|
5598
|
+
notification_status: currentNotificationStatus
|
|
5599
|
+
};
|
|
5600
|
+
} else {
|
|
5601
|
+
return {
|
|
5602
|
+
changed: true,
|
|
5603
|
+
notification_status: {
|
|
5604
|
+
...newNotificationStatus
|
|
5605
|
+
}
|
|
5606
|
+
};
|
|
5607
|
+
}
|
|
5608
|
+
};
|
|
5609
|
+
const updateNotificationFeedFromEvent = (event, currentAggregatedActivities, currentNotificationStatus) => {
|
|
5566
5610
|
const updates = {};
|
|
5567
|
-
if (event.notification_status) {
|
|
5568
|
-
|
|
5611
|
+
if (event.notification_status && currentNotificationStatus) {
|
|
5612
|
+
const notificationStatusResult = updateNotificationStatus(
|
|
5613
|
+
event.notification_status,
|
|
5614
|
+
currentNotificationStatus
|
|
5615
|
+
);
|
|
5616
|
+
if (notificationStatusResult.changed) {
|
|
5617
|
+
updates.notification_status = notificationStatusResult.notification_status;
|
|
5618
|
+
}
|
|
5569
5619
|
}
|
|
5570
|
-
if (event.aggregated_activities) {
|
|
5571
|
-
|
|
5620
|
+
if (event.aggregated_activities && currentAggregatedActivities) {
|
|
5621
|
+
const aggregatedActivitiesResult = addAggregatedActivitiesToState(
|
|
5622
|
+
event.aggregated_activities,
|
|
5623
|
+
currentAggregatedActivities,
|
|
5624
|
+
"start"
|
|
5625
|
+
);
|
|
5626
|
+
if (aggregatedActivitiesResult.changed) {
|
|
5627
|
+
updates.aggregated_activities = aggregatedActivitiesResult.aggregated_activities;
|
|
5628
|
+
}
|
|
5572
5629
|
}
|
|
5573
5630
|
if (Object.keys(updates).length > 0) {
|
|
5574
5631
|
return {
|
|
@@ -5581,7 +5638,11 @@ const updateNotificationFeedFromEvent = (event) => {
|
|
|
5581
5638
|
};
|
|
5582
5639
|
};
|
|
5583
5640
|
function handleNotificationFeedUpdated(event) {
|
|
5584
|
-
const result = updateNotificationFeedFromEvent(
|
|
5641
|
+
const result = updateNotificationFeedFromEvent(
|
|
5642
|
+
event,
|
|
5643
|
+
this.currentState.aggregated_activities,
|
|
5644
|
+
this.currentState.notification_status
|
|
5645
|
+
);
|
|
5585
5646
|
if (result.changed) {
|
|
5586
5647
|
this.state.partialNext({
|
|
5587
5648
|
notification_status: result.data?.notification_status,
|
|
@@ -5710,9 +5771,20 @@ const _Feed = class _Feed extends FeedApi {
|
|
|
5710
5771
|
currentActivities,
|
|
5711
5772
|
"end"
|
|
5712
5773
|
);
|
|
5713
|
-
|
|
5774
|
+
const aggregatedActivitiesResult = addAggregatedActivitiesToState(
|
|
5775
|
+
response.aggregated_activities,
|
|
5776
|
+
this.currentState.aggregated_activities,
|
|
5777
|
+
"end"
|
|
5778
|
+
);
|
|
5779
|
+
const notificationStatusResult = updateNotificationStatus(
|
|
5780
|
+
response.notification_status,
|
|
5781
|
+
this.currentState.notification_status
|
|
5782
|
+
);
|
|
5783
|
+
if (result.changed || aggregatedActivitiesResult.changed || notificationStatusResult.changed) {
|
|
5714
5784
|
this.state.partialNext({
|
|
5715
5785
|
activities: result.activities,
|
|
5786
|
+
aggregated_activities: aggregatedActivitiesResult.aggregated_activities,
|
|
5787
|
+
notification_status: notificationStatusResult.notification_status,
|
|
5716
5788
|
next: response.next,
|
|
5717
5789
|
prev: response.prev
|
|
5718
5790
|
});
|
|
@@ -6693,4 +6765,4 @@ export {
|
|
|
6693
6765
|
shouldUpdateState as s,
|
|
6694
6766
|
uniqueArrayMerge as u
|
|
6695
6767
|
};
|
|
6696
|
-
//# sourceMappingURL=index-
|
|
6768
|
+
//# sourceMappingURL=index-gvcJhGPH.mjs.map
|