Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3357784
D6041.id20152.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D6041.id20152.diff
View Options
diff --git a/lib/shared/typeahead-utils.js b/lib/shared/typeahead-utils.js
new file mode 100644
--- /dev/null
+++ b/lib/shared/typeahead-utils.js
@@ -0,0 +1,21 @@
+// @flow
+
+import type { RelativeMemberInfo } from '../types/thread-types';
+import SearchIndex from './search-index';
+import { stringForUserExplicit } from './user-utils';
+
+function getTypeaheadUserSuggestions(
+ userSearchIndex: SearchIndex,
+ usersInThread: $ReadOnlyArray<RelativeMemberInfo>,
+ typedPrefix: string,
+): $ReadOnlyArray<RelativeMemberInfo> {
+ const userIDs = userSearchIndex.getSearchResults(typedPrefix);
+
+ return usersInThread
+ .filter(user => typedPrefix.length === 0 || userIDs.includes(user.id))
+ .sort((userA, userB) =>
+ stringForUserExplicit(userA).localeCompare(stringForUserExplicit(userB)),
+ );
+}
+
+export { getTypeaheadUserSuggestions };
diff --git a/web/chat/typeahead-tooltip.react.js b/web/chat/typeahead-tooltip.react.js
--- a/web/chat/typeahead-tooltip.react.js
+++ b/web/chat/typeahead-tooltip.react.js
@@ -5,6 +5,7 @@
import SearchIndex from 'lib/shared/search-index';
import { threadOtherMembers } from 'lib/shared/thread-utils';
+import { getTypeaheadUserSuggestions } from 'lib/shared/typeahead-utils';
import type { RelativeMemberInfo } from 'lib/types/thread-types';
import Button from '../components/button.react';
@@ -14,7 +15,6 @@
import {
getTypeaheadTooltipActions,
getTypeaheadTooltipPosition,
- getTypeaheadUserSuggestions,
} from './typeahead-utils';
export type TypeaheadTooltipProps = {
diff --git a/web/chat/typeahead-utils.js b/web/chat/typeahead-utils.js
--- a/web/chat/typeahead-utils.js
+++ b/web/chat/typeahead-utils.js
@@ -3,7 +3,6 @@
import * as React from 'react';
import { oldValidUsernameRegexString } from 'lib/shared/account-utils';
-import SearchIndex from 'lib/shared/search-index';
import { stringForUserExplicit } from 'lib/shared/user-utils';
import type { RelativeMemberInfo } from 'lib/types/thread-types';
@@ -25,20 +24,6 @@
+left: number,
};
-function getTypeaheadUserSuggestions(
- userSearchIndex: SearchIndex,
- usersInThread: $ReadOnlyArray<RelativeMemberInfo>,
- typedPrefix: string,
-): $ReadOnlyArray<RelativeMemberInfo> {
- const userIDs = userSearchIndex.getSearchResults(typedPrefix);
-
- return usersInThread
- .filter(user => typedPrefix.length === 0 || userIDs.includes(user.id))
- .sort((userA, userB) =>
- stringForUserExplicit(userA).localeCompare(stringForUserExplicit(userB)),
- );
-}
-
function getCaretOffsets(
textarea: HTMLTextAreaElement,
text: string,
@@ -152,7 +137,6 @@
export {
typeaheadRegex,
- getTypeaheadUserSuggestions,
getCaretOffsets,
getTypeaheadTooltipActions,
getTypeaheadTooltipPosition,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 25, 1:35 AM (19 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2574422
Default Alt Text
D6041.id20152.diff (2 KB)
Attached To
Mode
D6041: [web] Keyboard support for typeahead [1/13] - Moved getTypeaheadUserSuggestions to lib
Attached
Detach File
Event Timeline
Log In to Comment