@stream-io/feeds-client 0.1.3 → 0.1.5
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/@react-bindings/hooks/client-state-hooks/index.ts +2 -0
- package/@react-bindings/hooks/feed-state-hooks/index.ts +5 -0
- package/@react-bindings/hooks/internal/index.ts +1 -0
- package/@react-bindings/hooks/util/index.ts +1 -0
- package/@react-bindings/index.ts +6 -3
- package/CHANGELOG.md +21 -0
- package/dist/@react-bindings/contexts/StreamFeedContext.d.ts +12 -0
- package/dist/@react-bindings/hooks/client-state-hooks/index.d.ts +2 -0
- package/dist/@react-bindings/hooks/client-state-hooks/useClientConnectedUser.d.ts +4 -0
- package/dist/@react-bindings/hooks/client-state-hooks/useWsConnectionState.d.ts +6 -0
- package/dist/@react-bindings/hooks/feed-state-hooks/index.d.ts +5 -0
- package/dist/@react-bindings/hooks/feed-state-hooks/useComments.d.ts +19 -0
- package/dist/@react-bindings/hooks/feed-state-hooks/useFeedActivities.d.ts +11 -0
- package/dist/@react-bindings/hooks/feed-state-hooks/useFollowers.d.ts +16 -0
- package/dist/@react-bindings/hooks/feed-state-hooks/useFollowing.d.ts +16 -0
- package/dist/@react-bindings/hooks/{useOwnCapabilities.d.ts → feed-state-hooks/useOwnCapabilities.d.ts} +2 -2
- package/dist/@react-bindings/hooks/internal/index.d.ts +1 -0
- package/dist/@react-bindings/hooks/internal/useStableCallback.d.ts +25 -0
- package/dist/@react-bindings/hooks/util/index.d.ts +1 -0
- package/dist/@react-bindings/hooks/util/useReactionActions.d.ts +17 -0
- package/dist/@react-bindings/index.d.ts +5 -3
- package/dist/@react-bindings/wrappers/StreamFeed.d.ts +12 -0
- package/dist/index-react-bindings.browser.cjs +456 -183
- package/dist/index-react-bindings.browser.cjs.map +1 -1
- package/dist/index-react-bindings.browser.js +451 -185
- package/dist/index-react-bindings.browser.js.map +1 -1
- package/dist/index-react-bindings.node.cjs +456 -183
- package/dist/index-react-bindings.node.cjs.map +1 -1
- package/dist/index-react-bindings.node.js +451 -185
- package/dist/index-react-bindings.node.js.map +1 -1
- package/dist/index.browser.cjs +172 -72
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +169 -73
- package/dist/index.browser.js.map +1 -1
- package/dist/index.node.cjs +172 -72
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +169 -73
- package/dist/index.node.js.map +1 -1
- package/dist/src/Feed.d.ts +7 -3
- package/dist/src/FeedsClient.d.ts +4 -3
- package/dist/src/gen/models/index.d.ts +92 -15
- package/dist/src/types.d.ts +7 -0
- package/dist/src/utils.d.ts +9 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -1
- package/src/Feed.ts +200 -89
- package/src/FeedsClient.ts +8 -3
- package/src/common/real-time/StableWSConnection.ts +4 -1
- package/src/gen/feeds/FeedsApi.ts +5 -0
- package/src/gen/models/index.ts +143 -17
- package/src/types.ts +12 -1
- package/src/utils.ts +25 -1
- package/dist/@react-bindings/hooks/clientStateHooks.d.ts +0 -10
- package/dist/@react-bindings/hooks/useComments.d.ts +0 -12
package/dist/index.node.cjs
CHANGED
|
@@ -1627,6 +1627,7 @@ class FeedsApi {
|
|
|
1627
1627
|
};
|
|
1628
1628
|
const body = {
|
|
1629
1629
|
type: request?.type,
|
|
1630
|
+
create_notification_activity: request?.create_notification_activity,
|
|
1630
1631
|
custom: request?.custom,
|
|
1631
1632
|
};
|
|
1632
1633
|
const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/activities/{activity_id}/reactions', pathParams, undefined, body, 'application/json');
|
|
@@ -1721,6 +1722,7 @@ class FeedsApi {
|
|
|
1721
1722
|
comment: request?.comment,
|
|
1722
1723
|
object_id: request?.object_id,
|
|
1723
1724
|
object_type: request?.object_type,
|
|
1725
|
+
create_notification_activity: request?.create_notification_activity,
|
|
1724
1726
|
parent_id: request?.parent_id,
|
|
1725
1727
|
attachments: request?.attachments,
|
|
1726
1728
|
mentioned_user_ids: request?.mentioned_user_ids,
|
|
@@ -1784,6 +1786,7 @@ class FeedsApi {
|
|
|
1784
1786
|
};
|
|
1785
1787
|
const body = {
|
|
1786
1788
|
type: request?.type,
|
|
1789
|
+
create_notification_activity: request?.create_notification_activity,
|
|
1787
1790
|
custom: request?.custom,
|
|
1788
1791
|
};
|
|
1789
1792
|
const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/comments/{comment_id}/reactions', pathParams, undefined, body, 'application/json');
|
|
@@ -2009,6 +2012,7 @@ class FeedsApi {
|
|
|
2009
2012
|
const body = {
|
|
2010
2013
|
source: request?.source,
|
|
2011
2014
|
target: request?.target,
|
|
2015
|
+
create_notification_activity: request?.create_notification_activity,
|
|
2012
2016
|
follower_role: request?.follower_role,
|
|
2013
2017
|
push_preference: request?.push_preference,
|
|
2014
2018
|
custom: request?.custom,
|
|
@@ -2021,6 +2025,7 @@ class FeedsApi {
|
|
|
2021
2025
|
const body = {
|
|
2022
2026
|
source: request?.source,
|
|
2023
2027
|
target: request?.target,
|
|
2028
|
+
create_notification_activity: request?.create_notification_activity,
|
|
2024
2029
|
push_preference: request?.push_preference,
|
|
2025
2030
|
custom: request?.custom,
|
|
2026
2031
|
};
|
|
@@ -2683,6 +2688,13 @@ function removeConnectionEventListeners(cb) {
|
|
|
2683
2688
|
window.removeEventListener('online', cb);
|
|
2684
2689
|
}
|
|
2685
2690
|
}
|
|
2691
|
+
const streamDevToken = (userId) => {
|
|
2692
|
+
return [
|
|
2693
|
+
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9', // {"alg": "HS256", "typ": "JWT"}
|
|
2694
|
+
window.btoa(JSON.stringify({ user_id: userId })),
|
|
2695
|
+
'devtoken', // hardcoded signature
|
|
2696
|
+
].join('.');
|
|
2697
|
+
};
|
|
2686
2698
|
const debounce = (fn, timeout = 0, { leading = false, trailing = true, } = {}) => {
|
|
2687
2699
|
let runningTimeout = null;
|
|
2688
2700
|
let argsForTrailingExecution = null;
|
|
@@ -2992,7 +3004,10 @@ class StableWSConnection {
|
|
|
2992
3004
|
this.onmessage = (wsID, event) => {
|
|
2993
3005
|
if (this.wsID !== wsID)
|
|
2994
3006
|
return;
|
|
2995
|
-
this._log('onmessage() - onmessage callback', {
|
|
3007
|
+
this._log('onmessage() - onmessage callback', {
|
|
3008
|
+
event: { ...event, data: JSON.parse(event.data) },
|
|
3009
|
+
wsID,
|
|
3010
|
+
});
|
|
2996
3011
|
let data = typeof event.data === 'string' ? JSON.parse(event.data) : null;
|
|
2997
3012
|
this.decoders.forEach((decode) => {
|
|
2998
3013
|
data = decode(data);
|
|
@@ -4007,8 +4022,22 @@ const updateBookmarkInActivities = (event, activities, isCurrentUser) => {
|
|
|
4007
4022
|
return updateActivityInActivities(updatedActivity, activities);
|
|
4008
4023
|
};
|
|
4009
4024
|
|
|
4010
|
-
const
|
|
4011
|
-
|
|
4025
|
+
const isImageFile = (file) => {
|
|
4026
|
+
// photoshop files begin with 'image/'
|
|
4027
|
+
return file.type.startsWith('image/') && !file.type.endsWith('.photoshop');
|
|
4028
|
+
};
|
|
4029
|
+
const isVideoFile = (file) => {
|
|
4030
|
+
return file.type.startsWith('video/');
|
|
4031
|
+
};
|
|
4032
|
+
const checkHasAnotherPage = (v, cursor) => (typeof v === 'undefined' && typeof cursor === 'undefined') ||
|
|
4033
|
+
typeof cursor === 'string';
|
|
4034
|
+
const isCommentResponse = (entity) => {
|
|
4035
|
+
return typeof entity?.object_id === 'string';
|
|
4036
|
+
};
|
|
4037
|
+
const Constants = {
|
|
4038
|
+
DEFAULT_COMMENT_PAGINATION: 'first',
|
|
4039
|
+
};
|
|
4040
|
+
|
|
4012
4041
|
class Feed extends FeedApi {
|
|
4013
4042
|
constructor(client, groupId, id, data) {
|
|
4014
4043
|
// Need this ugly cast because fileUpload endpoints :(
|
|
@@ -4081,7 +4110,7 @@ class Feed extends FeedApi {
|
|
|
4081
4110
|
const entityState = currentState.comments_by_entity_id[forId];
|
|
4082
4111
|
const newComments = entityState?.comments?.concat([]) ?? [];
|
|
4083
4112
|
if (entityState?.pagination?.sort === 'last' &&
|
|
4084
|
-
entityState?.pagination.next
|
|
4113
|
+
!checkHasAnotherPage(entityState.comments, entityState?.pagination.next)) {
|
|
4085
4114
|
newComments.unshift(comment);
|
|
4086
4115
|
}
|
|
4087
4116
|
else if (entityState?.pagination?.sort === 'first') {
|
|
@@ -4168,7 +4197,7 @@ class Feed extends FeedApi {
|
|
|
4168
4197
|
...currentState,
|
|
4169
4198
|
...event.follow.source_feed,
|
|
4170
4199
|
};
|
|
4171
|
-
if (currentState.following_pagination?.next
|
|
4200
|
+
if (!checkHasAnotherPage(currentState.following, currentState.following_pagination?.next)) {
|
|
4172
4201
|
// TODO: respect sort
|
|
4173
4202
|
newState.following = currentState.following
|
|
4174
4203
|
? currentState.following.concat(event.follow)
|
|
@@ -4189,7 +4218,7 @@ class Feed extends FeedApi {
|
|
|
4189
4218
|
? currentState.own_follows.concat(event.follow)
|
|
4190
4219
|
: [event.follow];
|
|
4191
4220
|
}
|
|
4192
|
-
if (currentState.followers_pagination?.next
|
|
4221
|
+
if (!checkHasAnotherPage(currentState.followers, currentState.followers_pagination?.next)) {
|
|
4193
4222
|
// TODO: respect sort
|
|
4194
4223
|
newState.followers = currentState.followers
|
|
4195
4224
|
? currentState.followers.concat(event.follow)
|
|
@@ -4230,40 +4259,60 @@ class Feed extends FeedApi {
|
|
|
4230
4259
|
'feeds.comment.reaction.deleted': this.handleCommentReactionEvent.bind(this),
|
|
4231
4260
|
'feeds.comment.reaction.updated': Feed.noop,
|
|
4232
4261
|
'feeds.feed_member.added': (event) => {
|
|
4233
|
-
const {
|
|
4234
|
-
// do not add a member if the pagination has reached the end of the list
|
|
4235
|
-
if (this.currentState.member_pagination?.next !== END_OF_LIST)
|
|
4236
|
-
return;
|
|
4262
|
+
const { connectedUser } = this.client.state.getLatestValue();
|
|
4237
4263
|
this.state.next((currentState) => {
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4264
|
+
let newState;
|
|
4265
|
+
if (!checkHasAnotherPage(currentState.members, currentState.member_pagination?.next)) {
|
|
4266
|
+
newState ?? (newState = {
|
|
4267
|
+
...currentState,
|
|
4268
|
+
});
|
|
4269
|
+
newState.members = newState.members?.concat(event.member) ?? [
|
|
4270
|
+
event.member,
|
|
4271
|
+
];
|
|
4272
|
+
}
|
|
4273
|
+
if (connectedUser?.id === event.member.user.id) {
|
|
4274
|
+
newState ?? (newState = {
|
|
4275
|
+
...currentState,
|
|
4276
|
+
});
|
|
4277
|
+
newState.own_membership = event.member;
|
|
4278
|
+
}
|
|
4279
|
+
return newState ?? currentState;
|
|
4245
4280
|
});
|
|
4246
4281
|
},
|
|
4247
4282
|
'feeds.feed_member.removed': (event) => {
|
|
4283
|
+
const { connectedUser } = this.client.state.getLatestValue();
|
|
4248
4284
|
this.state.next((currentState) => {
|
|
4249
|
-
|
|
4285
|
+
const newState = {
|
|
4250
4286
|
...currentState,
|
|
4251
4287
|
members: currentState.members?.filter((member) => member.user.id !== event.user?.id),
|
|
4252
4288
|
};
|
|
4289
|
+
if (connectedUser?.id === event.member_id) {
|
|
4290
|
+
delete newState.own_membership;
|
|
4291
|
+
}
|
|
4292
|
+
return newState;
|
|
4253
4293
|
});
|
|
4254
4294
|
},
|
|
4255
4295
|
'feeds.feed_member.updated': (event) => {
|
|
4296
|
+
const { connectedUser } = this.client.state.getLatestValue();
|
|
4256
4297
|
this.state.next((currentState) => {
|
|
4257
4298
|
const memberIndex = currentState.members?.findIndex((member) => member.user.id === event.member.user.id) ?? -1;
|
|
4299
|
+
let newState;
|
|
4258
4300
|
if (memberIndex !== -1) {
|
|
4301
|
+
// if there's an index, there's a member to update
|
|
4259
4302
|
const newMembers = [...currentState.members];
|
|
4260
4303
|
newMembers[memberIndex] = event.member;
|
|
4261
|
-
|
|
4304
|
+
newState ?? (newState = {
|
|
4262
4305
|
...currentState,
|
|
4263
|
-
|
|
4264
|
-
|
|
4306
|
+
});
|
|
4307
|
+
newState.members = newMembers;
|
|
4265
4308
|
}
|
|
4266
|
-
|
|
4309
|
+
if (connectedUser?.id === event.member.user.id) {
|
|
4310
|
+
newState ?? (newState = {
|
|
4311
|
+
...currentState,
|
|
4312
|
+
});
|
|
4313
|
+
newState.own_membership = event.member;
|
|
4314
|
+
}
|
|
4315
|
+
return newState ?? currentState;
|
|
4267
4316
|
});
|
|
4268
4317
|
},
|
|
4269
4318
|
// the poll events should be removed from here
|
|
@@ -4389,29 +4438,6 @@ class Feed extends FeedApi {
|
|
|
4389
4438
|
...currentState,
|
|
4390
4439
|
...responseCopy,
|
|
4391
4440
|
};
|
|
4392
|
-
// if there is no next cursor, set it to END_OF_LIST
|
|
4393
|
-
// request has to have a limit set for this to work
|
|
4394
|
-
if ((request?.followers_pagination?.limit ?? 0) > 0 &&
|
|
4395
|
-
typeof nextState.followers_pagination?.next === 'undefined') {
|
|
4396
|
-
nextState.followers_pagination = {
|
|
4397
|
-
...nextState.followers_pagination,
|
|
4398
|
-
next: END_OF_LIST,
|
|
4399
|
-
};
|
|
4400
|
-
}
|
|
4401
|
-
if ((request?.following_pagination?.limit ?? 0) > 0 &&
|
|
4402
|
-
typeof nextState.following_pagination?.next === 'undefined') {
|
|
4403
|
-
nextState.following_pagination = {
|
|
4404
|
-
...nextState.following_pagination,
|
|
4405
|
-
next: END_OF_LIST,
|
|
4406
|
-
};
|
|
4407
|
-
}
|
|
4408
|
-
if ((request?.member_pagination?.limit ?? 0) > 0 &&
|
|
4409
|
-
typeof nextState.member_pagination?.next === 'undefined') {
|
|
4410
|
-
nextState.member_pagination = {
|
|
4411
|
-
...nextState.member_pagination,
|
|
4412
|
-
next: END_OF_LIST,
|
|
4413
|
-
};
|
|
4414
|
-
}
|
|
4415
4441
|
if (!request?.followers_pagination?.limit) {
|
|
4416
4442
|
delete nextState.followers;
|
|
4417
4443
|
}
|
|
@@ -4502,6 +4528,7 @@ class Feed extends FeedApi {
|
|
|
4502
4528
|
});
|
|
4503
4529
|
}
|
|
4504
4530
|
async loadNextPageComments({ forId, base, sort, parentId, }) {
|
|
4531
|
+
let error;
|
|
4505
4532
|
try {
|
|
4506
4533
|
this.state.next((currentState) => ({
|
|
4507
4534
|
...currentState,
|
|
@@ -4516,7 +4543,7 @@ class Feed extends FeedApi {
|
|
|
4516
4543
|
},
|
|
4517
4544
|
},
|
|
4518
4545
|
}));
|
|
4519
|
-
const { next: newNextCursor
|
|
4546
|
+
const { next: newNextCursor, comments } = await base();
|
|
4520
4547
|
this.state.next((currentState) => {
|
|
4521
4548
|
const newPagination = {
|
|
4522
4549
|
...currentState.comments_by_entity_id[forId]?.pagination,
|
|
@@ -4541,9 +4568,8 @@ class Feed extends FeedApi {
|
|
|
4541
4568
|
};
|
|
4542
4569
|
});
|
|
4543
4570
|
}
|
|
4544
|
-
catch (
|
|
4545
|
-
|
|
4546
|
-
// TODO: figure out how to handle errorss
|
|
4571
|
+
catch (e) {
|
|
4572
|
+
error = e;
|
|
4547
4573
|
}
|
|
4548
4574
|
finally {
|
|
4549
4575
|
this.state.next((currentState) => ({
|
|
@@ -4560,15 +4586,21 @@ class Feed extends FeedApi {
|
|
|
4560
4586
|
},
|
|
4561
4587
|
}));
|
|
4562
4588
|
}
|
|
4589
|
+
if (error) {
|
|
4590
|
+
throw error;
|
|
4591
|
+
}
|
|
4563
4592
|
}
|
|
4564
4593
|
async loadNextPageActivityComments(activity, request) {
|
|
4565
|
-
const
|
|
4566
|
-
const
|
|
4567
|
-
const
|
|
4568
|
-
const
|
|
4569
|
-
const
|
|
4570
|
-
|
|
4594
|
+
const currentEntityState = this.currentState.comments_by_entity_id[activity.id];
|
|
4595
|
+
const currentPagination = currentEntityState?.pagination;
|
|
4596
|
+
const currentNextCursor = currentPagination?.next;
|
|
4597
|
+
const currentSort = currentPagination?.sort;
|
|
4598
|
+
const isLoading = currentPagination?.loading_next_page;
|
|
4599
|
+
const sort = currentSort ?? request?.sort ?? Constants.DEFAULT_COMMENT_PAGINATION;
|
|
4600
|
+
if (isLoading ||
|
|
4601
|
+
!checkHasAnotherPage(currentEntityState?.comments, currentNextCursor)) {
|
|
4571
4602
|
return;
|
|
4603
|
+
}
|
|
4572
4604
|
await this.loadNextPageComments({
|
|
4573
4605
|
forId: activity.id,
|
|
4574
4606
|
base: () => this.client.getComments({
|
|
@@ -4582,20 +4614,25 @@ class Feed extends FeedApi {
|
|
|
4582
4614
|
});
|
|
4583
4615
|
}
|
|
4584
4616
|
async loadNextPageCommentReplies(comment, request) {
|
|
4585
|
-
const
|
|
4586
|
-
const
|
|
4587
|
-
const
|
|
4588
|
-
const
|
|
4589
|
-
const
|
|
4590
|
-
|
|
4617
|
+
const currentEntityState = this.currentState.comments_by_entity_id[comment.id];
|
|
4618
|
+
const currentPagination = currentEntityState?.pagination;
|
|
4619
|
+
const currentNextCursor = currentPagination?.next;
|
|
4620
|
+
const currentSort = currentPagination?.sort;
|
|
4621
|
+
const isLoading = currentPagination?.loading_next_page;
|
|
4622
|
+
const sort = currentSort ?? request?.sort ?? Constants.DEFAULT_COMMENT_PAGINATION;
|
|
4623
|
+
if (isLoading ||
|
|
4624
|
+
!checkHasAnotherPage(currentEntityState?.comments, currentNextCursor)) {
|
|
4591
4625
|
return;
|
|
4626
|
+
}
|
|
4592
4627
|
await this.loadNextPageComments({
|
|
4593
4628
|
forId: comment.id,
|
|
4594
4629
|
base: () => this.client.getCommentReplies({
|
|
4595
4630
|
...request,
|
|
4596
4631
|
comment_id: comment.id,
|
|
4597
4632
|
// use known sort first (prevents broken pagination)
|
|
4598
|
-
sort: currentSort ??
|
|
4633
|
+
sort: currentSort ??
|
|
4634
|
+
request?.sort ??
|
|
4635
|
+
Constants.DEFAULT_COMMENT_PAGINATION,
|
|
4599
4636
|
next: currentNextCursor,
|
|
4600
4637
|
}),
|
|
4601
4638
|
parentId: comment.parent_id ?? comment.object_id,
|
|
@@ -4605,10 +4642,14 @@ class Feed extends FeedApi {
|
|
|
4605
4642
|
async loadNextPageFollows(type, request) {
|
|
4606
4643
|
const paginationKey = `${type}_pagination`;
|
|
4607
4644
|
const method = `query${capitalize(type)}`;
|
|
4645
|
+
const currentFollows = this.currentState[type];
|
|
4608
4646
|
const currentNextCursor = this.currentState[paginationKey]?.next;
|
|
4609
4647
|
const isLoading = this.currentState[paginationKey]?.loading_next_page;
|
|
4610
|
-
|
|
4648
|
+
const sort = this.currentState[paginationKey]?.sort ?? request.sort;
|
|
4649
|
+
let error;
|
|
4650
|
+
if (isLoading || !checkHasAnotherPage(currentFollows, currentNextCursor)) {
|
|
4611
4651
|
return;
|
|
4652
|
+
}
|
|
4612
4653
|
try {
|
|
4613
4654
|
this.state.next((currentState) => {
|
|
4614
4655
|
return {
|
|
@@ -4619,9 +4660,10 @@ class Feed extends FeedApi {
|
|
|
4619
4660
|
},
|
|
4620
4661
|
};
|
|
4621
4662
|
});
|
|
4622
|
-
const { next: newNextCursor
|
|
4663
|
+
const { next: newNextCursor, follows } = await this[method]({
|
|
4623
4664
|
...request,
|
|
4624
4665
|
next: currentNextCursor,
|
|
4666
|
+
sort,
|
|
4625
4667
|
});
|
|
4626
4668
|
this.state.next((currentState) => ({
|
|
4627
4669
|
...currentState,
|
|
@@ -4631,12 +4673,12 @@ class Feed extends FeedApi {
|
|
|
4631
4673
|
[paginationKey]: {
|
|
4632
4674
|
...currentState[paginationKey],
|
|
4633
4675
|
next: newNextCursor,
|
|
4676
|
+
sort,
|
|
4634
4677
|
},
|
|
4635
4678
|
}));
|
|
4636
4679
|
}
|
|
4637
|
-
catch (
|
|
4638
|
-
|
|
4639
|
-
// TODO: figure out how to handle errorss
|
|
4680
|
+
catch (e) {
|
|
4681
|
+
error = e;
|
|
4640
4682
|
}
|
|
4641
4683
|
finally {
|
|
4642
4684
|
this.state.next((currentState) => {
|
|
@@ -4649,6 +4691,9 @@ class Feed extends FeedApi {
|
|
|
4649
4691
|
};
|
|
4650
4692
|
});
|
|
4651
4693
|
}
|
|
4694
|
+
if (error) {
|
|
4695
|
+
throw error;
|
|
4696
|
+
}
|
|
4652
4697
|
}
|
|
4653
4698
|
async loadNextPageFollowers(request) {
|
|
4654
4699
|
await this.loadNextPageFollows('followers', request);
|
|
@@ -4656,6 +4701,59 @@ class Feed extends FeedApi {
|
|
|
4656
4701
|
async loadNextPageFollowing(request) {
|
|
4657
4702
|
await this.loadNextPageFollows('following', request);
|
|
4658
4703
|
}
|
|
4704
|
+
async loadNextPageMembers(request) {
|
|
4705
|
+
const currentMembers = this.currentState.members;
|
|
4706
|
+
const currentNextCursor = this.currentState.member_pagination?.next;
|
|
4707
|
+
const isLoading = this.currentState.member_pagination?.loading_next_page;
|
|
4708
|
+
const sort = this.currentState.member_pagination?.sort ?? request.sort;
|
|
4709
|
+
let error;
|
|
4710
|
+
if (isLoading || !checkHasAnotherPage(currentMembers, currentNextCursor)) {
|
|
4711
|
+
return;
|
|
4712
|
+
}
|
|
4713
|
+
try {
|
|
4714
|
+
this.state.next((currentState) => ({
|
|
4715
|
+
...currentState,
|
|
4716
|
+
member_pagination: {
|
|
4717
|
+
...currentState.member_pagination,
|
|
4718
|
+
loading_next_page: true,
|
|
4719
|
+
},
|
|
4720
|
+
}));
|
|
4721
|
+
const { next: newNextCursor, members } = await this.client.queryFeedMembers({
|
|
4722
|
+
...request,
|
|
4723
|
+
sort,
|
|
4724
|
+
feed_id: this.id,
|
|
4725
|
+
feed_group_id: this.group,
|
|
4726
|
+
next: currentNextCursor,
|
|
4727
|
+
});
|
|
4728
|
+
this.state.next((currentState) => ({
|
|
4729
|
+
...currentState,
|
|
4730
|
+
members: currentState.members
|
|
4731
|
+
? currentState.members.concat(members)
|
|
4732
|
+
: members,
|
|
4733
|
+
member_pagination: {
|
|
4734
|
+
...currentState.member_pagination,
|
|
4735
|
+
next: newNextCursor,
|
|
4736
|
+
// set sort if not defined yet
|
|
4737
|
+
sort: currentState.member_pagination?.sort ?? request.sort,
|
|
4738
|
+
},
|
|
4739
|
+
}));
|
|
4740
|
+
}
|
|
4741
|
+
catch (e) {
|
|
4742
|
+
error = e;
|
|
4743
|
+
}
|
|
4744
|
+
finally {
|
|
4745
|
+
this.state.next((currentState) => ({
|
|
4746
|
+
...currentState,
|
|
4747
|
+
member_pagination: {
|
|
4748
|
+
...currentState.member_pagination,
|
|
4749
|
+
loading_next_page: false,
|
|
4750
|
+
},
|
|
4751
|
+
}));
|
|
4752
|
+
}
|
|
4753
|
+
if (error) {
|
|
4754
|
+
throw error;
|
|
4755
|
+
}
|
|
4756
|
+
}
|
|
4659
4757
|
/**
|
|
4660
4758
|
* Method which queries followers of this feed (feeds which target this feed).
|
|
4661
4759
|
*
|
|
@@ -5146,6 +5244,9 @@ class FeedsClient extends FeedsApi {
|
|
|
5146
5244
|
throw err;
|
|
5147
5245
|
}
|
|
5148
5246
|
};
|
|
5247
|
+
this.devToken = (userId) => {
|
|
5248
|
+
return streamDevToken(userId);
|
|
5249
|
+
};
|
|
5149
5250
|
this.closePoll = async (request) => {
|
|
5150
5251
|
return await this.updatePollPartial({
|
|
5151
5252
|
poll_id: request.poll_id,
|
|
@@ -5867,14 +5968,10 @@ class FeedSearchSource extends BaseSearchSource {
|
|
|
5867
5968
|
}
|
|
5868
5969
|
}
|
|
5869
5970
|
|
|
5870
|
-
const isImageFile = (file) => {
|
|
5871
|
-
// photoshop files begin with 'image/'
|
|
5872
|
-
return file.type.startsWith('image/') && !file.type.endsWith('.photoshop');
|
|
5873
|
-
};
|
|
5874
|
-
|
|
5875
5971
|
exports.ActivitySearchSource = ActivitySearchSource;
|
|
5876
5972
|
exports.BaseSearchSource = BaseSearchSource;
|
|
5877
5973
|
exports.ChannelOwnCapability = ChannelOwnCapability;
|
|
5974
|
+
exports.Constants = Constants;
|
|
5878
5975
|
exports.Feed = Feed;
|
|
5879
5976
|
exports.FeedOwnCapability = FeedOwnCapability;
|
|
5880
5977
|
exports.FeedSearchSource = FeedSearchSource;
|
|
@@ -5885,7 +5982,10 @@ exports.StateStore = StateStore;
|
|
|
5885
5982
|
exports.StreamApiError = StreamApiError;
|
|
5886
5983
|
exports.StreamPoll = StreamPoll;
|
|
5887
5984
|
exports.UserSearchSource = UserSearchSource;
|
|
5985
|
+
exports.checkHasAnotherPage = checkHasAnotherPage;
|
|
5986
|
+
exports.isCommentResponse = isCommentResponse;
|
|
5888
5987
|
exports.isImageFile = isImageFile;
|
|
5889
5988
|
exports.isPatch = isPatch;
|
|
5989
|
+
exports.isVideoFile = isVideoFile;
|
|
5890
5990
|
exports.isVoteAnswer = isVoteAnswer;
|
|
5891
5991
|
//# sourceMappingURL=index.node.cjs.map
|