@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
|
@@ -3711,7 +3711,7 @@ const getRateLimitFromResponseHeader = (response_headers) => {
|
|
|
3711
3711
|
};
|
|
3712
3712
|
return result;
|
|
3713
3713
|
};
|
|
3714
|
-
const version = "0.2.
|
|
3714
|
+
const version = "0.2.13";
|
|
3715
3715
|
class ApiClient {
|
|
3716
3716
|
constructor(apiKey, tokenManager, connectionIdManager, options) {
|
|
3717
3717
|
this.apiKey = apiKey;
|
|
@@ -5580,13 +5580,70 @@ function handleActivityMarked(event) {
|
|
|
5580
5580
|
function handleFeedUpdated(event) {
|
|
5581
5581
|
this.state.partialNext({ ...event.feed });
|
|
5582
5582
|
}
|
|
5583
|
-
const
|
|
5583
|
+
const addAggregatedActivitiesToState = (newAggregatedActivities, aggregatedActivities, position) => {
|
|
5584
|
+
let result;
|
|
5585
|
+
if (newAggregatedActivities.length === 0) {
|
|
5586
|
+
result = {
|
|
5587
|
+
changed: false,
|
|
5588
|
+
aggregated_activities: []
|
|
5589
|
+
};
|
|
5590
|
+
} else {
|
|
5591
|
+
result = {
|
|
5592
|
+
changed: true,
|
|
5593
|
+
aggregated_activities: []
|
|
5594
|
+
};
|
|
5595
|
+
}
|
|
5596
|
+
result.aggregated_activities = position === "start" ? uniqueArrayMerge(
|
|
5597
|
+
newAggregatedActivities,
|
|
5598
|
+
aggregatedActivities ?? [],
|
|
5599
|
+
(a) => a.group
|
|
5600
|
+
) : uniqueArrayMerge(
|
|
5601
|
+
aggregatedActivities ?? [],
|
|
5602
|
+
newAggregatedActivities,
|
|
5603
|
+
(a) => a.group
|
|
5604
|
+
);
|
|
5605
|
+
return result;
|
|
5606
|
+
};
|
|
5607
|
+
const updateNotificationStatus = (newNotificationStatus, currentNotificationStatus) => {
|
|
5608
|
+
if (!newNotificationStatus && !currentNotificationStatus) {
|
|
5609
|
+
return {
|
|
5610
|
+
changed: false,
|
|
5611
|
+
notification_status: void 0
|
|
5612
|
+
};
|
|
5613
|
+
} else if (!newNotificationStatus) {
|
|
5614
|
+
return {
|
|
5615
|
+
changed: false,
|
|
5616
|
+
notification_status: currentNotificationStatus
|
|
5617
|
+
};
|
|
5618
|
+
} else {
|
|
5619
|
+
return {
|
|
5620
|
+
changed: true,
|
|
5621
|
+
notification_status: {
|
|
5622
|
+
...newNotificationStatus
|
|
5623
|
+
}
|
|
5624
|
+
};
|
|
5625
|
+
}
|
|
5626
|
+
};
|
|
5627
|
+
const updateNotificationFeedFromEvent = (event, currentAggregatedActivities, currentNotificationStatus) => {
|
|
5584
5628
|
const updates = {};
|
|
5585
|
-
if (event.notification_status) {
|
|
5586
|
-
|
|
5629
|
+
if (event.notification_status && currentNotificationStatus) {
|
|
5630
|
+
const notificationStatusResult = updateNotificationStatus(
|
|
5631
|
+
event.notification_status,
|
|
5632
|
+
currentNotificationStatus
|
|
5633
|
+
);
|
|
5634
|
+
if (notificationStatusResult.changed) {
|
|
5635
|
+
updates.notification_status = notificationStatusResult.notification_status;
|
|
5636
|
+
}
|
|
5587
5637
|
}
|
|
5588
|
-
if (event.aggregated_activities) {
|
|
5589
|
-
|
|
5638
|
+
if (event.aggregated_activities && currentAggregatedActivities) {
|
|
5639
|
+
const aggregatedActivitiesResult = addAggregatedActivitiesToState(
|
|
5640
|
+
event.aggregated_activities,
|
|
5641
|
+
currentAggregatedActivities,
|
|
5642
|
+
"start"
|
|
5643
|
+
);
|
|
5644
|
+
if (aggregatedActivitiesResult.changed) {
|
|
5645
|
+
updates.aggregated_activities = aggregatedActivitiesResult.aggregated_activities;
|
|
5646
|
+
}
|
|
5590
5647
|
}
|
|
5591
5648
|
if (Object.keys(updates).length > 0) {
|
|
5592
5649
|
return {
|
|
@@ -5599,7 +5656,11 @@ const updateNotificationFeedFromEvent = (event) => {
|
|
|
5599
5656
|
};
|
|
5600
5657
|
};
|
|
5601
5658
|
function handleNotificationFeedUpdated(event) {
|
|
5602
|
-
const result = updateNotificationFeedFromEvent(
|
|
5659
|
+
const result = updateNotificationFeedFromEvent(
|
|
5660
|
+
event,
|
|
5661
|
+
this.currentState.aggregated_activities,
|
|
5662
|
+
this.currentState.notification_status
|
|
5663
|
+
);
|
|
5603
5664
|
if (result.changed) {
|
|
5604
5665
|
this.state.partialNext({
|
|
5605
5666
|
notification_status: result.data?.notification_status,
|
|
@@ -5728,9 +5789,20 @@ const _Feed = class _Feed extends FeedApi {
|
|
|
5728
5789
|
currentActivities,
|
|
5729
5790
|
"end"
|
|
5730
5791
|
);
|
|
5731
|
-
|
|
5792
|
+
const aggregatedActivitiesResult = addAggregatedActivitiesToState(
|
|
5793
|
+
response.aggregated_activities,
|
|
5794
|
+
this.currentState.aggregated_activities,
|
|
5795
|
+
"end"
|
|
5796
|
+
);
|
|
5797
|
+
const notificationStatusResult = updateNotificationStatus(
|
|
5798
|
+
response.notification_status,
|
|
5799
|
+
this.currentState.notification_status
|
|
5800
|
+
);
|
|
5801
|
+
if (result.changed || aggregatedActivitiesResult.changed || notificationStatusResult.changed) {
|
|
5732
5802
|
this.state.partialNext({
|
|
5733
5803
|
activities: result.activities,
|
|
5804
|
+
aggregated_activities: aggregatedActivitiesResult.aggregated_activities,
|
|
5805
|
+
notification_status: notificationStatusResult.notification_status,
|
|
5734
5806
|
next: response.next,
|
|
5735
5807
|
prev: response.prev
|
|
5736
5808
|
});
|
|
@@ -6709,4 +6781,4 @@ exports.isVoteAnswer = isVoteAnswer;
|
|
|
6709
6781
|
exports.shouldUpdateState = shouldUpdateState;
|
|
6710
6782
|
exports.uniqueArrayMerge = uniqueArrayMerge;
|
|
6711
6783
|
exports.updateEntityInArray = updateEntityInArray;
|
|
6712
|
-
//# sourceMappingURL=index-
|
|
6784
|
+
//# sourceMappingURL=index-RzB4c4g6.js.map
|