Skip to content

Commit e5e0dbf

Browse files
authored
feat: add MentionsSearchSource.toUserSuggestion method (#1637)
1 parent afe749d commit e5e0dbf

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/messageComposer/middleware/textComposer/mentions.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ export class MentionsSearchSource extends BaseSearchSource<UserSuggestion> {
111111
return countLoadedMembers < MAX_CHANNEL_MEMBER_COUNT_IN_CHANNEL_QUERY;
112112
}
113113

114+
toUserSuggestion = (user: UserResponse): UserSuggestion => ({
115+
...user,
116+
...getTokenizedSuggestionDisplayName({
117+
displayName: user.name || user.id,
118+
searchToken: this.searchQuery,
119+
}),
120+
});
121+
114122
getStateBeforeFirstQuery(newSearchString: string) {
115123
const newState = super.getStateBeforeFirstQuery(newSearchString);
116124
const { items } = this.state.getLatestValue();
@@ -255,16 +263,7 @@ export class MentionsSearchSource extends BaseSearchSource<UserSuggestion> {
255263
}
256264

257265
return {
258-
items: users.map(
259-
(user) =>
260-
({
261-
...user,
262-
...getTokenizedSuggestionDisplayName({
263-
displayName: user.name || user.id,
264-
searchToken: this.searchQuery,
265-
}),
266-
}) as UserSuggestion,
267-
),
266+
items: users.map(this.toUserSuggestion),
268267
};
269268
}
270269

0 commit comments

Comments
 (0)