@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.js
CHANGED
|
@@ -1625,6 +1625,7 @@ class FeedsApi {
|
|
|
1625
1625
|
};
|
|
1626
1626
|
const body = {
|
|
1627
1627
|
type: request?.type,
|
|
1628
|
+
create_notification_activity: request?.create_notification_activity,
|
|
1628
1629
|
custom: request?.custom,
|
|
1629
1630
|
};
|
|
1630
1631
|
const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/activities/{activity_id}/reactions', pathParams, undefined, body, 'application/json');
|
|
@@ -1719,6 +1720,7 @@ class FeedsApi {
|
|
|
1719
1720
|
comment: request?.comment,
|
|
1720
1721
|
object_id: request?.object_id,
|
|
1721
1722
|
object_type: request?.object_type,
|
|
1723
|
+
create_notification_activity: request?.create_notification_activity,
|
|
1722
1724
|
parent_id: request?.parent_id,
|
|
1723
1725
|
attachments: request?.attachments,
|
|
1724
1726
|
mentioned_user_ids: request?.mentioned_user_ids,
|
|
@@ -1782,6 +1784,7 @@ class FeedsApi {
|
|
|
1782
1784
|
};
|
|
1783
1785
|
const body = {
|
|
1784
1786
|
type: request?.type,
|
|
1787
|
+
create_notification_activity: request?.create_notification_activity,
|
|
1785
1788
|
custom: request?.custom,
|
|
1786
1789
|
};
|
|
1787
1790
|
const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/comments/{comment_id}/reactions', pathParams, undefined, body, 'application/json');
|
|
@@ -2007,6 +2010,7 @@ class FeedsApi {
|
|
|
2007
2010
|
const body = {
|
|
2008
2011
|
source: request?.source,
|
|
2009
2012
|
target: request?.target,
|
|
2013
|
+
create_notification_activity: request?.create_notification_activity,
|
|
2010
2014
|
follower_role: request?.follower_role,
|
|
2011
2015
|
push_preference: request?.push_preference,
|
|
2012
2016
|
custom: request?.custom,
|
|
@@ -2019,6 +2023,7 @@ class FeedsApi {
|
|
|
2019
2023
|
const body = {
|
|
2020
2024
|
source: request?.source,
|
|
2021
2025
|
target: request?.target,
|
|
2026
|
+
create_notification_activity: request?.create_notification_activity,
|
|
2022
2027
|
push_preference: request?.push_preference,
|
|
2023
2028
|
custom: request?.custom,
|
|
2024
2029
|
};
|
|
@@ -2681,6 +2686,13 @@ function removeConnectionEventListeners(cb) {
|
|
|
2681
2686
|
window.removeEventListener('online', cb);
|
|
2682
2687
|
}
|
|
2683
2688
|
}
|
|
2689
|
+
const streamDevToken = (userId) => {
|
|
2690
|
+
return [
|
|
2691
|
+
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9', // {"alg": "HS256", "typ": "JWT"}
|
|
2692
|
+
window.btoa(JSON.stringify({ user_id: userId })),
|
|
2693
|
+
'devtoken', // hardcoded signature
|
|
2694
|
+
].join('.');
|
|
2695
|
+
};
|
|
2684
2696
|
const debounce = (fn, timeout = 0, { leading = false, trailing = true, } = {}) => {
|
|
2685
2697
|
let runningTimeout = null;
|
|
2686
2698
|
let argsForTrailingExecution = null;
|
|
@@ -2990,7 +3002,10 @@ class StableWSConnection {
|
|
|
2990
3002
|
this.onmessage = (wsID, event) => {
|
|
2991
3003
|
if (this.wsID !== wsID)
|
|
2992
3004
|
return;
|
|
2993
|
-
this._log('onmessage() - onmessage callback', {
|
|
3005
|
+
this._log('onmessage() - onmessage callback', {
|
|
3006
|
+
event: { ...event, data: JSON.parse(event.data) },
|
|
3007
|
+
wsID,
|
|
3008
|
+
});
|
|
2994
3009
|
let data = typeof event.data === 'string' ? JSON.parse(event.data) : null;
|
|
2995
3010
|
this.decoders.forEach((decode) => {
|
|
2996
3011
|
data = decode(data);
|
|
@@ -4005,8 +4020,22 @@ const updateBookmarkInActivities = (event, activities, isCurrentUser) => {
|
|
|
4005
4020
|
return updateActivityInActivities(updatedActivity, activities);
|
|
4006
4021
|
};
|
|
4007
4022
|
|
|
4008
|
-
const
|
|
4009
|
-
|
|
4023
|
+
const isImageFile = (file) => {
|
|
4024
|
+
// photoshop files begin with 'image/'
|
|
4025
|
+
return file.type.startsWith('image/') && !file.type.endsWith('.photoshop');
|
|
4026
|
+
};
|
|
4027
|
+
const isVideoFile = (file) => {
|
|
4028
|
+
return file.type.startsWith('video/');
|
|
4029
|
+
};
|
|
4030
|
+
const checkHasAnotherPage = (v, cursor) => (typeof v === 'undefined' && typeof cursor === 'undefined') ||
|
|
4031
|
+
typeof cursor === 'string';
|
|
4032
|
+
const isCommentResponse = (entity) => {
|
|
4033
|
+
return typeof entity?.object_id === 'string';
|
|
4034
|
+
};
|
|
4035
|
+
const Constants = {
|
|
4036
|
+
DEFAULT_COMMENT_PAGINATION: 'first',
|
|
4037
|
+
};
|
|
4038
|
+
|
|
4010
4039
|
class Feed extends FeedApi {
|
|
4011
4040
|
constructor(client, groupId, id, data) {
|
|
4012
4041
|
// Need this ugly cast because fileUpload endpoints :(
|
|
@@ -4079,7 +4108,7 @@ class Feed extends FeedApi {
|
|
|
4079
4108
|
const entityState = currentState.comments_by_entity_id[forId];
|
|
4080
4109
|
const newComments = entityState?.comments?.concat([]) ?? [];
|
|
4081
4110
|
if (entityState?.pagination?.sort === 'last' &&
|
|
4082
|
-
entityState?.pagination.next
|
|
4111
|
+
!checkHasAnotherPage(entityState.comments, entityState?.pagination.next)) {
|
|
4083
4112
|
newComments.unshift(comment);
|
|
4084
4113
|
}
|
|
4085
4114
|
else if (entityState?.pagination?.sort === 'first') {
|
|
@@ -4166,7 +4195,7 @@ class Feed extends FeedApi {
|
|
|
4166
4195
|
...currentState,
|
|
4167
4196
|
...event.follow.source_feed,
|
|
4168
4197
|
};
|
|
4169
|
-
if (currentState.following_pagination?.next
|
|
4198
|
+
if (!checkHasAnotherPage(currentState.following, currentState.following_pagination?.next)) {
|
|
4170
4199
|
// TODO: respect sort
|
|
4171
4200
|
newState.following = currentState.following
|
|
4172
4201
|
? currentState.following.concat(event.follow)
|
|
@@ -4187,7 +4216,7 @@ class Feed extends FeedApi {
|
|
|
4187
4216
|
? currentState.own_follows.concat(event.follow)
|
|
4188
4217
|
: [event.follow];
|
|
4189
4218
|
}
|
|
4190
|
-
if (currentState.followers_pagination?.next
|
|
4219
|
+
if (!checkHasAnotherPage(currentState.followers, currentState.followers_pagination?.next)) {
|
|
4191
4220
|
// TODO: respect sort
|
|
4192
4221
|
newState.followers = currentState.followers
|
|
4193
4222
|
? currentState.followers.concat(event.follow)
|
|
@@ -4228,40 +4257,60 @@ class Feed extends FeedApi {
|
|
|
4228
4257
|
'feeds.comment.reaction.deleted': this.handleCommentReactionEvent.bind(this),
|
|
4229
4258
|
'feeds.comment.reaction.updated': Feed.noop,
|
|
4230
4259
|
'feeds.feed_member.added': (event) => {
|
|
4231
|
-
const {
|
|
4232
|
-
// do not add a member if the pagination has reached the end of the list
|
|
4233
|
-
if (this.currentState.member_pagination?.next !== END_OF_LIST)
|
|
4234
|
-
return;
|
|
4260
|
+
const { connectedUser } = this.client.state.getLatestValue();
|
|
4235
4261
|
this.state.next((currentState) => {
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4262
|
+
let newState;
|
|
4263
|
+
if (!checkHasAnotherPage(currentState.members, currentState.member_pagination?.next)) {
|
|
4264
|
+
newState ?? (newState = {
|
|
4265
|
+
...currentState,
|
|
4266
|
+
});
|
|
4267
|
+
newState.members = newState.members?.concat(event.member) ?? [
|
|
4268
|
+
event.member,
|
|
4269
|
+
];
|
|
4270
|
+
}
|
|
4271
|
+
if (connectedUser?.id === event.member.user.id) {
|
|
4272
|
+
newState ?? (newState = {
|
|
4273
|
+
...currentState,
|
|
4274
|
+
});
|
|
4275
|
+
newState.own_membership = event.member;
|
|
4276
|
+
}
|
|
4277
|
+
return newState ?? currentState;
|
|
4243
4278
|
});
|
|
4244
4279
|
},
|
|
4245
4280
|
'feeds.feed_member.removed': (event) => {
|
|
4281
|
+
const { connectedUser } = this.client.state.getLatestValue();
|
|
4246
4282
|
this.state.next((currentState) => {
|
|
4247
|
-
|
|
4283
|
+
const newState = {
|
|
4248
4284
|
...currentState,
|
|
4249
4285
|
members: currentState.members?.filter((member) => member.user.id !== event.user?.id),
|
|
4250
4286
|
};
|
|
4287
|
+
if (connectedUser?.id === event.member_id) {
|
|
4288
|
+
delete newState.own_membership;
|
|
4289
|
+
}
|
|
4290
|
+
return newState;
|
|
4251
4291
|
});
|
|
4252
4292
|
},
|
|
4253
4293
|
'feeds.feed_member.updated': (event) => {
|
|
4294
|
+
const { connectedUser } = this.client.state.getLatestValue();
|
|
4254
4295
|
this.state.next((currentState) => {
|
|
4255
4296
|
const memberIndex = currentState.members?.findIndex((member) => member.user.id === event.member.user.id) ?? -1;
|
|
4297
|
+
let newState;
|
|
4256
4298
|
if (memberIndex !== -1) {
|
|
4299
|
+
// if there's an index, there's a member to update
|
|
4257
4300
|
const newMembers = [...currentState.members];
|
|
4258
4301
|
newMembers[memberIndex] = event.member;
|
|
4259
|
-
|
|
4302
|
+
newState ?? (newState = {
|
|
4260
4303
|
...currentState,
|
|
4261
|
-
|
|
4262
|
-
|
|
4304
|
+
});
|
|
4305
|
+
newState.members = newMembers;
|
|
4263
4306
|
}
|
|
4264
|
-
|
|
4307
|
+
if (connectedUser?.id === event.member.user.id) {
|
|
4308
|
+
newState ?? (newState = {
|
|
4309
|
+
...currentState,
|
|
4310
|
+
});
|
|
4311
|
+
newState.own_membership = event.member;
|
|
4312
|
+
}
|
|
4313
|
+
return newState ?? currentState;
|
|
4265
4314
|
});
|
|
4266
4315
|
},
|
|
4267
4316
|
// the poll events should be removed from here
|
|
@@ -4387,29 +4436,6 @@ class Feed extends FeedApi {
|
|
|
4387
4436
|
...currentState,
|
|
4388
4437
|
...responseCopy,
|
|
4389
4438
|
};
|
|
4390
|
-
// if there is no next cursor, set it to END_OF_LIST
|
|
4391
|
-
// request has to have a limit set for this to work
|
|
4392
|
-
if ((request?.followers_pagination?.limit ?? 0) > 0 &&
|
|
4393
|
-
typeof nextState.followers_pagination?.next === 'undefined') {
|
|
4394
|
-
nextState.followers_pagination = {
|
|
4395
|
-
...nextState.followers_pagination,
|
|
4396
|
-
next: END_OF_LIST,
|
|
4397
|
-
};
|
|
4398
|
-
}
|
|
4399
|
-
if ((request?.following_pagination?.limit ?? 0) > 0 &&
|
|
4400
|
-
typeof nextState.following_pagination?.next === 'undefined') {
|
|
4401
|
-
nextState.following_pagination = {
|
|
4402
|
-
...nextState.following_pagination,
|
|
4403
|
-
next: END_OF_LIST,
|
|
4404
|
-
};
|
|
4405
|
-
}
|
|
4406
|
-
if ((request?.member_pagination?.limit ?? 0) > 0 &&
|
|
4407
|
-
typeof nextState.member_pagination?.next === 'undefined') {
|
|
4408
|
-
nextState.member_pagination = {
|
|
4409
|
-
...nextState.member_pagination,
|
|
4410
|
-
next: END_OF_LIST,
|
|
4411
|
-
};
|
|
4412
|
-
}
|
|
4413
4439
|
if (!request?.followers_pagination?.limit) {
|
|
4414
4440
|
delete nextState.followers;
|
|
4415
4441
|
}
|
|
@@ -4500,6 +4526,7 @@ class Feed extends FeedApi {
|
|
|
4500
4526
|
});
|
|
4501
4527
|
}
|
|
4502
4528
|
async loadNextPageComments({ forId, base, sort, parentId, }) {
|
|
4529
|
+
let error;
|
|
4503
4530
|
try {
|
|
4504
4531
|
this.state.next((currentState) => ({
|
|
4505
4532
|
...currentState,
|
|
@@ -4514,7 +4541,7 @@ class Feed extends FeedApi {
|
|
|
4514
4541
|
},
|
|
4515
4542
|
},
|
|
4516
4543
|
}));
|
|
4517
|
-
const { next: newNextCursor
|
|
4544
|
+
const { next: newNextCursor, comments } = await base();
|
|
4518
4545
|
this.state.next((currentState) => {
|
|
4519
4546
|
const newPagination = {
|
|
4520
4547
|
...currentState.comments_by_entity_id[forId]?.pagination,
|
|
@@ -4539,9 +4566,8 @@ class Feed extends FeedApi {
|
|
|
4539
4566
|
};
|
|
4540
4567
|
});
|
|
4541
4568
|
}
|
|
4542
|
-
catch (
|
|
4543
|
-
|
|
4544
|
-
// TODO: figure out how to handle errorss
|
|
4569
|
+
catch (e) {
|
|
4570
|
+
error = e;
|
|
4545
4571
|
}
|
|
4546
4572
|
finally {
|
|
4547
4573
|
this.state.next((currentState) => ({
|
|
@@ -4558,15 +4584,21 @@ class Feed extends FeedApi {
|
|
|
4558
4584
|
},
|
|
4559
4585
|
}));
|
|
4560
4586
|
}
|
|
4587
|
+
if (error) {
|
|
4588
|
+
throw error;
|
|
4589
|
+
}
|
|
4561
4590
|
}
|
|
4562
4591
|
async loadNextPageActivityComments(activity, request) {
|
|
4563
|
-
const
|
|
4564
|
-
const
|
|
4565
|
-
const
|
|
4566
|
-
const
|
|
4567
|
-
const
|
|
4568
|
-
|
|
4592
|
+
const currentEntityState = this.currentState.comments_by_entity_id[activity.id];
|
|
4593
|
+
const currentPagination = currentEntityState?.pagination;
|
|
4594
|
+
const currentNextCursor = currentPagination?.next;
|
|
4595
|
+
const currentSort = currentPagination?.sort;
|
|
4596
|
+
const isLoading = currentPagination?.loading_next_page;
|
|
4597
|
+
const sort = currentSort ?? request?.sort ?? Constants.DEFAULT_COMMENT_PAGINATION;
|
|
4598
|
+
if (isLoading ||
|
|
4599
|
+
!checkHasAnotherPage(currentEntityState?.comments, currentNextCursor)) {
|
|
4569
4600
|
return;
|
|
4601
|
+
}
|
|
4570
4602
|
await this.loadNextPageComments({
|
|
4571
4603
|
forId: activity.id,
|
|
4572
4604
|
base: () => this.client.getComments({
|
|
@@ -4580,20 +4612,25 @@ class Feed extends FeedApi {
|
|
|
4580
4612
|
});
|
|
4581
4613
|
}
|
|
4582
4614
|
async loadNextPageCommentReplies(comment, request) {
|
|
4583
|
-
const
|
|
4584
|
-
const
|
|
4585
|
-
const
|
|
4586
|
-
const
|
|
4587
|
-
const
|
|
4588
|
-
|
|
4615
|
+
const currentEntityState = this.currentState.comments_by_entity_id[comment.id];
|
|
4616
|
+
const currentPagination = currentEntityState?.pagination;
|
|
4617
|
+
const currentNextCursor = currentPagination?.next;
|
|
4618
|
+
const currentSort = currentPagination?.sort;
|
|
4619
|
+
const isLoading = currentPagination?.loading_next_page;
|
|
4620
|
+
const sort = currentSort ?? request?.sort ?? Constants.DEFAULT_COMMENT_PAGINATION;
|
|
4621
|
+
if (isLoading ||
|
|
4622
|
+
!checkHasAnotherPage(currentEntityState?.comments, currentNextCursor)) {
|
|
4589
4623
|
return;
|
|
4624
|
+
}
|
|
4590
4625
|
await this.loadNextPageComments({
|
|
4591
4626
|
forId: comment.id,
|
|
4592
4627
|
base: () => this.client.getCommentReplies({
|
|
4593
4628
|
...request,
|
|
4594
4629
|
comment_id: comment.id,
|
|
4595
4630
|
// use known sort first (prevents broken pagination)
|
|
4596
|
-
sort: currentSort ??
|
|
4631
|
+
sort: currentSort ??
|
|
4632
|
+
request?.sort ??
|
|
4633
|
+
Constants.DEFAULT_COMMENT_PAGINATION,
|
|
4597
4634
|
next: currentNextCursor,
|
|
4598
4635
|
}),
|
|
4599
4636
|
parentId: comment.parent_id ?? comment.object_id,
|
|
@@ -4603,10 +4640,14 @@ class Feed extends FeedApi {
|
|
|
4603
4640
|
async loadNextPageFollows(type, request) {
|
|
4604
4641
|
const paginationKey = `${type}_pagination`;
|
|
4605
4642
|
const method = `query${capitalize(type)}`;
|
|
4643
|
+
const currentFollows = this.currentState[type];
|
|
4606
4644
|
const currentNextCursor = this.currentState[paginationKey]?.next;
|
|
4607
4645
|
const isLoading = this.currentState[paginationKey]?.loading_next_page;
|
|
4608
|
-
|
|
4646
|
+
const sort = this.currentState[paginationKey]?.sort ?? request.sort;
|
|
4647
|
+
let error;
|
|
4648
|
+
if (isLoading || !checkHasAnotherPage(currentFollows, currentNextCursor)) {
|
|
4609
4649
|
return;
|
|
4650
|
+
}
|
|
4610
4651
|
try {
|
|
4611
4652
|
this.state.next((currentState) => {
|
|
4612
4653
|
return {
|
|
@@ -4617,9 +4658,10 @@ class Feed extends FeedApi {
|
|
|
4617
4658
|
},
|
|
4618
4659
|
};
|
|
4619
4660
|
});
|
|
4620
|
-
const { next: newNextCursor
|
|
4661
|
+
const { next: newNextCursor, follows } = await this[method]({
|
|
4621
4662
|
...request,
|
|
4622
4663
|
next: currentNextCursor,
|
|
4664
|
+
sort,
|
|
4623
4665
|
});
|
|
4624
4666
|
this.state.next((currentState) => ({
|
|
4625
4667
|
...currentState,
|
|
@@ -4629,12 +4671,12 @@ class Feed extends FeedApi {
|
|
|
4629
4671
|
[paginationKey]: {
|
|
4630
4672
|
...currentState[paginationKey],
|
|
4631
4673
|
next: newNextCursor,
|
|
4674
|
+
sort,
|
|
4632
4675
|
},
|
|
4633
4676
|
}));
|
|
4634
4677
|
}
|
|
4635
|
-
catch (
|
|
4636
|
-
|
|
4637
|
-
// TODO: figure out how to handle errorss
|
|
4678
|
+
catch (e) {
|
|
4679
|
+
error = e;
|
|
4638
4680
|
}
|
|
4639
4681
|
finally {
|
|
4640
4682
|
this.state.next((currentState) => {
|
|
@@ -4647,6 +4689,9 @@ class Feed extends FeedApi {
|
|
|
4647
4689
|
};
|
|
4648
4690
|
});
|
|
4649
4691
|
}
|
|
4692
|
+
if (error) {
|
|
4693
|
+
throw error;
|
|
4694
|
+
}
|
|
4650
4695
|
}
|
|
4651
4696
|
async loadNextPageFollowers(request) {
|
|
4652
4697
|
await this.loadNextPageFollows('followers', request);
|
|
@@ -4654,6 +4699,59 @@ class Feed extends FeedApi {
|
|
|
4654
4699
|
async loadNextPageFollowing(request) {
|
|
4655
4700
|
await this.loadNextPageFollows('following', request);
|
|
4656
4701
|
}
|
|
4702
|
+
async loadNextPageMembers(request) {
|
|
4703
|
+
const currentMembers = this.currentState.members;
|
|
4704
|
+
const currentNextCursor = this.currentState.member_pagination?.next;
|
|
4705
|
+
const isLoading = this.currentState.member_pagination?.loading_next_page;
|
|
4706
|
+
const sort = this.currentState.member_pagination?.sort ?? request.sort;
|
|
4707
|
+
let error;
|
|
4708
|
+
if (isLoading || !checkHasAnotherPage(currentMembers, currentNextCursor)) {
|
|
4709
|
+
return;
|
|
4710
|
+
}
|
|
4711
|
+
try {
|
|
4712
|
+
this.state.next((currentState) => ({
|
|
4713
|
+
...currentState,
|
|
4714
|
+
member_pagination: {
|
|
4715
|
+
...currentState.member_pagination,
|
|
4716
|
+
loading_next_page: true,
|
|
4717
|
+
},
|
|
4718
|
+
}));
|
|
4719
|
+
const { next: newNextCursor, members } = await this.client.queryFeedMembers({
|
|
4720
|
+
...request,
|
|
4721
|
+
sort,
|
|
4722
|
+
feed_id: this.id,
|
|
4723
|
+
feed_group_id: this.group,
|
|
4724
|
+
next: currentNextCursor,
|
|
4725
|
+
});
|
|
4726
|
+
this.state.next((currentState) => ({
|
|
4727
|
+
...currentState,
|
|
4728
|
+
members: currentState.members
|
|
4729
|
+
? currentState.members.concat(members)
|
|
4730
|
+
: members,
|
|
4731
|
+
member_pagination: {
|
|
4732
|
+
...currentState.member_pagination,
|
|
4733
|
+
next: newNextCursor,
|
|
4734
|
+
// set sort if not defined yet
|
|
4735
|
+
sort: currentState.member_pagination?.sort ?? request.sort,
|
|
4736
|
+
},
|
|
4737
|
+
}));
|
|
4738
|
+
}
|
|
4739
|
+
catch (e) {
|
|
4740
|
+
error = e;
|
|
4741
|
+
}
|
|
4742
|
+
finally {
|
|
4743
|
+
this.state.next((currentState) => ({
|
|
4744
|
+
...currentState,
|
|
4745
|
+
member_pagination: {
|
|
4746
|
+
...currentState.member_pagination,
|
|
4747
|
+
loading_next_page: false,
|
|
4748
|
+
},
|
|
4749
|
+
}));
|
|
4750
|
+
}
|
|
4751
|
+
if (error) {
|
|
4752
|
+
throw error;
|
|
4753
|
+
}
|
|
4754
|
+
}
|
|
4657
4755
|
/**
|
|
4658
4756
|
* Method which queries followers of this feed (feeds which target this feed).
|
|
4659
4757
|
*
|
|
@@ -5144,6 +5242,9 @@ class FeedsClient extends FeedsApi {
|
|
|
5144
5242
|
throw err;
|
|
5145
5243
|
}
|
|
5146
5244
|
};
|
|
5245
|
+
this.devToken = (userId) => {
|
|
5246
|
+
return streamDevToken(userId);
|
|
5247
|
+
};
|
|
5147
5248
|
this.closePoll = async (request) => {
|
|
5148
5249
|
return await this.updatePollPartial({
|
|
5149
5250
|
poll_id: request.poll_id,
|
|
@@ -5865,10 +5966,5 @@ class FeedSearchSource extends BaseSearchSource {
|
|
|
5865
5966
|
}
|
|
5866
5967
|
}
|
|
5867
5968
|
|
|
5868
|
-
|
|
5869
|
-
// photoshop files begin with 'image/'
|
|
5870
|
-
return file.type.startsWith('image/') && !file.type.endsWith('.photoshop');
|
|
5871
|
-
};
|
|
5872
|
-
|
|
5873
|
-
export { ActivitySearchSource, BaseSearchSource, ChannelOwnCapability, Feed, FeedOwnCapability, FeedSearchSource, FeedsClient, MergedStateStore, SearchController, StateStore, StreamApiError, StreamPoll, UserSearchSource, isImageFile, isPatch, isVoteAnswer };
|
|
5969
|
+
export { ActivitySearchSource, BaseSearchSource, ChannelOwnCapability, Constants, Feed, FeedOwnCapability, FeedSearchSource, FeedsClient, MergedStateStore, SearchController, StateStore, StreamApiError, StreamPoll, UserSearchSource, checkHasAnotherPage, isCommentResponse, isImageFile, isPatch, isVideoFile, isVoteAnswer };
|
|
5874
5970
|
//# sourceMappingURL=index.node.js.map
|