Page MenuHomePhabricator

D6041.id20859.diff
No OneTemporary

D6041.id20859.diff

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

Mime Type
text/plain
Expires
Sun, Nov 24, 7:08 AM (7 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2574422
Default Alt Text
D6041.id20859.diff (2 KB)

Event Timeline