@stream-io/feeds-client 0.1.2 → 0.1.3
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/index-react-bindings.browser.cjs +28 -5
- package/dist/index-react-bindings.browser.cjs.map +1 -1
- package/dist/index-react-bindings.browser.js +28 -5
- package/dist/index-react-bindings.browser.js.map +1 -1
- package/dist/index-react-bindings.node.cjs +28 -5
- package/dist/index-react-bindings.node.cjs.map +1 -1
- package/dist/index-react-bindings.node.js +28 -5
- package/dist/index-react-bindings.node.js.map +1 -1
- package/dist/index.browser.cjs +28 -5
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +28 -5
- package/dist/index.browser.js.map +1 -1
- package/dist/index.node.cjs +28 -5
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +28 -5
- package/dist/index.node.js.map +1 -1
- package/dist/src/Feed.d.ts +2 -0
- package/dist/src/FeedsClient.d.ts +1 -0
- package/dist/src/common/ApiClient.d.ts +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/Feed.ts +14 -3
- package/src/FeedsClient.ts +13 -0
- package/src/common/ApiClient.ts +10 -3
package/dist/index.node.js
CHANGED
|
@@ -3543,7 +3543,10 @@ class ApiClient {
|
|
|
3543
3543
|
const encodedBody = requestContentType === 'multipart/form-data' ? new FormData() : body;
|
|
3544
3544
|
if (requestContentType === 'multipart/form-data') {
|
|
3545
3545
|
Object.keys(body).forEach((key) => {
|
|
3546
|
-
|
|
3546
|
+
const value = body[key];
|
|
3547
|
+
if (value != null) {
|
|
3548
|
+
encodedBody.append(key, value);
|
|
3549
|
+
}
|
|
3547
3550
|
});
|
|
3548
3551
|
}
|
|
3549
3552
|
try {
|
|
@@ -3552,8 +3555,11 @@ class ApiClient {
|
|
|
3552
3555
|
method,
|
|
3553
3556
|
headers,
|
|
3554
3557
|
params: queryParams,
|
|
3555
|
-
paramsSerializer: params => this.queryParamsStringify(params),
|
|
3558
|
+
paramsSerializer: (params) => this.queryParamsStringify(params),
|
|
3556
3559
|
data: encodedBody,
|
|
3560
|
+
timeout:
|
|
3561
|
+
// multipart/form-data requests should not have a timeout allowing ample time for file uploads
|
|
3562
|
+
requestContentType === 'multipart/form-data' ? 0 : this.timeout,
|
|
3557
3563
|
});
|
|
3558
3564
|
const metadata = this.getRequestMetadata(client_request_id, response);
|
|
3559
3565
|
return { body: response.data, metadata };
|
|
@@ -3617,9 +3623,9 @@ class ApiClient {
|
|
|
3617
3623
|
};
|
|
3618
3624
|
};
|
|
3619
3625
|
this.baseUrl = options?.base_url ?? 'https://video.stream-io-api.com';
|
|
3626
|
+
this.timeout = options?.timeout ?? 3000;
|
|
3620
3627
|
this.axiosInstance = axios.create({
|
|
3621
3628
|
baseURL: this.baseUrl,
|
|
3622
|
-
timeout: options?.timeout ?? 3000,
|
|
3623
3629
|
});
|
|
3624
3630
|
}
|
|
3625
3631
|
get webSocketBaseUrl() {
|
|
@@ -4339,6 +4345,12 @@ class Feed extends FeedApi {
|
|
|
4339
4345
|
};
|
|
4340
4346
|
});
|
|
4341
4347
|
}
|
|
4348
|
+
async synchronize() {
|
|
4349
|
+
const { last_get_or_create_request_config } = this.state.getLatestValue();
|
|
4350
|
+
if (last_get_or_create_request_config?.watch) {
|
|
4351
|
+
await this.getOrCreate(last_get_or_create_request_config);
|
|
4352
|
+
}
|
|
4353
|
+
}
|
|
4342
4354
|
async getOrCreate(request) {
|
|
4343
4355
|
if (this.currentState.is_loading_activities) {
|
|
4344
4356
|
throw new Error('Only one getOrCreate call is allowed at a time');
|
|
@@ -4404,6 +4416,7 @@ class Feed extends FeedApi {
|
|
|
4404
4416
|
if (!request?.following_pagination?.limit) {
|
|
4405
4417
|
delete nextState.following;
|
|
4406
4418
|
}
|
|
4419
|
+
nextState.last_get_or_create_request_config = request;
|
|
4407
4420
|
return nextState;
|
|
4408
4421
|
});
|
|
4409
4422
|
}
|
|
@@ -4690,7 +4703,7 @@ class Feed extends FeedApi {
|
|
|
4690
4703
|
}
|
|
4691
4704
|
async getNextPage() {
|
|
4692
4705
|
const currentState = this.currentState;
|
|
4693
|
-
|
|
4706
|
+
return await this.getOrCreate({
|
|
4694
4707
|
member_pagination: {
|
|
4695
4708
|
limit: 0,
|
|
4696
4709
|
},
|
|
@@ -4701,8 +4714,8 @@ class Feed extends FeedApi {
|
|
|
4701
4714
|
limit: 0,
|
|
4702
4715
|
},
|
|
4703
4716
|
next: currentState.next,
|
|
4717
|
+
limit: currentState.last_get_or_create_request_config?.limit ?? 20,
|
|
4704
4718
|
});
|
|
4705
|
-
return response;
|
|
4706
4719
|
}
|
|
4707
4720
|
addActivity(request) {
|
|
4708
4721
|
return this.feedsApi.addActivity({
|
|
@@ -5105,6 +5118,7 @@ class FeedsClient extends FeedsApi {
|
|
|
5105
5118
|
super(apiClient);
|
|
5106
5119
|
this.eventDispatcher = new EventDispatcher();
|
|
5107
5120
|
this.activeFeeds = {};
|
|
5121
|
+
this.healthyConnectionChangedEventCount = 0;
|
|
5108
5122
|
this.pollFromState = (id) => this.polls_by_id.get(id);
|
|
5109
5123
|
this.connectUser = async (user, tokenProvider) => {
|
|
5110
5124
|
if (this.state.getLatestValue().connectedUser !== undefined ||
|
|
@@ -5218,6 +5232,15 @@ class FeedsClient extends FeedsApi {
|
|
|
5218
5232
|
case 'connection.changed': {
|
|
5219
5233
|
const { online } = event;
|
|
5220
5234
|
this.state.partialNext({ isWsConnectionHealthy: online });
|
|
5235
|
+
if (online) {
|
|
5236
|
+
this.healthyConnectionChangedEventCount++;
|
|
5237
|
+
// we skip the first event as we could potentially be querying twice
|
|
5238
|
+
if (this.healthyConnectionChangedEventCount > 1) {
|
|
5239
|
+
for (const activeFeed of Object.values(this.activeFeeds)) {
|
|
5240
|
+
activeFeed.synchronize();
|
|
5241
|
+
}
|
|
5242
|
+
}
|
|
5243
|
+
}
|
|
5221
5244
|
break;
|
|
5222
5245
|
}
|
|
5223
5246
|
case 'feeds.feed.created': {
|