@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
|
@@ -3651,7 +3651,10 @@ class ApiClient {
|
|
|
3651
3651
|
const encodedBody = requestContentType === 'multipart/form-data' ? new FormData() : body;
|
|
3652
3652
|
if (requestContentType === 'multipart/form-data') {
|
|
3653
3653
|
Object.keys(body).forEach((key) => {
|
|
3654
|
-
|
|
3654
|
+
const value = body[key];
|
|
3655
|
+
if (value != null) {
|
|
3656
|
+
encodedBody.append(key, value);
|
|
3657
|
+
}
|
|
3655
3658
|
});
|
|
3656
3659
|
}
|
|
3657
3660
|
try {
|
|
@@ -3660,8 +3663,11 @@ class ApiClient {
|
|
|
3660
3663
|
method,
|
|
3661
3664
|
headers,
|
|
3662
3665
|
params: queryParams,
|
|
3663
|
-
paramsSerializer: params => this.queryParamsStringify(params),
|
|
3666
|
+
paramsSerializer: (params) => this.queryParamsStringify(params),
|
|
3664
3667
|
data: encodedBody,
|
|
3668
|
+
timeout:
|
|
3669
|
+
// multipart/form-data requests should not have a timeout allowing ample time for file uploads
|
|
3670
|
+
requestContentType === 'multipart/form-data' ? 0 : this.timeout,
|
|
3665
3671
|
});
|
|
3666
3672
|
const metadata = this.getRequestMetadata(client_request_id, response);
|
|
3667
3673
|
return { body: response.data, metadata };
|
|
@@ -3725,9 +3731,9 @@ class ApiClient {
|
|
|
3725
3731
|
};
|
|
3726
3732
|
};
|
|
3727
3733
|
this.baseUrl = options?.base_url ?? 'https://video.stream-io-api.com';
|
|
3734
|
+
this.timeout = options?.timeout ?? 3000;
|
|
3728
3735
|
this.axiosInstance = axios.create({
|
|
3729
3736
|
baseURL: this.baseUrl,
|
|
3730
|
-
timeout: options?.timeout ?? 3000,
|
|
3731
3737
|
});
|
|
3732
3738
|
}
|
|
3733
3739
|
get webSocketBaseUrl() {
|
|
@@ -4447,6 +4453,12 @@ class Feed extends FeedApi {
|
|
|
4447
4453
|
};
|
|
4448
4454
|
});
|
|
4449
4455
|
}
|
|
4456
|
+
async synchronize() {
|
|
4457
|
+
const { last_get_or_create_request_config } = this.state.getLatestValue();
|
|
4458
|
+
if (last_get_or_create_request_config?.watch) {
|
|
4459
|
+
await this.getOrCreate(last_get_or_create_request_config);
|
|
4460
|
+
}
|
|
4461
|
+
}
|
|
4450
4462
|
async getOrCreate(request) {
|
|
4451
4463
|
if (this.currentState.is_loading_activities) {
|
|
4452
4464
|
throw new Error('Only one getOrCreate call is allowed at a time');
|
|
@@ -4512,6 +4524,7 @@ class Feed extends FeedApi {
|
|
|
4512
4524
|
if (!request?.following_pagination?.limit) {
|
|
4513
4525
|
delete nextState.following;
|
|
4514
4526
|
}
|
|
4527
|
+
nextState.last_get_or_create_request_config = request;
|
|
4515
4528
|
return nextState;
|
|
4516
4529
|
});
|
|
4517
4530
|
}
|
|
@@ -4798,7 +4811,7 @@ class Feed extends FeedApi {
|
|
|
4798
4811
|
}
|
|
4799
4812
|
async getNextPage() {
|
|
4800
4813
|
const currentState = this.currentState;
|
|
4801
|
-
|
|
4814
|
+
return await this.getOrCreate({
|
|
4802
4815
|
member_pagination: {
|
|
4803
4816
|
limit: 0,
|
|
4804
4817
|
},
|
|
@@ -4809,8 +4822,8 @@ class Feed extends FeedApi {
|
|
|
4809
4822
|
limit: 0,
|
|
4810
4823
|
},
|
|
4811
4824
|
next: currentState.next,
|
|
4825
|
+
limit: currentState.last_get_or_create_request_config?.limit ?? 20,
|
|
4812
4826
|
});
|
|
4813
|
-
return response;
|
|
4814
4827
|
}
|
|
4815
4828
|
addActivity(request) {
|
|
4816
4829
|
return this.feedsApi.addActivity({
|
|
@@ -5213,6 +5226,7 @@ class FeedsClient extends FeedsApi {
|
|
|
5213
5226
|
super(apiClient);
|
|
5214
5227
|
this.eventDispatcher = new EventDispatcher();
|
|
5215
5228
|
this.activeFeeds = {};
|
|
5229
|
+
this.healthyConnectionChangedEventCount = 0;
|
|
5216
5230
|
this.pollFromState = (id) => this.polls_by_id.get(id);
|
|
5217
5231
|
this.connectUser = async (user, tokenProvider) => {
|
|
5218
5232
|
if (this.state.getLatestValue().connectedUser !== undefined ||
|
|
@@ -5326,6 +5340,15 @@ class FeedsClient extends FeedsApi {
|
|
|
5326
5340
|
case 'connection.changed': {
|
|
5327
5341
|
const { online } = event;
|
|
5328
5342
|
this.state.partialNext({ isWsConnectionHealthy: online });
|
|
5343
|
+
if (online) {
|
|
5344
|
+
this.healthyConnectionChangedEventCount++;
|
|
5345
|
+
// we skip the first event as we could potentially be querying twice
|
|
5346
|
+
if (this.healthyConnectionChangedEventCount > 1) {
|
|
5347
|
+
for (const activeFeed of Object.values(this.activeFeeds)) {
|
|
5348
|
+
activeFeed.synchronize();
|
|
5349
|
+
}
|
|
5350
|
+
}
|
|
5351
|
+
}
|
|
5329
5352
|
break;
|
|
5330
5353
|
}
|
|
5331
5354
|
case 'feeds.feed.created': {
|