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 = { | export type TypeaheadMatchedStrings = { | ||||
+textBeforeAtSymbol: string, | +textBeforeAtSymbol: string, | ||||
+usernamePrefix: string, | +usernamePrefix: string, | ||||
}; | }; | ||||
export type Selection = { | |||||
+start: number, | |||||
+end: number, | |||||
}; | |||||
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 32 Lines |