@stream-io/feeds-client 0.3.33 → 0.3.35
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 +17 -0
- package/README.md +3 -2
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/react-bindings.js +2 -4
- package/dist/cjs/react-bindings.js.map +1 -1
- package/dist/es/index.mjs +2 -2
- package/dist/es/index.mjs.map +1 -1
- package/dist/es/react-bindings.mjs +2 -4
- package/dist/es/react-bindings.mjs.map +1 -1
- package/dist/{feeds-client-C-6NrDBy.mjs → feeds-client-BRK49aQb.mjs} +40 -34
- package/dist/{feeds-client-C-6NrDBy.mjs.map → feeds-client-BRK49aQb.mjs.map} +1 -1
- package/dist/{feeds-client-CyaHg6lu.js → feeds-client-F087iP6p.js} +40 -34
- package/dist/{feeds-client-CyaHg6lu.js.map → feeds-client-F087iP6p.js.map} +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/types/activity-with-state-updates/activity-with-state-updates.d.ts +3 -1
- package/dist/types/activity-with-state-updates/activity-with-state-updates.d.ts.map +1 -1
- package/dist/types/bindings/react/hooks/useCreateFeedsClient.d.ts.map +1 -1
- package/dist/types/feed/event-handlers/activity-updater.d.ts +1 -0
- package/dist/types/feed/event-handlers/activity-updater.d.ts.map +1 -1
- package/dist/types/feed/feed.d.ts.map +1 -1
- package/dist/types/feeds-client/active-activity.d.ts +2 -1
- package/dist/types/feeds-client/active-activity.d.ts.map +1 -1
- package/dist/types/feeds-client/feeds-client.d.ts +7 -3
- package/dist/types/feeds-client/feeds-client.d.ts.map +1 -1
- package/dist/types/gen/models/index.d.ts +1 -0
- package/dist/types/gen/models/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/activity-with-state-updates/activity-with-state-updates.ts +10 -1
- package/src/bindings/react/hooks/useCreateFeedsClient.ts +1 -3
- package/src/feed/feed.ts +7 -5
- package/src/feeds-client/active-activity.ts +8 -4
- package/src/feeds-client/feeds-client.ts +22 -23
- package/src/gen/models/index.ts +2 -0
|
@@ -124,7 +124,7 @@ export class FeedsClient extends FeedsApi {
|
|
|
124
124
|
|
|
125
125
|
private readonly polls_by_id: Map<string, StreamPoll>;
|
|
126
126
|
|
|
127
|
-
protected activeActivities:
|
|
127
|
+
protected activeActivities: ActivityWithStateUpdates[] = [];
|
|
128
128
|
protected activeFeeds: Record<FID, Feed> = {};
|
|
129
129
|
|
|
130
130
|
private healthyConnectionChangedEventCount = 0;
|
|
@@ -193,12 +193,9 @@ export class FeedsClient extends FeedsApi {
|
|
|
193
193
|
feeds.forEach((f) => f.handleWSEvent(event as unknown as WSEvent));
|
|
194
194
|
if (typeof fid === 'string') {
|
|
195
195
|
delete this.activeFeeds[fid];
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
delete this.activeActivities[activityId];
|
|
200
|
-
}
|
|
201
|
-
});
|
|
196
|
+
this.activeActivities = this.activeActivities.filter(
|
|
197
|
+
(activity) => getFeed.call(activity)?.feed !== fid,
|
|
198
|
+
);
|
|
202
199
|
}
|
|
203
200
|
break;
|
|
204
201
|
}
|
|
@@ -278,7 +275,9 @@ export class FeedsClient extends FeedsApi {
|
|
|
278
275
|
default: {
|
|
279
276
|
feeds.forEach((f) => f.handleWSEvent(event as unknown as WSEvent));
|
|
280
277
|
if (event.type === 'feeds.activity.deleted') {
|
|
281
|
-
|
|
278
|
+
this.activeActivities = this.activeActivities.filter(
|
|
279
|
+
(activity) => activity.id !== event.activity.id,
|
|
280
|
+
);
|
|
282
281
|
}
|
|
283
282
|
}
|
|
284
283
|
}
|
|
@@ -314,18 +313,17 @@ export class FeedsClient extends FeedsApi {
|
|
|
314
313
|
// we skip the first event as we could potentially be querying twice
|
|
315
314
|
if (this.healthyConnectionChangedEventCount > 1) {
|
|
316
315
|
const feedEntries = Object.entries(this.activeFeeds);
|
|
317
|
-
const activityEntries = Object.entries(this.activeActivities);
|
|
318
316
|
|
|
319
317
|
const results = await Promise.allSettled([
|
|
320
318
|
...feedEntries.map(([, feed]) => feed.synchronize()),
|
|
321
|
-
...
|
|
319
|
+
...this.activeActivities.map((activity) => activity.synchronize()),
|
|
322
320
|
]);
|
|
323
321
|
|
|
324
322
|
const failures: SyncFailure[] = results.flatMap((result, index) => {
|
|
325
323
|
if (result.status === 'fulfilled') {
|
|
326
324
|
return [];
|
|
327
325
|
}
|
|
328
|
-
const activity =
|
|
326
|
+
const activity = this.activeActivities[index - feedEntries.length];
|
|
329
327
|
const feed =
|
|
330
328
|
feedEntries[index]?.[0] ?? (activity && getFeed.call(activity)?.feed);
|
|
331
329
|
|
|
@@ -613,7 +611,7 @@ export class FeedsClient extends FeedsApi {
|
|
|
613
611
|
// clear all caches
|
|
614
612
|
this.polls_by_id.clear();
|
|
615
613
|
|
|
616
|
-
this.activeActivities =
|
|
614
|
+
this.activeActivities = [];
|
|
617
615
|
this.activeFeeds = {};
|
|
618
616
|
|
|
619
617
|
this.state.partialNext({
|
|
@@ -661,12 +659,14 @@ export class FeedsClient extends FeedsApi {
|
|
|
661
659
|
* @param id - The id of the activity
|
|
662
660
|
* @returns The activity with state updates
|
|
663
661
|
*/
|
|
664
|
-
activityWithStateUpdates = (
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
662
|
+
activityWithStateUpdates = (
|
|
663
|
+
id: ActivityId,
|
|
664
|
+
{ fromResponse }: { fromResponse?: ActivityResponse } = {
|
|
665
|
+
fromResponse: undefined,
|
|
666
|
+
},
|
|
667
|
+
) => {
|
|
668
|
+
const activity = new ActivityWithStateUpdates(id, this, { fromResponse });
|
|
669
|
+
this.activeActivities.push(activity);
|
|
670
670
|
return activity;
|
|
671
671
|
};
|
|
672
672
|
|
|
@@ -812,11 +812,11 @@ export class FeedsClient extends FeedsApi {
|
|
|
812
812
|
|
|
813
813
|
async getFollowSuggestions(
|
|
814
814
|
...params: Parameters<FeedsApi['getFollowSuggestions']>
|
|
815
|
-
): Promise<StreamResponse<GetFollowSuggestionsResponse>> {
|
|
815
|
+
): Promise<StreamResponse<GetFollowSuggestionsResponse & { feeds: Feed[] }>> {
|
|
816
816
|
const response = await super.getFollowSuggestions(...params);
|
|
817
817
|
|
|
818
|
-
response.suggestions.
|
|
819
|
-
this.getOrCreateActiveFeed({
|
|
818
|
+
const feeds = response.suggestions.map((suggestion) => {
|
|
819
|
+
return this.getOrCreateActiveFeed({
|
|
820
820
|
group: suggestion.group_id,
|
|
821
821
|
id: suggestion.id,
|
|
822
822
|
data: suggestion,
|
|
@@ -829,8 +829,7 @@ export class FeedsClient extends FeedsApi {
|
|
|
829
829
|
});
|
|
830
830
|
});
|
|
831
831
|
|
|
832
|
-
|
|
833
|
-
return response;
|
|
832
|
+
return { ...response, feeds };
|
|
834
833
|
}
|
|
835
834
|
|
|
836
835
|
protected readonly getOrCreateActiveFeed = ({
|