@stream-io/feeds-client 1.0.0 → 1.2.0
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 +21 -0
- package/dist/cjs/index.js +477 -466
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/react-bindings.js +454 -463
- package/dist/cjs/react-bindings.js.map +1 -1
- package/dist/es/index.mjs +440 -466
- package/dist/es/index.mjs.map +1 -1
- package/dist/es/react-bindings.mjs +447 -493
- package/dist/es/react-bindings.mjs.map +1 -1
- package/dist/feeds-client-ACVPbpUP.mjs +8752 -0
- package/dist/feeds-client-ACVPbpUP.mjs.map +1 -0
- package/dist/feeds-client-BP0fE4NZ.js +8918 -0
- package/dist/feeds-client-BP0fE4NZ.js.map +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/types/bindings/react/hooks/feed-state-hooks/useIsAggregatedActivityRead.d.ts +6 -2
- package/dist/types/bindings/react/hooks/feed-state-hooks/useIsAggregatedActivityRead.d.ts.map +1 -1
- package/dist/types/bindings/react/hooks/feed-state-hooks/useIsAggregatedActivitySeen.d.ts +6 -2
- package/dist/types/bindings/react/hooks/feed-state-hooks/useIsAggregatedActivitySeen.d.ts.map +1 -1
- package/dist/types/feed/event-handlers/activity/handle-activity-deleted.d.ts +3 -2
- package/dist/types/feed/event-handlers/activity/handle-activity-deleted.d.ts.map +1 -1
- package/dist/types/feed/event-handlers/activity/handle-activity-feedback.d.ts +5 -0
- package/dist/types/feed/event-handlers/activity/handle-activity-feedback.d.ts.map +1 -1
- package/dist/types/feed/event-handlers/activity/handle-activity-pinned.d.ts +3 -2
- package/dist/types/feed/event-handlers/activity/handle-activity-pinned.d.ts.map +1 -1
- package/dist/types/feed/event-handlers/activity/handle-activity-unpinned.d.ts +3 -2
- package/dist/types/feed/event-handlers/activity/handle-activity-unpinned.d.ts.map +1 -1
- package/dist/types/feed/event-handlers/activity/index.d.ts +3 -1
- package/dist/types/feed/event-handlers/activity/index.d.ts.map +1 -1
- package/dist/types/feed/event-handlers/activity-updater.d.ts +1 -0
- package/dist/types/feed/event-handlers/activity-updater.d.ts.map +1 -1
- package/dist/types/feed/event-handlers/add-aggregated-activities-to-state.d.ts +1 -1
- package/dist/types/feed/event-handlers/add-aggregated-activities-to-state.d.ts.map +1 -1
- package/dist/types/feed/event-handlers/bookmark/handle-bookmark-added.d.ts +6 -5
- package/dist/types/feed/event-handlers/bookmark/handle-bookmark-added.d.ts.map +1 -1
- package/dist/types/feed/event-handlers/bookmark/handle-bookmark-deleted.d.ts +6 -5
- package/dist/types/feed/event-handlers/bookmark/handle-bookmark-deleted.d.ts.map +1 -1
- package/dist/types/feed/event-handlers/bookmark/handle-bookmark-updated.d.ts +6 -5
- package/dist/types/feed/event-handlers/bookmark/handle-bookmark-updated.d.ts.map +1 -1
- package/dist/types/feed/event-handlers/feed/handle-feed-deleted.d.ts +4 -0
- package/dist/types/feed/event-handlers/feed/handle-feed-deleted.d.ts.map +1 -0
- package/dist/types/feed/event-handlers/feed/handle-feed-updated.d.ts.map +1 -1
- package/dist/types/feed/event-handlers/feed/index.d.ts +1 -0
- package/dist/types/feed/event-handlers/feed/index.d.ts.map +1 -1
- package/dist/types/feed/event-handlers/feed-member/handle-feed-member-added.d.ts +3 -2
- package/dist/types/feed/event-handlers/feed-member/handle-feed-member-added.d.ts.map +1 -1
- package/dist/types/feed/event-handlers/feed-member/handle-feed-member-removed.d.ts +3 -2
- package/dist/types/feed/event-handlers/feed-member/handle-feed-member-removed.d.ts.map +1 -1
- package/dist/types/feed/event-handlers/feed-member/handle-feed-member-updated.d.ts +3 -2
- package/dist/types/feed/event-handlers/feed-member/handle-feed-member-updated.d.ts.map +1 -1
- package/dist/types/feed/event-handlers/follow/handle-follow-updated.d.ts.map +1 -1
- package/dist/types/feed/event-handlers/notification-feed/handle-notification-feed-updated.d.ts +3 -2
- package/dist/types/feed/event-handlers/notification-feed/handle-notification-feed-updated.d.ts.map +1 -1
- package/dist/types/feed/feed.d.ts.map +1 -1
- package/dist/types/feeds-client/feeds-client.d.ts +25 -1
- package/dist/types/feeds-client/feeds-client.d.ts.map +1 -1
- package/dist/types/gen/feeds/FeedsApi.d.ts +6 -4
- package/dist/types/gen/feeds/FeedsApi.d.ts.map +1 -1
- package/dist/types/gen/models/index.d.ts +40 -2
- package/dist/types/gen/models/index.d.ts.map +1 -1
- package/dist/types/utils/state-update-queue.d.ts +11 -2
- package/dist/types/utils/state-update-queue.d.ts.map +1 -1
- package/dist/types/utils/unique-array-merge.d.ts +1 -1
- package/dist/types/utils/unique-array-merge.d.ts.map +1 -1
- package/package.json +15 -15
- package/src/bindings/react/hooks/feed-state-hooks/useIsAggregatedActivityRead.ts +6 -20
- package/src/bindings/react/hooks/feed-state-hooks/useIsAggregatedActivitySeen.ts +6 -20
- package/src/feed/event-handlers/activity/handle-activity-deleted.ts +28 -2
- package/src/feed/event-handlers/activity/handle-activity-feedback.ts +17 -7
- package/src/feed/event-handlers/activity/handle-activity-pinned.ts +25 -3
- package/src/feed/event-handlers/activity/handle-activity-unpinned.ts +25 -2
- package/src/feed/event-handlers/activity/index.ts +3 -1
- package/src/feed/event-handlers/add-aggregated-activities-to-state.ts +11 -2
- package/src/feed/event-handlers/bookmark/handle-bookmark-added.ts +20 -11
- package/src/feed/event-handlers/bookmark/handle-bookmark-deleted.ts +21 -11
- package/src/feed/event-handlers/bookmark/handle-bookmark-updated.ts +24 -10
- package/src/feed/event-handlers/feed/handle-feed-deleted.ts +12 -0
- package/src/feed/event-handlers/feed/handle-feed-updated.ts +8 -0
- package/src/feed/event-handlers/feed/index.ts +1 -0
- package/src/feed/event-handlers/feed-member/handle-feed-member-added.ts +25 -2
- package/src/feed/event-handlers/feed-member/handle-feed-member-removed.ts +25 -2
- package/src/feed/event-handlers/feed-member/handle-feed-member-updated.ts +25 -2
- package/src/feed/event-handlers/follow/handle-follow-updated.ts +14 -0
- package/src/feed/event-handlers/notification-feed/handle-notification-feed-updated.ts +64 -2
- package/src/feed/event-handlers/story-feeds/handle-story-feeds-updated.ts +1 -1
- package/src/feed/feed.ts +7 -5
- package/src/feeds-client/feeds-client.ts +359 -45
- package/src/gen/feeds/FeedsApi.ts +79 -12
- package/src/gen/model-decoders/decoders.ts +7 -0
- package/src/gen/models/index.ts +66 -4
- package/src/utils/state-update-queue.ts +42 -28
- package/src/utils/unique-array-merge.ts +11 -3
- package/dist/feeds-client-B03y08Kq.mjs +0 -8409
- package/dist/feeds-client-B03y08Kq.mjs.map +0 -1
- package/dist/feeds-client-tw63OGrd.js +0 -8425
- package/dist/feeds-client-tw63OGrd.js.map +0 -1
- package/dist/types/feed/event-handlers/activity/handle-activity-marked.d.ts +0 -12
- package/dist/types/feed/event-handlers/activity/handle-activity-marked.d.ts.map +0 -1
- package/src/feed/event-handlers/activity/handle-activity-marked.ts +0 -68
package/dist/es/index.mjs
CHANGED
|
@@ -1,472 +1,446 @@
|
|
|
1
|
+
import { C as LogLevelEnum, S as debounce, _ as uniqueArrayMerge, a as ownFeedFields, b as isVoteAnswer, c as shouldUpdateState, d as isFollowResponse, f as isImageFile, g as replaceUniqueArrayMerge, h as Constants, i as activityFilter, l as ensureExhausted, m as isVideoFile, n as ActivityWithStateUpdates, o as updateEntityInArray, p as isReactionResponse, r as Feed, s as getStateUpdateQueueId, t as FeedsClient, u as isCommentResponse, v as checkHasAnotherPage, w as feedsLoggerSystem, x as StreamApiError, y as StreamPoll } from "../feeds-client-ACVPbpUP.mjs";
|
|
1
2
|
import { StateStore } from "@stream-io/state-store";
|
|
2
3
|
export * from "@stream-io/state-store";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
UPDATE_OWN_MESSAGE: "update-own-message",
|
|
43
|
-
UPDATE_THREAD: "update-thread",
|
|
44
|
-
UPLOAD_FILE: "upload-file"
|
|
4
|
+
//#region src/gen/models/index.ts
|
|
5
|
+
var ChannelOwnCapability = {
|
|
6
|
+
BAN_CHANNEL_MEMBERS: "ban-channel-members",
|
|
7
|
+
CAST_POLL_VOTE: "cast-poll-vote",
|
|
8
|
+
CONNECT_EVENTS: "connect-events",
|
|
9
|
+
CREATE_ATTACHMENT: "create-attachment",
|
|
10
|
+
DELETE_ANY_MESSAGE: "delete-any-message",
|
|
11
|
+
DELETE_CHANNEL: "delete-channel",
|
|
12
|
+
DELETE_OWN_MESSAGE: "delete-own-message",
|
|
13
|
+
DELIVERY_EVENTS: "delivery-events",
|
|
14
|
+
FLAG_MESSAGE: "flag-message",
|
|
15
|
+
FREEZE_CHANNEL: "freeze-channel",
|
|
16
|
+
JOIN_CHANNEL: "join-channel",
|
|
17
|
+
LEAVE_CHANNEL: "leave-channel",
|
|
18
|
+
MUTE_CHANNEL: "mute-channel",
|
|
19
|
+
PIN_MESSAGE: "pin-message",
|
|
20
|
+
QUERY_POLL_VOTES: "query-poll-votes",
|
|
21
|
+
QUOTE_MESSAGE: "quote-message",
|
|
22
|
+
READ_EVENTS: "read-events",
|
|
23
|
+
SEARCH_MESSAGES: "search-messages",
|
|
24
|
+
SEND_CUSTOM_EVENTS: "send-custom-events",
|
|
25
|
+
SEND_LINKS: "send-links",
|
|
26
|
+
SEND_MESSAGE: "send-message",
|
|
27
|
+
SEND_POLL: "send-poll",
|
|
28
|
+
SEND_REACTION: "send-reaction",
|
|
29
|
+
SEND_REPLY: "send-reply",
|
|
30
|
+
SEND_RESTRICTED_VISIBILITY_MESSAGE: "send-restricted-visibility-message",
|
|
31
|
+
SEND_TYPING_EVENTS: "send-typing-events",
|
|
32
|
+
SET_CHANNEL_COOLDOWN: "set-channel-cooldown",
|
|
33
|
+
SHARE_LOCATION: "share-location",
|
|
34
|
+
SKIP_SLOW_MODE: "skip-slow-mode",
|
|
35
|
+
SLOW_MODE: "slow-mode",
|
|
36
|
+
TYPING_EVENTS: "typing-events",
|
|
37
|
+
UPDATE_ANY_MESSAGE: "update-any-message",
|
|
38
|
+
UPDATE_CHANNEL: "update-channel",
|
|
39
|
+
UPDATE_CHANNEL_MEMBERS: "update-channel-members",
|
|
40
|
+
UPDATE_OWN_MESSAGE: "update-own-message",
|
|
41
|
+
UPDATE_THREAD: "update-thread",
|
|
42
|
+
UPLOAD_FILE: "upload-file"
|
|
45
43
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
44
|
+
var FeedOwnCapability = {
|
|
45
|
+
ADD_ACTIVITY: "add-activity",
|
|
46
|
+
ADD_ACTIVITY_BOOKMARK: "add-activity-bookmark",
|
|
47
|
+
ADD_ACTIVITY_REACTION: "add-activity-reaction",
|
|
48
|
+
ADD_COMMENT: "add-comment",
|
|
49
|
+
ADD_COMMENT_REACTION: "add-comment-reaction",
|
|
50
|
+
CREATE_FEED: "create-feed",
|
|
51
|
+
DELETE_ANY_ACTIVITY: "delete-any-activity",
|
|
52
|
+
DELETE_ANY_COMMENT: "delete-any-comment",
|
|
53
|
+
DELETE_FEED: "delete-feed",
|
|
54
|
+
DELETE_OWN_ACTIVITY: "delete-own-activity",
|
|
55
|
+
DELETE_OWN_ACTIVITY_BOOKMARK: "delete-own-activity-bookmark",
|
|
56
|
+
DELETE_OWN_ACTIVITY_REACTION: "delete-own-activity-reaction",
|
|
57
|
+
DELETE_OWN_COMMENT: "delete-own-comment",
|
|
58
|
+
DELETE_OWN_COMMENT_REACTION: "delete-own-comment-reaction",
|
|
59
|
+
FOLLOW: "follow",
|
|
60
|
+
PIN_ACTIVITY: "pin-activity",
|
|
61
|
+
QUERY_FEED_MEMBERS: "query-feed-members",
|
|
62
|
+
QUERY_FOLLOWS: "query-follows",
|
|
63
|
+
READ_ACTIVITIES: "read-activities",
|
|
64
|
+
READ_FEED: "read-feed",
|
|
65
|
+
UNFOLLOW: "unfollow",
|
|
66
|
+
UPDATE_ANY_ACTIVITY: "update-any-activity",
|
|
67
|
+
UPDATE_ANY_COMMENT: "update-any-comment",
|
|
68
|
+
UPDATE_FEED: "update-feed",
|
|
69
|
+
UPDATE_FEED_FOLLOWERS: "update-feed-followers",
|
|
70
|
+
UPDATE_FEED_MEMBERS: "update-feed-members",
|
|
71
|
+
UPDATE_OWN_ACTIVITY: "update-own-activity",
|
|
72
|
+
UPDATE_OWN_ACTIVITY_BOOKMARK: "update-own-activity-bookmark",
|
|
73
|
+
UPDATE_OWN_COMMENT: "update-own-comment"
|
|
76
74
|
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
get searchQuery() {
|
|
175
|
-
return this.state.getLatestValue().searchQuery;
|
|
176
|
-
}
|
|
177
|
-
get searchSourceTypes() {
|
|
178
|
-
return this.sources.map((s2) => s2.type);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
const DEFAULT_SEARCH_SOURCE_OPTIONS = {
|
|
182
|
-
debounceMs: 300,
|
|
183
|
-
pageSize: 10,
|
|
184
|
-
allowEmptySearchString: false,
|
|
185
|
-
resetOnNewSearchQuery: true
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/common/search/SearchController.ts
|
|
77
|
+
var SearchController = class {
|
|
78
|
+
constructor({ config, sources } = {}) {
|
|
79
|
+
this.addSource = (source) => {
|
|
80
|
+
this.state.partialNext({ sources: [...this.sources, source] });
|
|
81
|
+
};
|
|
82
|
+
this.getSource = (sourceType) => this.sources.find((s) => s.type === sourceType);
|
|
83
|
+
this.removeSource = (sourceType) => {
|
|
84
|
+
const newSources = this.sources.filter((s) => s.type !== sourceType);
|
|
85
|
+
if (newSources.length === this.sources.length) return;
|
|
86
|
+
this.state.partialNext({ sources: newSources });
|
|
87
|
+
};
|
|
88
|
+
this.activateSource = (sourceType) => {
|
|
89
|
+
const source = this.getSource(sourceType);
|
|
90
|
+
if (!source || source.isActive) return;
|
|
91
|
+
if (this.config.keepSingleActiveSource) this.sources.forEach((s) => {
|
|
92
|
+
if (s.type !== sourceType) s.deactivate();
|
|
93
|
+
});
|
|
94
|
+
source.activate();
|
|
95
|
+
this.state.partialNext({ sources: [...this.sources] });
|
|
96
|
+
};
|
|
97
|
+
this.deactivateSource = (sourceType) => {
|
|
98
|
+
const source = this.getSource(sourceType);
|
|
99
|
+
if (!source?.isActive) return;
|
|
100
|
+
if (this.activeSources.length === 1) return;
|
|
101
|
+
source.deactivate();
|
|
102
|
+
this.state.partialNext({ sources: [...this.sources] });
|
|
103
|
+
};
|
|
104
|
+
this.activate = () => {
|
|
105
|
+
if (!this.activeSources.length) (this.config.keepSingleActiveSource ? this.sources.slice(0, 1) : this.sources).forEach((s) => s.activate());
|
|
106
|
+
if (this.isActive) return;
|
|
107
|
+
this.state.partialNext({ isActive: true });
|
|
108
|
+
};
|
|
109
|
+
this.search = async (searchQuery) => {
|
|
110
|
+
const searchedSources = this.activeSources;
|
|
111
|
+
this.state.partialNext({ searchQuery });
|
|
112
|
+
await Promise.all(searchedSources.map((source) => source.search(searchQuery)));
|
|
113
|
+
};
|
|
114
|
+
this.cancelSearchQueries = () => {
|
|
115
|
+
this.activeSources.forEach((s) => s.cancelScheduledQuery());
|
|
116
|
+
};
|
|
117
|
+
this.clear = () => {
|
|
118
|
+
this.cancelSearchQueries();
|
|
119
|
+
this.sources.forEach((source) => source.state.next({
|
|
120
|
+
...source.initialState,
|
|
121
|
+
isActive: source.isActive
|
|
122
|
+
}));
|
|
123
|
+
this.state.next((current) => ({
|
|
124
|
+
...current,
|
|
125
|
+
isActive: true,
|
|
126
|
+
queriesInProgress: [],
|
|
127
|
+
searchQuery: ""
|
|
128
|
+
}));
|
|
129
|
+
};
|
|
130
|
+
this.exit = () => {
|
|
131
|
+
this.cancelSearchQueries();
|
|
132
|
+
this.sources.forEach((source) => source.state.next({
|
|
133
|
+
...source.initialState,
|
|
134
|
+
isActive: source.isActive
|
|
135
|
+
}));
|
|
136
|
+
this.state.next((current) => ({
|
|
137
|
+
...current,
|
|
138
|
+
isActive: false,
|
|
139
|
+
queriesInProgress: [],
|
|
140
|
+
searchQuery: ""
|
|
141
|
+
}));
|
|
142
|
+
};
|
|
143
|
+
this.state = new StateStore({
|
|
144
|
+
isActive: false,
|
|
145
|
+
searchQuery: "",
|
|
146
|
+
sources: sources ?? []
|
|
147
|
+
});
|
|
148
|
+
this._internalState = new StateStore({});
|
|
149
|
+
this.config = {
|
|
150
|
+
keepSingleActiveSource: true,
|
|
151
|
+
...config
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
get hasNext() {
|
|
155
|
+
return this.sources.some((source) => source.hasNext);
|
|
156
|
+
}
|
|
157
|
+
get sources() {
|
|
158
|
+
return this.state.getLatestValue().sources;
|
|
159
|
+
}
|
|
160
|
+
get activeSources() {
|
|
161
|
+
return this.state.getLatestValue().sources.filter((s) => s.isActive);
|
|
162
|
+
}
|
|
163
|
+
get isActive() {
|
|
164
|
+
return this.state.getLatestValue().isActive;
|
|
165
|
+
}
|
|
166
|
+
get searchQuery() {
|
|
167
|
+
return this.state.getLatestValue().searchQuery;
|
|
168
|
+
}
|
|
169
|
+
get searchSourceTypes() {
|
|
170
|
+
return this.sources.map((s) => s.type);
|
|
171
|
+
}
|
|
186
172
|
};
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
if (!this.isActive) return;
|
|
195
|
-
this.state.partialNext({ isActive: false });
|
|
196
|
-
};
|
|
197
|
-
this.canExecuteQuery = (newSearchString) => {
|
|
198
|
-
const hasNewSearchQuery = typeof newSearchString !== "undefined";
|
|
199
|
-
const searchString = newSearchString ?? this.searchQuery;
|
|
200
|
-
return !!(this.isActive && !this.isLoading && (this.hasNext || hasNewSearchQuery) && (this.allowEmptySearchString || searchString));
|
|
201
|
-
};
|
|
202
|
-
const { pageSize, allowEmptySearchString, resetOnNewSearchQuery } = {
|
|
203
|
-
...DEFAULT_SEARCH_SOURCE_OPTIONS,
|
|
204
|
-
...options
|
|
205
|
-
};
|
|
206
|
-
this.pageSize = pageSize;
|
|
207
|
-
this.allowEmptySearchString = allowEmptySearchString;
|
|
208
|
-
this.resetOnNewSearchQuery = resetOnNewSearchQuery;
|
|
209
|
-
this.state = new StateStore(this.initialState);
|
|
210
|
-
}
|
|
211
|
-
get lastQueryError() {
|
|
212
|
-
return this.state.getLatestValue().lastQueryError;
|
|
213
|
-
}
|
|
214
|
-
get hasNext() {
|
|
215
|
-
return this.state.getLatestValue().hasNext;
|
|
216
|
-
}
|
|
217
|
-
get hasResults() {
|
|
218
|
-
return Array.isArray(this.state.getLatestValue().items);
|
|
219
|
-
}
|
|
220
|
-
get isActive() {
|
|
221
|
-
return this.state.getLatestValue().isActive;
|
|
222
|
-
}
|
|
223
|
-
get isLoading() {
|
|
224
|
-
return this.state.getLatestValue().isLoading;
|
|
225
|
-
}
|
|
226
|
-
get initialState() {
|
|
227
|
-
return {
|
|
228
|
-
hasNext: true,
|
|
229
|
-
isActive: false,
|
|
230
|
-
isLoading: false,
|
|
231
|
-
items: void 0,
|
|
232
|
-
lastQueryError: void 0,
|
|
233
|
-
next: void 0,
|
|
234
|
-
offset: 0,
|
|
235
|
-
searchQuery: ""
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
get items() {
|
|
239
|
-
return this.state.getLatestValue().items;
|
|
240
|
-
}
|
|
241
|
-
get next() {
|
|
242
|
-
return this.state.getLatestValue().next;
|
|
243
|
-
}
|
|
244
|
-
get offset() {
|
|
245
|
-
return this.state.getLatestValue().offset;
|
|
246
|
-
}
|
|
247
|
-
get searchQuery() {
|
|
248
|
-
return this.state.getLatestValue().searchQuery;
|
|
249
|
-
}
|
|
250
|
-
getStateBeforeFirstQuery(newSearchString) {
|
|
251
|
-
const initialState = this.initialState;
|
|
252
|
-
const oldItems = this.items;
|
|
253
|
-
const items = this.resetOnNewSearchQuery ? initialState.items : oldItems;
|
|
254
|
-
return {
|
|
255
|
-
...this.initialState,
|
|
256
|
-
items,
|
|
257
|
-
isActive: this.isActive,
|
|
258
|
-
isLoading: this.resetOnNewSearchQuery ? true : !oldItems,
|
|
259
|
-
searchQuery: newSearchString
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
getStateAfterQuery(stateUpdate, isFirstPage) {
|
|
263
|
-
const current = this.state.getLatestValue();
|
|
264
|
-
return {
|
|
265
|
-
...current,
|
|
266
|
-
lastQueryError: void 0,
|
|
267
|
-
// reset lastQueryError that can be overridden by the stateUpdate
|
|
268
|
-
...stateUpdate,
|
|
269
|
-
isLoading: false,
|
|
270
|
-
items: isFirstPage ? stateUpdate.items : [...this.items ?? [], ...stateUpdate.items || []]
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
prepareStateForQuery(newSearchString) {
|
|
274
|
-
const hasNewSearchQuery = typeof newSearchString !== "undefined";
|
|
275
|
-
const searchString = newSearchString ?? this.searchQuery;
|
|
276
|
-
if (hasNewSearchQuery) {
|
|
277
|
-
this.state.next(this.getStateBeforeFirstQuery(newSearchString ?? ""));
|
|
278
|
-
} else {
|
|
279
|
-
this.state.partialNext({ isLoading: true });
|
|
280
|
-
}
|
|
281
|
-
return { searchString, hasNewSearchQuery };
|
|
282
|
-
}
|
|
283
|
-
updatePaginationStateFromQuery(result) {
|
|
284
|
-
const { items, next } = result;
|
|
285
|
-
const stateUpdate = {};
|
|
286
|
-
if (Object.prototype.hasOwnProperty.call(result, "next")) {
|
|
287
|
-
stateUpdate.next = next;
|
|
288
|
-
stateUpdate.hasNext = !!next;
|
|
289
|
-
} else {
|
|
290
|
-
stateUpdate.offset = (this.offset ?? 0) + items.length;
|
|
291
|
-
stateUpdate.hasNext = items.length === this.pageSize;
|
|
292
|
-
}
|
|
293
|
-
return stateUpdate;
|
|
294
|
-
}
|
|
295
|
-
resetState() {
|
|
296
|
-
this.state.next(this.initialState);
|
|
297
|
-
}
|
|
298
|
-
resetStateAndActivate() {
|
|
299
|
-
this.resetState();
|
|
300
|
-
this.activate();
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
class BaseSearchSource extends BaseSearchSourceBase {
|
|
304
|
-
constructor(options) {
|
|
305
|
-
const { debounceMs } = { ...DEFAULT_SEARCH_SOURCE_OPTIONS, ...options };
|
|
306
|
-
super(options);
|
|
307
|
-
this.setDebounceOptions = ({ debounceMs: debounceMs2 }) => {
|
|
308
|
-
this.searchDebounced = debounce(this.executeQuery.bind(this), debounceMs2);
|
|
309
|
-
};
|
|
310
|
-
this.search = (searchQuery) => this.searchDebounced(searchQuery);
|
|
311
|
-
this.setDebounceOptions({ debounceMs });
|
|
312
|
-
}
|
|
313
|
-
async executeQuery(newSearchString) {
|
|
314
|
-
if (!this.canExecuteQuery(newSearchString)) return;
|
|
315
|
-
const { hasNewSearchQuery, searchString } = this.prepareStateForQuery(newSearchString);
|
|
316
|
-
let stateUpdate = {};
|
|
317
|
-
try {
|
|
318
|
-
const results = await this.query(searchString);
|
|
319
|
-
if (!results) return;
|
|
320
|
-
const { items } = results;
|
|
321
|
-
stateUpdate = this.updatePaginationStateFromQuery(results);
|
|
322
|
-
stateUpdate.items = await this.filterQueryResults(items);
|
|
323
|
-
} catch (e2) {
|
|
324
|
-
stateUpdate.lastQueryError = e2;
|
|
325
|
-
} finally {
|
|
326
|
-
this.state.next(this.getStateAfterQuery(stateUpdate, hasNewSearchQuery));
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
cancelScheduledQuery() {
|
|
330
|
-
this.searchDebounced.cancel();
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
class BaseSearchSourceSync extends BaseSearchSourceBase {
|
|
334
|
-
constructor(options) {
|
|
335
|
-
const { debounceMs } = { ...DEFAULT_SEARCH_SOURCE_OPTIONS, ...options };
|
|
336
|
-
super(options);
|
|
337
|
-
this.setDebounceOptions = ({ debounceMs: debounceMs2 }) => {
|
|
338
|
-
this.searchDebounced = debounce(this.executeQuery.bind(this), debounceMs2);
|
|
339
|
-
};
|
|
340
|
-
this.search = (searchQuery) => this.searchDebounced(searchQuery);
|
|
341
|
-
this.setDebounceOptions({ debounceMs });
|
|
342
|
-
}
|
|
343
|
-
executeQuery(newSearchString) {
|
|
344
|
-
if (!this.canExecuteQuery(newSearchString)) return;
|
|
345
|
-
const { hasNewSearchQuery, searchString } = this.prepareStateForQuery(newSearchString);
|
|
346
|
-
let stateUpdate = {};
|
|
347
|
-
try {
|
|
348
|
-
const results = this.query(searchString);
|
|
349
|
-
if (!results) return;
|
|
350
|
-
const { items } = results;
|
|
351
|
-
stateUpdate = this.updatePaginationStateFromQuery(results);
|
|
352
|
-
stateUpdate.items = this.filterQueryResults(items);
|
|
353
|
-
} catch (e2) {
|
|
354
|
-
stateUpdate.lastQueryError = e2;
|
|
355
|
-
} finally {
|
|
356
|
-
this.state.next(this.getStateAfterQuery(stateUpdate, hasNewSearchQuery));
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
cancelScheduledQuery() {
|
|
360
|
-
this.searchDebounced.cancel();
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
class ActivitySearchSource extends BaseSearchSource {
|
|
364
|
-
constructor(client, options) {
|
|
365
|
-
super(options);
|
|
366
|
-
this.type = "activity";
|
|
367
|
-
this.client = client;
|
|
368
|
-
}
|
|
369
|
-
async query(searchQuery) {
|
|
370
|
-
const { connected_user: connectedUser } = this.client.state.getLatestValue();
|
|
371
|
-
if (!connectedUser) return { items: [] };
|
|
372
|
-
const { activities: items, next } = await this.client.queryActivities({
|
|
373
|
-
sort: [{ direction: -1, field: "created_at" }],
|
|
374
|
-
...!this.allowEmptySearchString || searchQuery.length > 0 ? { filter: { text: { $autocomplete: searchQuery } } } : {},
|
|
375
|
-
limit: 10,
|
|
376
|
-
next: this.next ?? void 0
|
|
377
|
-
});
|
|
378
|
-
return { items, next };
|
|
379
|
-
}
|
|
380
|
-
filterQueryResults(items) {
|
|
381
|
-
return items;
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
class FeedSearchSource extends BaseSearchSource {
|
|
385
|
-
constructor(client, options) {
|
|
386
|
-
super(options);
|
|
387
|
-
this.client = client;
|
|
388
|
-
this.feedGroupId = options?.groupId;
|
|
389
|
-
this.type = `${this.feedGroupId}-feed`;
|
|
390
|
-
}
|
|
391
|
-
async query(searchQuery) {
|
|
392
|
-
const { connected_user: connectedUser } = this.client.state.getLatestValue();
|
|
393
|
-
if (!connectedUser) return { items: [] };
|
|
394
|
-
const { feeds: items, next } = await this.client.queryFeeds({
|
|
395
|
-
filter: {
|
|
396
|
-
...this.feedGroupId ? { group_id: this.feedGroupId } : {},
|
|
397
|
-
...!this.allowEmptySearchString || searchQuery.length > 0 ? {
|
|
398
|
-
$or: [
|
|
399
|
-
{ name: { $autocomplete: searchQuery } },
|
|
400
|
-
{ description: { $autocomplete: searchQuery } },
|
|
401
|
-
{ "created_by.name": { $autocomplete: searchQuery } }
|
|
402
|
-
]
|
|
403
|
-
} : {}
|
|
404
|
-
},
|
|
405
|
-
next: this.next ?? void 0
|
|
406
|
-
});
|
|
407
|
-
return { items, next };
|
|
408
|
-
}
|
|
409
|
-
filterQueryResults(items) {
|
|
410
|
-
return items;
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
class UserSearchSource extends BaseSearchSource {
|
|
414
|
-
constructor(client, options) {
|
|
415
|
-
super(options);
|
|
416
|
-
this.type = "user";
|
|
417
|
-
this.client = client;
|
|
418
|
-
}
|
|
419
|
-
async query(searchQuery) {
|
|
420
|
-
const { connected_user: connectedUser } = this.client.state.getLatestValue();
|
|
421
|
-
if (!connectedUser) return { items: [] };
|
|
422
|
-
const { users: items } = await this.client.queryUsers({
|
|
423
|
-
payload: {
|
|
424
|
-
filter_conditions: {
|
|
425
|
-
...!this.allowEmptySearchString || searchQuery.length > 0 ? {
|
|
426
|
-
name: {
|
|
427
|
-
$autocomplete: searchQuery
|
|
428
|
-
}
|
|
429
|
-
} : {}
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
});
|
|
433
|
-
return { items, next: void 0 };
|
|
434
|
-
}
|
|
435
|
-
filterQueryResults(items) {
|
|
436
|
-
return items;
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
export {
|
|
440
|
-
ActivitySearchSource,
|
|
441
|
-
A as ActivityWithStateUpdates,
|
|
442
|
-
BaseSearchSource,
|
|
443
|
-
BaseSearchSourceSync,
|
|
444
|
-
ChannelOwnCapability,
|
|
445
|
-
C as Constants,
|
|
446
|
-
b as Feed,
|
|
447
|
-
FeedOwnCapability,
|
|
448
|
-
FeedSearchSource,
|
|
449
|
-
F as FeedsClient,
|
|
450
|
-
LogLevelEnum,
|
|
451
|
-
SearchController,
|
|
452
|
-
S as StreamApiError,
|
|
453
|
-
c as StreamPoll,
|
|
454
|
-
UserSearchSource,
|
|
455
|
-
a as activityFilter,
|
|
456
|
-
e as checkHasAnotherPage,
|
|
457
|
-
o as ensureExhausted,
|
|
458
|
-
n as feedsLoggerSystem,
|
|
459
|
-
l as getStateUpdateQueueId,
|
|
460
|
-
h as isCommentResponse,
|
|
461
|
-
f as isFollowResponse,
|
|
462
|
-
j as isImageFile,
|
|
463
|
-
g as isReactionResponse,
|
|
464
|
-
k as isVideoFile,
|
|
465
|
-
i as isVoteAnswer,
|
|
466
|
-
ownFeedFields,
|
|
467
|
-
r as replaceUniqueArrayMerge,
|
|
468
|
-
s as shouldUpdateState,
|
|
469
|
-
u as uniqueArrayMerge,
|
|
470
|
-
m as updateEntityInArray
|
|
173
|
+
//#endregion
|
|
174
|
+
//#region src/common/search/BaseSearchSource.ts
|
|
175
|
+
var DEFAULT_SEARCH_SOURCE_OPTIONS = {
|
|
176
|
+
debounceMs: 300,
|
|
177
|
+
pageSize: 10,
|
|
178
|
+
allowEmptySearchString: false,
|
|
179
|
+
resetOnNewSearchQuery: true
|
|
471
180
|
};
|
|
472
|
-
|
|
181
|
+
var BaseSearchSourceBase = class {
|
|
182
|
+
constructor(options) {
|
|
183
|
+
this.activate = () => {
|
|
184
|
+
if (this.isActive) return;
|
|
185
|
+
this.state.partialNext({ isActive: true });
|
|
186
|
+
};
|
|
187
|
+
this.deactivate = () => {
|
|
188
|
+
if (!this.isActive) return;
|
|
189
|
+
this.state.partialNext({ isActive: false });
|
|
190
|
+
};
|
|
191
|
+
this.canExecuteQuery = (newSearchString) => {
|
|
192
|
+
const hasNewSearchQuery = typeof newSearchString !== "undefined";
|
|
193
|
+
const searchString = newSearchString ?? this.searchQuery;
|
|
194
|
+
return !!(this.isActive && !this.isLoading && (this.hasNext || hasNewSearchQuery) && (this.allowEmptySearchString || searchString));
|
|
195
|
+
};
|
|
196
|
+
const { pageSize, allowEmptySearchString, resetOnNewSearchQuery } = {
|
|
197
|
+
...DEFAULT_SEARCH_SOURCE_OPTIONS,
|
|
198
|
+
...options
|
|
199
|
+
};
|
|
200
|
+
this.pageSize = pageSize;
|
|
201
|
+
this.allowEmptySearchString = allowEmptySearchString;
|
|
202
|
+
this.resetOnNewSearchQuery = resetOnNewSearchQuery;
|
|
203
|
+
this.state = new StateStore(this.initialState);
|
|
204
|
+
}
|
|
205
|
+
get lastQueryError() {
|
|
206
|
+
return this.state.getLatestValue().lastQueryError;
|
|
207
|
+
}
|
|
208
|
+
get hasNext() {
|
|
209
|
+
return this.state.getLatestValue().hasNext;
|
|
210
|
+
}
|
|
211
|
+
get hasResults() {
|
|
212
|
+
return Array.isArray(this.state.getLatestValue().items);
|
|
213
|
+
}
|
|
214
|
+
get isActive() {
|
|
215
|
+
return this.state.getLatestValue().isActive;
|
|
216
|
+
}
|
|
217
|
+
get isLoading() {
|
|
218
|
+
return this.state.getLatestValue().isLoading;
|
|
219
|
+
}
|
|
220
|
+
get initialState() {
|
|
221
|
+
return {
|
|
222
|
+
hasNext: true,
|
|
223
|
+
isActive: false,
|
|
224
|
+
isLoading: false,
|
|
225
|
+
items: void 0,
|
|
226
|
+
lastQueryError: void 0,
|
|
227
|
+
next: void 0,
|
|
228
|
+
offset: 0,
|
|
229
|
+
searchQuery: ""
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
get items() {
|
|
233
|
+
return this.state.getLatestValue().items;
|
|
234
|
+
}
|
|
235
|
+
get next() {
|
|
236
|
+
return this.state.getLatestValue().next;
|
|
237
|
+
}
|
|
238
|
+
get offset() {
|
|
239
|
+
return this.state.getLatestValue().offset;
|
|
240
|
+
}
|
|
241
|
+
get searchQuery() {
|
|
242
|
+
return this.state.getLatestValue().searchQuery;
|
|
243
|
+
}
|
|
244
|
+
getStateBeforeFirstQuery(newSearchString) {
|
|
245
|
+
const initialState = this.initialState;
|
|
246
|
+
const oldItems = this.items;
|
|
247
|
+
const items = this.resetOnNewSearchQuery ? initialState.items : oldItems;
|
|
248
|
+
return {
|
|
249
|
+
...this.initialState,
|
|
250
|
+
items,
|
|
251
|
+
isActive: this.isActive,
|
|
252
|
+
isLoading: this.resetOnNewSearchQuery ? true : !oldItems,
|
|
253
|
+
searchQuery: newSearchString
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
getStateAfterQuery(stateUpdate, isFirstPage) {
|
|
257
|
+
return {
|
|
258
|
+
...this.state.getLatestValue(),
|
|
259
|
+
lastQueryError: void 0,
|
|
260
|
+
...stateUpdate,
|
|
261
|
+
isLoading: false,
|
|
262
|
+
items: isFirstPage ? stateUpdate.items : [...this.items ?? [], ...stateUpdate.items || []]
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
prepareStateForQuery(newSearchString) {
|
|
266
|
+
const hasNewSearchQuery = typeof newSearchString !== "undefined";
|
|
267
|
+
const searchString = newSearchString ?? this.searchQuery;
|
|
268
|
+
if (hasNewSearchQuery) this.state.next(this.getStateBeforeFirstQuery(newSearchString ?? ""));
|
|
269
|
+
else this.state.partialNext({ isLoading: true });
|
|
270
|
+
return {
|
|
271
|
+
searchString,
|
|
272
|
+
hasNewSearchQuery
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
updatePaginationStateFromQuery(result) {
|
|
276
|
+
const { items, next } = result;
|
|
277
|
+
const stateUpdate = {};
|
|
278
|
+
if (Object.prototype.hasOwnProperty.call(result, "next")) {
|
|
279
|
+
stateUpdate.next = next;
|
|
280
|
+
stateUpdate.hasNext = !!next;
|
|
281
|
+
} else {
|
|
282
|
+
stateUpdate.offset = (this.offset ?? 0) + items.length;
|
|
283
|
+
stateUpdate.hasNext = items.length === this.pageSize;
|
|
284
|
+
}
|
|
285
|
+
return stateUpdate;
|
|
286
|
+
}
|
|
287
|
+
resetState() {
|
|
288
|
+
this.state.next(this.initialState);
|
|
289
|
+
}
|
|
290
|
+
resetStateAndActivate() {
|
|
291
|
+
this.resetState();
|
|
292
|
+
this.activate();
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
var BaseSearchSource = class extends BaseSearchSourceBase {
|
|
296
|
+
constructor(options) {
|
|
297
|
+
const { debounceMs } = {
|
|
298
|
+
...DEFAULT_SEARCH_SOURCE_OPTIONS,
|
|
299
|
+
...options
|
|
300
|
+
};
|
|
301
|
+
super(options);
|
|
302
|
+
this.setDebounceOptions = ({ debounceMs }) => {
|
|
303
|
+
this.searchDebounced = debounce(this.executeQuery.bind(this), debounceMs);
|
|
304
|
+
};
|
|
305
|
+
this.search = (searchQuery) => this.searchDebounced(searchQuery);
|
|
306
|
+
this.setDebounceOptions({ debounceMs });
|
|
307
|
+
}
|
|
308
|
+
async executeQuery(newSearchString) {
|
|
309
|
+
if (!this.canExecuteQuery(newSearchString)) return;
|
|
310
|
+
const { hasNewSearchQuery, searchString } = this.prepareStateForQuery(newSearchString);
|
|
311
|
+
let stateUpdate = {};
|
|
312
|
+
try {
|
|
313
|
+
const results = await this.query(searchString);
|
|
314
|
+
if (!results) return;
|
|
315
|
+
const { items } = results;
|
|
316
|
+
stateUpdate = this.updatePaginationStateFromQuery(results);
|
|
317
|
+
stateUpdate.items = await this.filterQueryResults(items);
|
|
318
|
+
} catch (e) {
|
|
319
|
+
stateUpdate.lastQueryError = e;
|
|
320
|
+
} finally {
|
|
321
|
+
this.state.next(this.getStateAfterQuery(stateUpdate, hasNewSearchQuery));
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
cancelScheduledQuery() {
|
|
325
|
+
this.searchDebounced.cancel();
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
var BaseSearchSourceSync = class extends BaseSearchSourceBase {
|
|
329
|
+
constructor(options) {
|
|
330
|
+
const { debounceMs } = {
|
|
331
|
+
...DEFAULT_SEARCH_SOURCE_OPTIONS,
|
|
332
|
+
...options
|
|
333
|
+
};
|
|
334
|
+
super(options);
|
|
335
|
+
this.setDebounceOptions = ({ debounceMs }) => {
|
|
336
|
+
this.searchDebounced = debounce(this.executeQuery.bind(this), debounceMs);
|
|
337
|
+
};
|
|
338
|
+
this.search = (searchQuery) => this.searchDebounced(searchQuery);
|
|
339
|
+
this.setDebounceOptions({ debounceMs });
|
|
340
|
+
}
|
|
341
|
+
executeQuery(newSearchString) {
|
|
342
|
+
if (!this.canExecuteQuery(newSearchString)) return;
|
|
343
|
+
const { hasNewSearchQuery, searchString } = this.prepareStateForQuery(newSearchString);
|
|
344
|
+
let stateUpdate = {};
|
|
345
|
+
try {
|
|
346
|
+
const results = this.query(searchString);
|
|
347
|
+
if (!results) return;
|
|
348
|
+
const { items } = results;
|
|
349
|
+
stateUpdate = this.updatePaginationStateFromQuery(results);
|
|
350
|
+
stateUpdate.items = this.filterQueryResults(items);
|
|
351
|
+
} catch (e) {
|
|
352
|
+
stateUpdate.lastQueryError = e;
|
|
353
|
+
} finally {
|
|
354
|
+
this.state.next(this.getStateAfterQuery(stateUpdate, hasNewSearchQuery));
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
cancelScheduledQuery() {
|
|
358
|
+
this.searchDebounced.cancel();
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
//#endregion
|
|
362
|
+
//#region src/common/search/ActivitySearchSource.ts
|
|
363
|
+
var ActivitySearchSource = class extends BaseSearchSource {
|
|
364
|
+
constructor(client, options) {
|
|
365
|
+
super(options);
|
|
366
|
+
this.type = "activity";
|
|
367
|
+
this.client = client;
|
|
368
|
+
}
|
|
369
|
+
async query(searchQuery) {
|
|
370
|
+
const { connected_user: connectedUser } = this.client.state.getLatestValue();
|
|
371
|
+
if (!connectedUser) return { items: [] };
|
|
372
|
+
const { activities: items, next } = await this.client.queryActivities({
|
|
373
|
+
sort: [{
|
|
374
|
+
direction: -1,
|
|
375
|
+
field: "created_at"
|
|
376
|
+
}],
|
|
377
|
+
...!this.allowEmptySearchString || searchQuery.length > 0 ? { filter: { text: { $autocomplete: searchQuery } } } : {},
|
|
378
|
+
limit: 10,
|
|
379
|
+
next: this.next ?? void 0
|
|
380
|
+
});
|
|
381
|
+
return {
|
|
382
|
+
items,
|
|
383
|
+
next
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
filterQueryResults(items) {
|
|
387
|
+
return items;
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
//#endregion
|
|
391
|
+
//#region src/common/search/FeedSearchSource.ts
|
|
392
|
+
var FeedSearchSource = class extends BaseSearchSource {
|
|
393
|
+
constructor(client, options) {
|
|
394
|
+
super(options);
|
|
395
|
+
this.client = client;
|
|
396
|
+
this.feedGroupId = options?.groupId;
|
|
397
|
+
this.type = `${this.feedGroupId}-feed`;
|
|
398
|
+
}
|
|
399
|
+
async query(searchQuery) {
|
|
400
|
+
const { connected_user: connectedUser } = this.client.state.getLatestValue();
|
|
401
|
+
if (!connectedUser) return { items: [] };
|
|
402
|
+
const { feeds: items, next } = await this.client.queryFeeds({
|
|
403
|
+
filter: {
|
|
404
|
+
...this.feedGroupId ? { group_id: this.feedGroupId } : {},
|
|
405
|
+
...!this.allowEmptySearchString || searchQuery.length > 0 ? { $or: [
|
|
406
|
+
{ name: { $autocomplete: searchQuery } },
|
|
407
|
+
{ description: { $autocomplete: searchQuery } },
|
|
408
|
+
{ "created_by.name": { $autocomplete: searchQuery } }
|
|
409
|
+
] } : {}
|
|
410
|
+
},
|
|
411
|
+
next: this.next ?? void 0
|
|
412
|
+
});
|
|
413
|
+
return {
|
|
414
|
+
items,
|
|
415
|
+
next
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
filterQueryResults(items) {
|
|
419
|
+
return items;
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
//#endregion
|
|
423
|
+
//#region src/common/search/UserSearchSource.ts
|
|
424
|
+
var UserSearchSource = class extends BaseSearchSource {
|
|
425
|
+
constructor(client, options) {
|
|
426
|
+
super(options);
|
|
427
|
+
this.type = "user";
|
|
428
|
+
this.client = client;
|
|
429
|
+
}
|
|
430
|
+
async query(searchQuery) {
|
|
431
|
+
const { connected_user: connectedUser } = this.client.state.getLatestValue();
|
|
432
|
+
if (!connectedUser) return { items: [] };
|
|
433
|
+
const { users: items } = await this.client.queryUsers({ payload: { filter_conditions: { ...!this.allowEmptySearchString || searchQuery.length > 0 ? { name: { $autocomplete: searchQuery } } : {} } } });
|
|
434
|
+
return {
|
|
435
|
+
items,
|
|
436
|
+
next: void 0
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
filterQueryResults(items) {
|
|
440
|
+
return items;
|
|
441
|
+
}
|
|
442
|
+
};
|
|
443
|
+
//#endregion
|
|
444
|
+
export { ActivitySearchSource, ActivityWithStateUpdates, BaseSearchSource, BaseSearchSourceSync, ChannelOwnCapability, Constants, Feed, FeedOwnCapability, FeedSearchSource, FeedsClient, LogLevelEnum, SearchController, StreamApiError, StreamPoll, UserSearchSource, activityFilter, checkHasAnotherPage, ensureExhausted, feedsLoggerSystem, getStateUpdateQueueId, isCommentResponse, isFollowResponse, isImageFile, isReactionResponse, isVideoFile, isVoteAnswer, ownFeedFields, replaceUniqueArrayMerge, shouldUpdateState, uniqueArrayMerge, updateEntityInArray };
|
|
445
|
+
|
|
446
|
+
//# sourceMappingURL=index.mjs.map
|