@stream-io/feeds-client 0.2.2 → 0.2.4
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 +20 -0
- package/dist/@react-bindings/contexts/StreamSearchContext.d.ts +1 -1
- package/dist/@react-bindings/contexts/StreamSearchResultsContext.d.ts +1 -1
- package/dist/@react-bindings/hooks/search-state-hooks/useSearchQuery.d.ts +1 -1
- package/dist/@react-bindings/hooks/search-state-hooks/useSearchResult.d.ts +1 -1
- package/dist/@react-bindings/hooks/search-state-hooks/useSearchSources.d.ts +2 -2
- package/dist/@react-bindings/wrappers/StreamSearch.d.ts +1 -1
- package/dist/@react-bindings/wrappers/StreamSearchResults.d.ts +1 -1
- package/dist/index-react-bindings.browser.cjs +29 -9
- package/dist/index-react-bindings.browser.cjs.map +1 -1
- package/dist/index-react-bindings.browser.js +29 -9
- package/dist/index-react-bindings.browser.js.map +1 -1
- package/dist/index-react-bindings.node.cjs +29 -9
- package/dist/index-react-bindings.node.cjs.map +1 -1
- package/dist/index-react-bindings.node.js +29 -9
- package/dist/index-react-bindings.node.js.map +1 -1
- package/dist/index.browser.cjs +243 -171
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +243 -172
- package/dist/index.browser.js.map +1 -1
- package/dist/index.d.ts +1 -5
- package/dist/index.node.cjs +243 -171
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +243 -172
- package/dist/index.node.js.map +1 -1
- package/dist/src/common/{ActivitySearchSource.d.ts → search/ActivitySearchSource.d.ts} +3 -3
- package/dist/src/common/{BaseSearchSource.d.ts → search/BaseSearchSource.d.ts} +41 -35
- package/dist/src/common/{FeedSearchSource.d.ts → search/FeedSearchSource.d.ts} +5 -5
- package/dist/src/common/{SearchController.d.ts → search/SearchController.d.ts} +1 -3
- package/dist/src/common/{UserSearchSource.d.ts → search/UserSearchSource.d.ts} +4 -4
- package/dist/src/common/search/index.d.ts +6 -0
- package/dist/src/common/search/types.d.ts +22 -0
- package/dist/src/common/types.d.ts +1 -0
- package/dist/src/feed/event-handlers/activity/handle-activity-deleted.d.ts +5 -12
- package/dist/src/gen/models/index.d.ts +68 -26
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/index.ts +1 -5
- package/package.json +1 -1
- package/src/common/{ActivitySearchSource.ts → search/ActivitySearchSource.ts} +3 -3
- package/src/common/{BaseSearchSource.ts → search/BaseSearchSource.ts} +137 -69
- package/src/common/{FeedSearchSource.ts → search/FeedSearchSource.ts} +6 -5
- package/src/common/{SearchController.ts → search/SearchController.ts} +2 -7
- package/src/common/{UserSearchSource.ts → search/UserSearchSource.ts} +3 -3
- package/src/common/search/index.ts +6 -0
- package/src/common/search/types.ts +21 -0
- package/src/common/types.ts +2 -0
- package/src/feed/event-handlers/activity/activity-utils.test.ts +2 -2
- package/src/feed/event-handlers/activity/handle-activity-added.test.ts +86 -0
- package/src/feed/event-handlers/activity/handle-activity-deleted.test.ts +117 -0
- package/src/feed/event-handlers/activity/handle-activity-deleted.ts +8 -4
- package/src/feed/event-handlers/feed-member/handle-feed-member-added.test.ts +75 -0
- package/src/feed/event-handlers/feed-member/handle-feed-member-removed.test.ts +82 -0
- package/src/feed/event-handlers/feed-member/handle-feed-member-removed.ts +19 -9
- package/src/feed/event-handlers/feed-member/handle-feed-member-updated.test.ts +84 -0
- package/src/gen/feeds/FeedsApi.ts +6 -0
- package/src/gen/model-decoders/decoders.ts +13 -1
- package/src/gen/models/index.ts +108 -34
- package/src/test-utils/response-generators.ts +107 -0
- package/dist/src/test-utils/index.d.ts +0 -1
- package/dist/src/test-utils/response-generators.d.ts +0 -74
|
@@ -275,7 +275,7 @@ function useStateStore(store, selector) {
|
|
|
275
275
|
|
|
276
276
|
const decoders = {};
|
|
277
277
|
const decodeDatetimeType = (input) => typeof input === 'number'
|
|
278
|
-
? new Date(Math.floor(input /
|
|
278
|
+
? new Date(Math.floor(input / 1000000))
|
|
279
279
|
: new Date(input);
|
|
280
280
|
decoders.DatetimeType = decodeDatetimeType;
|
|
281
281
|
const decode = (typeMappings, input) => {
|
|
@@ -686,6 +686,7 @@ decoders.Command = (input) => {
|
|
|
686
686
|
decoders.CommentAddedEvent = (input) => {
|
|
687
687
|
const typeMappings = {
|
|
688
688
|
created_at: { type: 'DatetimeType', isSingle: true },
|
|
689
|
+
activity: { type: 'ActivityResponse', isSingle: true },
|
|
689
690
|
comment: { type: 'CommentResponse', isSingle: true },
|
|
690
691
|
received_at: { type: 'DatetimeType', isSingle: true },
|
|
691
692
|
};
|
|
@@ -702,6 +703,7 @@ decoders.CommentDeletedEvent = (input) => {
|
|
|
702
703
|
decoders.CommentReactionAddedEvent = (input) => {
|
|
703
704
|
const typeMappings = {
|
|
704
705
|
created_at: { type: 'DatetimeType', isSingle: true },
|
|
706
|
+
activity: { type: 'ActivityResponse', isSingle: true },
|
|
705
707
|
comment: { type: 'CommentResponse', isSingle: true },
|
|
706
708
|
reaction: { type: 'FeedsReactionResponse', isSingle: true },
|
|
707
709
|
received_at: { type: 'DatetimeType', isSingle: true },
|
|
@@ -720,6 +722,7 @@ decoders.CommentReactionDeletedEvent = (input) => {
|
|
|
720
722
|
decoders.CommentReactionUpdatedEvent = (input) => {
|
|
721
723
|
const typeMappings = {
|
|
722
724
|
created_at: { type: 'DatetimeType', isSingle: true },
|
|
725
|
+
activity: { type: 'ActivityResponse', isSingle: true },
|
|
723
726
|
comment: { type: 'CommentResponse', isSingle: true },
|
|
724
727
|
reaction: { type: 'FeedsReactionResponse', isSingle: true },
|
|
725
728
|
received_at: { type: 'DatetimeType', isSingle: true },
|
|
@@ -1082,6 +1085,7 @@ decoders.Message = (input) => {
|
|
|
1082
1085
|
pin_expires: { type: 'DatetimeType', isSingle: true },
|
|
1083
1086
|
pinned_at: { type: 'DatetimeType', isSingle: true },
|
|
1084
1087
|
thread_participants: { type: 'User', isSingle: false },
|
|
1088
|
+
member: { type: 'ChannelMember', isSingle: true },
|
|
1085
1089
|
pinned_by: { type: 'User', isSingle: true },
|
|
1086
1090
|
poll: { type: 'Poll', isSingle: true },
|
|
1087
1091
|
quoted_message: { type: 'Message', isSingle: true },
|
|
@@ -1135,6 +1139,8 @@ decoders.ModerationCustomActionEvent = (input) => {
|
|
|
1135
1139
|
};
|
|
1136
1140
|
decoders.ModerationFlagResponse = (input) => {
|
|
1137
1141
|
const typeMappings = {
|
|
1142
|
+
created_at: { type: 'DatetimeType', isSingle: true },
|
|
1143
|
+
updated_at: { type: 'DatetimeType', isSingle: true },
|
|
1138
1144
|
review_queue_item: { type: 'ReviewQueueItemResponse', isSingle: true },
|
|
1139
1145
|
user: { type: 'UserResponse', isSingle: true },
|
|
1140
1146
|
};
|
|
@@ -1901,6 +1907,7 @@ class FeedsApi {
|
|
|
1901
1907
|
const body = {
|
|
1902
1908
|
type: request?.type,
|
|
1903
1909
|
create_notification_activity: request?.create_notification_activity,
|
|
1910
|
+
skip_push: request?.skip_push,
|
|
1904
1911
|
custom: request?.custom,
|
|
1905
1912
|
};
|
|
1906
1913
|
const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/activities/{activity_id}/reactions', pathParams, undefined, body, 'application/json');
|
|
@@ -2047,6 +2054,7 @@ class FeedsApi {
|
|
|
2047
2054
|
object_type: request?.object_type,
|
|
2048
2055
|
create_notification_activity: request?.create_notification_activity,
|
|
2049
2056
|
parent_id: request?.parent_id,
|
|
2057
|
+
skip_push: request?.skip_push,
|
|
2050
2058
|
attachments: request?.attachments,
|
|
2051
2059
|
mentioned_user_ids: request?.mentioned_user_ids,
|
|
2052
2060
|
custom: request?.custom,
|
|
@@ -2100,6 +2108,7 @@ class FeedsApi {
|
|
|
2100
2108
|
};
|
|
2101
2109
|
const body = {
|
|
2102
2110
|
comment: request?.comment,
|
|
2111
|
+
skip_push: request?.skip_push,
|
|
2103
2112
|
custom: request?.custom,
|
|
2104
2113
|
};
|
|
2105
2114
|
const response = await this.apiClient.sendRequest('PATCH', '/api/v2/feeds/comments/{id}', pathParams, undefined, body, 'application/json');
|
|
@@ -2113,6 +2122,7 @@ class FeedsApi {
|
|
|
2113
2122
|
const body = {
|
|
2114
2123
|
type: request?.type,
|
|
2115
2124
|
create_notification_activity: request?.create_notification_activity,
|
|
2125
|
+
skip_push: request?.skip_push,
|
|
2116
2126
|
custom: request?.custom,
|
|
2117
2127
|
};
|
|
2118
2128
|
const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/comments/{id}/reactions', pathParams, undefined, body, 'application/json');
|
|
@@ -2353,6 +2363,7 @@ class FeedsApi {
|
|
|
2353
2363
|
create_notification_activity: request?.create_notification_activity,
|
|
2354
2364
|
follower_role: request?.follower_role,
|
|
2355
2365
|
push_preference: request?.push_preference,
|
|
2366
|
+
skip_push: request?.skip_push,
|
|
2356
2367
|
custom: request?.custom,
|
|
2357
2368
|
};
|
|
2358
2369
|
const response = await this.apiClient.sendRequest('PATCH', '/api/v2/feeds/follows', undefined, undefined, body, 'application/json');
|
|
@@ -2365,6 +2376,7 @@ class FeedsApi {
|
|
|
2365
2376
|
target: request?.target,
|
|
2366
2377
|
create_notification_activity: request?.create_notification_activity,
|
|
2367
2378
|
push_preference: request?.push_preference,
|
|
2379
|
+
skip_push: request?.skip_push,
|
|
2368
2380
|
custom: request?.custom,
|
|
2369
2381
|
};
|
|
2370
2382
|
const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/follows', undefined, undefined, body, 'application/json');
|
|
@@ -4646,14 +4658,20 @@ function handleFeedMemberUpdated(event) {
|
|
|
4646
4658
|
function handleFeedMemberRemoved(event) {
|
|
4647
4659
|
const { connected_user: connectedUser } = this.client.state.getLatestValue();
|
|
4648
4660
|
this.state.next((currentState) => {
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4661
|
+
let newState;
|
|
4662
|
+
if (typeof currentState.members !== 'undefined') {
|
|
4663
|
+
const filtered = currentState.members.filter((member) => member.user.id !== event.member_id);
|
|
4664
|
+
if (filtered.length !== currentState.members.length) {
|
|
4665
|
+
newState ?? (newState = { ...currentState });
|
|
4666
|
+
newState.members = filtered;
|
|
4667
|
+
}
|
|
4668
|
+
}
|
|
4669
|
+
if (connectedUser?.id === event.member_id &&
|
|
4670
|
+
typeof currentState.own_membership !== 'undefined') {
|
|
4671
|
+
newState ?? (newState = { ...currentState });
|
|
4654
4672
|
delete newState.own_membership;
|
|
4655
4673
|
}
|
|
4656
|
-
return newState;
|
|
4674
|
+
return newState ?? currentState;
|
|
4657
4675
|
});
|
|
4658
4676
|
}
|
|
4659
4677
|
|
|
@@ -4890,7 +4908,7 @@ const removePinnedActivityFromState = (activityResponse, pinnedActivities) => {
|
|
|
4890
4908
|
if (index !== -1) {
|
|
4891
4909
|
const newActivities = [...pinnedActivities];
|
|
4892
4910
|
newActivities.splice(index, 1);
|
|
4893
|
-
return { changed: true,
|
|
4911
|
+
return { changed: true, pinned_activities: newActivities };
|
|
4894
4912
|
}
|
|
4895
4913
|
else {
|
|
4896
4914
|
return { changed: false, pinned_activities: pinnedActivities };
|
|
@@ -6402,7 +6420,9 @@ const useSearchResult = (sourceFromProps) => {
|
|
|
6402
6420
|
const source = sourceFromProps ?? sourceFromContext;
|
|
6403
6421
|
const { items, error, isLoading, hasNext } = useStateStore(source?.state, selector$2) ?? {};
|
|
6404
6422
|
const loadMore = useStableCallback(async () => {
|
|
6405
|
-
|
|
6423
|
+
if (hasNext) {
|
|
6424
|
+
source?.search();
|
|
6425
|
+
}
|
|
6406
6426
|
});
|
|
6407
6427
|
return useMemo(() => ({ items, error, isLoading, hasNext, loadMore }), [error, hasNext, isLoading, items, loadMore]);
|
|
6408
6428
|
};
|