@stream-io/feeds-client 0.3.18 → 0.3.20
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 +14 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/react-bindings.js +1 -2
- package/dist/cjs/react-bindings.js.map +1 -1
- package/dist/es/index.mjs +2 -2
- package/dist/es/react-bindings.mjs +1 -2
- package/dist/es/react-bindings.mjs.map +1 -1
- package/dist/{feeds-client-DT_p8LU4.mjs → feeds-client-CQkvWrgd.mjs} +49 -12
- package/dist/feeds-client-CQkvWrgd.mjs.map +1 -0
- package/dist/{feeds-client-Be5gS8Xx.js → feeds-client-CVOa15Qx.js} +49 -12
- package/dist/feeds-client-CVOa15Qx.js.map +1 -0
- package/dist/types/common/ApiClient.d.ts.map +1 -1
- package/dist/types/feed/feed.d.ts +1 -0
- package/dist/types/feed/feed.d.ts.map +1 -1
- package/dist/types/feeds-client/feeds-client.d.ts +6 -2
- package/dist/types/feeds-client/feeds-client.d.ts.map +1 -1
- package/dist/types/feeds-client/get-or-create-active-feed.d.ts +4 -0
- package/dist/types/feeds-client/get-or-create-active-feed.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/common/ApiClient.ts +5 -1
- package/src/feed/event-handlers/activity/handle-activity-added.ts +2 -2
- package/src/feed/event-handlers/follow/handle-follow-deleted.ts +7 -7
- package/src/feed/feed.ts +16 -1
- package/src/feeds-client/feeds-client.ts +37 -7
- package/src/feeds-client/get-or-create-active-feed.ts +12 -0
- package/dist/feeds-client-Be5gS8Xx.js.map +0 -1
- package/dist/feeds-client-DT_p8LU4.mjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StateStore } from "@stream-io/state-store";
|
|
2
2
|
import * as loggerInternal from "@stream-io/logger";
|
|
3
|
-
import
|
|
3
|
+
import axiosImport from "axios";
|
|
4
4
|
const decoders = {};
|
|
5
5
|
const decodeDatetimeType = (input) => typeof input === "number" ? new Date(Math.floor(input / 1e6)) : new Date(input);
|
|
6
6
|
decoders.DatetimeType = decodeDatetimeType;
|
|
@@ -3914,7 +3914,8 @@ const getRateLimitFromResponseHeader = (response_headers) => {
|
|
|
3914
3914
|
};
|
|
3915
3915
|
return result;
|
|
3916
3916
|
};
|
|
3917
|
-
const version = "0.3.
|
|
3917
|
+
const version = "0.3.20";
|
|
3918
|
+
const axios = axiosImport.default ?? axiosImport;
|
|
3918
3919
|
class ApiClient {
|
|
3919
3920
|
constructor(apiKey, tokenManager, connectionIdManager, options) {
|
|
3920
3921
|
this.apiKey = apiKey;
|
|
@@ -4857,10 +4858,10 @@ const updateStateFollowDeleted = (follow, currentState, currentFeedId, connected
|
|
|
4857
4858
|
// Update FeedResponse fields, that has the new follower/following count
|
|
4858
4859
|
...follow.target_feed
|
|
4859
4860
|
};
|
|
4860
|
-
if (source.created_by.id === connectedUserId
|
|
4861
|
-
newState.own_follows = currentState.own_follows.filter(
|
|
4861
|
+
if (source.created_by.id === connectedUserId) {
|
|
4862
|
+
newState.own_follows = currentState.own_follows ? currentState.own_follows.filter(
|
|
4862
4863
|
(followItem) => followItem.source_feed.feed !== follow.source_feed.feed
|
|
4863
|
-
);
|
|
4864
|
+
) : [];
|
|
4864
4865
|
}
|
|
4865
4866
|
if (currentState.followers !== void 0) {
|
|
4866
4867
|
newState.followers = currentState.followers.filter(
|
|
@@ -5508,6 +5509,7 @@ function addActivitiesToState(newActivities, activities, position) {
|
|
|
5508
5509
|
...activities,
|
|
5509
5510
|
...position === "end" ? newActivitiesDeduplicated : []
|
|
5510
5511
|
];
|
|
5512
|
+
this.newActivitiesAdded(newActivitiesDeduplicated);
|
|
5511
5513
|
result = { changed: true, activities: updatedActivities };
|
|
5512
5514
|
}
|
|
5513
5515
|
return result;
|
|
@@ -6226,6 +6228,9 @@ const deepEqual = (x, y) => {
|
|
|
6226
6228
|
return false;
|
|
6227
6229
|
}
|
|
6228
6230
|
};
|
|
6231
|
+
function getOrCreateActiveFeed(group, id, data, watch) {
|
|
6232
|
+
return this.getOrCreateActiveFeed(group, id, data, watch);
|
|
6233
|
+
}
|
|
6229
6234
|
const _Feed = class _Feed extends FeedApi {
|
|
6230
6235
|
constructor(client, groupId, id, data, watch = false, addNewActivitiesTo = "start", activityAddedEventFilter) {
|
|
6231
6236
|
super(client, groupId, id);
|
|
@@ -6418,7 +6423,7 @@ const _Feed = class _Feed extends FeedApi {
|
|
|
6418
6423
|
return nextState;
|
|
6419
6424
|
});
|
|
6420
6425
|
}
|
|
6421
|
-
this.
|
|
6426
|
+
this.newActivitiesAdded(response.activities);
|
|
6422
6427
|
return response;
|
|
6423
6428
|
} finally {
|
|
6424
6429
|
this.state.partialNext({
|
|
@@ -6819,6 +6824,18 @@ const _Feed = class _Feed extends FeedApi {
|
|
|
6819
6824
|
}
|
|
6820
6825
|
this.eventDispatcher.dispatch(event);
|
|
6821
6826
|
}
|
|
6827
|
+
newActivitiesAdded(activities) {
|
|
6828
|
+
this.client.hydratePollCache(activities);
|
|
6829
|
+
activities.forEach((activity) => {
|
|
6830
|
+
if (activity.current_feed) {
|
|
6831
|
+
getOrCreateActiveFeed.bind(this.client)(
|
|
6832
|
+
activity.current_feed.group_id,
|
|
6833
|
+
activity.current_feed.id,
|
|
6834
|
+
activity.current_feed
|
|
6835
|
+
);
|
|
6836
|
+
}
|
|
6837
|
+
});
|
|
6838
|
+
}
|
|
6822
6839
|
};
|
|
6823
6840
|
_Feed.noop = () => {
|
|
6824
6841
|
};
|
|
@@ -7363,8 +7380,7 @@ class FeedsClient extends FeedsApi {
|
|
|
7363
7380
|
id,
|
|
7364
7381
|
void 0,
|
|
7365
7382
|
void 0,
|
|
7366
|
-
options2
|
|
7367
|
-
options2?.activityAddedEventFilter
|
|
7383
|
+
options2
|
|
7368
7384
|
);
|
|
7369
7385
|
};
|
|
7370
7386
|
this.activityWithStateUpdates = (id) => {
|
|
@@ -7382,20 +7398,30 @@ class FeedsClient extends FeedsApi {
|
|
|
7382
7398
|
};
|
|
7383
7399
|
this.eventDispatcher.dispatch(networkEvent);
|
|
7384
7400
|
};
|
|
7385
|
-
this.getOrCreateActiveFeed = (group, id, data, watch,
|
|
7401
|
+
this.getOrCreateActiveFeed = (group, id, data, watch, options2) => {
|
|
7386
7402
|
const fid = `${group}:${id}`;
|
|
7403
|
+
let isCreated = false;
|
|
7387
7404
|
if (!this.activeFeeds[fid]) {
|
|
7405
|
+
isCreated = true;
|
|
7388
7406
|
this.activeFeeds[fid] = new Feed(
|
|
7389
7407
|
this,
|
|
7390
7408
|
group,
|
|
7391
7409
|
id,
|
|
7392
7410
|
data,
|
|
7393
7411
|
watch,
|
|
7394
|
-
addNewActivitiesTo,
|
|
7395
|
-
activityAddedEventFilter
|
|
7412
|
+
options2?.addNewActivitiesTo,
|
|
7413
|
+
options2?.activityAddedEventFilter
|
|
7396
7414
|
);
|
|
7397
7415
|
}
|
|
7398
7416
|
const feed = this.activeFeeds[fid];
|
|
7417
|
+
if (!isCreated && options2) {
|
|
7418
|
+
if (options2?.addNewActivitiesTo) {
|
|
7419
|
+
feed.addNewActivitiesTo = options2.addNewActivitiesTo;
|
|
7420
|
+
}
|
|
7421
|
+
if (options2?.activityAddedEventFilter) {
|
|
7422
|
+
feed.activityAddedEventFilter = options2.activityAddedEventFilter;
|
|
7423
|
+
}
|
|
7424
|
+
}
|
|
7399
7425
|
if (!feed.currentState.watch) {
|
|
7400
7426
|
if (data) handleFeedUpdated.call(feed, { feed: data });
|
|
7401
7427
|
if (watch) handleWatchStarted.call(feed);
|
|
@@ -7667,6 +7693,17 @@ class FeedsClient extends FeedsApi {
|
|
|
7667
7693
|
}
|
|
7668
7694
|
return response;
|
|
7669
7695
|
}
|
|
7696
|
+
async getFollowSuggestions(...params) {
|
|
7697
|
+
const response = await super.getFollowSuggestions(...params);
|
|
7698
|
+
response.suggestions.forEach((suggestion) => {
|
|
7699
|
+
this.getOrCreateActiveFeed(
|
|
7700
|
+
suggestion.group_id,
|
|
7701
|
+
suggestion.id,
|
|
7702
|
+
suggestion
|
|
7703
|
+
);
|
|
7704
|
+
});
|
|
7705
|
+
return response;
|
|
7706
|
+
}
|
|
7670
7707
|
findAllActiveFeedsByActivityId(activityId) {
|
|
7671
7708
|
return [
|
|
7672
7709
|
...Object.values(this.activeFeeds),
|
|
@@ -7748,4 +7785,4 @@ export {
|
|
|
7748
7785
|
shouldUpdateState as s,
|
|
7749
7786
|
uniqueArrayMerge as u
|
|
7750
7787
|
};
|
|
7751
|
-
//# sourceMappingURL=feeds-client-
|
|
7788
|
+
//# sourceMappingURL=feeds-client-CQkvWrgd.mjs.map
|