Changeset View
Changeset View
Standalone View
Standalone View
lib/shared/typeahead-utils.js
// @flow | // @flow | ||||
import type { RelativeMemberInfo } from '../types/thread-types'; | import type { RelativeMemberInfo } from '../types/thread-types'; | ||||
import SearchIndex from './search-index'; | import SearchIndex from './search-index'; | ||||
import { threadOtherMembers } from './thread-utils'; | import { threadOtherMembers } from './thread-utils'; | ||||
import { stringForUserExplicit } from './user-utils'; | import { stringForUserExplicit } from './user-utils'; | ||||
export type TypeaheadMatchedStrings = { | |||||
+textBeforeAtSymbol: string, | |||||
+usernamePrefix: string, | |||||
}; | |||||
function getTypeaheadUserSuggestions( | function getTypeaheadUserSuggestions( | ||||
userSearchIndex: SearchIndex, | userSearchIndex: SearchIndex, | ||||
threadMembers: $ReadOnlyArray<RelativeMemberInfo>, | threadMembers: $ReadOnlyArray<RelativeMemberInfo>, | ||||
viewerID: ?string, | viewerID: ?string, | ||||
usernamePrefix: string, | usernamePrefix: string, | ||||
): $ReadOnlyArray<RelativeMemberInfo> { | ): $ReadOnlyArray<RelativeMemberInfo> { | ||||
const userIDs = userSearchIndex.getSearchResults(usernamePrefix); | const userIDs = userSearchIndex.getSearchResults(usernamePrefix); | ||||
const usersInThread = threadOtherMembers(threadMembers, viewerID); | const usersInThread = threadOtherMembers(threadMembers, viewerID); | ||||
Show All 9 Lines |