diff --git a/lib/shared/search-utils.js b/lib/shared/search-utils.js --- a/lib/shared/search-utils.js +++ b/lib/shared/search-utils.js @@ -430,6 +430,7 @@ type UseSearchUsersOptions = { +includeViewer?: ?boolean, +searchFarcaster?: ?boolean, + +skipCommUsers?: ?boolean, }; function useSearchUsers( usernameInputText: string, @@ -437,6 +438,7 @@ ): $ReadOnlyArray { const includeViewer = !!options?.includeViewer; const searchFarcaster = !!options?.searchFarcaster; + const skipCommUsers = !!options?.skipCommUsers; const currentUserID = useSelector( state => state.currentUserInfo && state.currentUserInfo.id, @@ -477,7 +479,7 @@ const foundInfos: Array = []; const identityPromise = (async () => { - if (identitySearchSocketConnected) { + if (identitySearchSocketConnected && !skipCommUsers) { try { const identitySearchResult = await callIdentitySearchUsers( forwardLookupSearchText, @@ -521,7 +523,7 @@ await Promise.all([identityPromise, farcasterPromise]); - if (foundInfos.length > 0) { + if (foundInfos.length > 0 || skipCommUsers) { setSearchResultsFromServer(foundInfos); return; } @@ -539,6 +541,7 @@ forwardLookupSearchText, findFarcasterDCUsers, searchFarcaster, + skipCommUsers, ]); return searchResults; } diff --git a/native/chat/settings/add-users-modal.react.js b/native/chat/settings/add-users-modal.react.js --- a/native/chat/settings/add-users-modal.react.js +++ b/native/chat/settings/add-users-modal.react.js @@ -16,8 +16,10 @@ import { threadActualMembers } from 'lib/shared/thread-utils.js'; import { threadSpecs } from 'lib/shared/threads/thread-specs.js'; import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; +import { farcasterThreadTypeValidator } from 'lib/types/thread-types-enum.js'; import { type AccountUserInfo } from 'lib/types/user-types.js'; import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js'; +import { useIsFarcasterDCsIntegrationEnabled } from 'lib/utils/services-utils.js'; import Button from '../../components/button.react.js'; import Modal from '../../components/modal.react.js'; @@ -187,6 +189,13 @@ const communityThreadInfo = useSelector(state => community ? threadInfoSelector(state)[community] : null, ); + const isFarcasterDCsIntegrationEnabled = + useIsFarcasterDCsIntegrationEnabled(); + const isFarcasterThread = farcasterThreadTypeValidator.is(threadInfo.type); + const searchUsersResult = useSearchUsers(searchText, { + searchFarcaster: isFarcasterDCsIntegrationEnabled && isFarcasterThread, + skipCommUsers: true, + }); const auxUserInfos = useSelector(state => state.auxUserStore.auxUserInfos); const userSearchResults = usePotentialMemberItems({ text: usernameInputText, @@ -196,6 +205,7 @@ inputParentThreadInfo: parentThreadInfo, inputCommunityThreadInfo: communityThreadInfo, threadType: threadInfo.type, + includeServerSearchUsers: isFarcasterThread ? searchUsersResult : undefined, }); const onChangeTagInput = React.useCallback( diff --git a/web/settings/relationship/add-users-utils.js b/web/settings/relationship/add-users-utils.js --- a/web/settings/relationship/add-users-utils.js +++ b/web/settings/relationship/add-users-utils.js @@ -14,13 +14,17 @@ import { threadActualMembers } from 'lib/shared/thread-utils.js'; import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { UserRelationshipStatus } from 'lib/types/relationship-types.js'; -import type { ThreadType } from 'lib/types/thread-types-enum.js'; +import { + farcasterThreadTypeValidator, + type ThreadType, +} from 'lib/types/thread-types-enum.js'; import type { GlobalAccountUserInfo, AccountUserInfo, UserListItem, } from 'lib/types/user-types.js'; import { values } from 'lib/utils/objects.js'; +import { useIsFarcasterDCsIntegrationEnabled } from 'lib/utils/services-utils.js'; import { useAddUsersListContext } from './add-users-list-provider.react.js'; import { useSelector } from '../../redux/redux-utils.js'; @@ -149,6 +153,13 @@ [previouslySelectedUsers, threadInfo.members, viewerID], ); + const isFarcasterDCsIntegrationEnabled = + useIsFarcasterDCsIntegrationEnabled(); + const isFarcasterThread = farcasterThreadTypeValidator.is(threadInfo.type); + const searchUsersResult = useSearchUsers(searchText, { + searchFarcaster: isFarcasterDCsIntegrationEnabled && isFarcasterThread, + skipCommUsers: true, + }); const auxUserInfos = useSelector(state => state.auxUserStore.auxUserInfos); const userSearchResults = usePotentialMemberItems({ text: searchText, @@ -158,6 +169,7 @@ inputParentThreadInfo: parentThreadInfo, inputCommunityThreadInfo: communityThreadInfo, threadType: threadInfo.type, + includeServerSearchUsers: isFarcasterThread ? searchUsersResult : undefined, }); const userInfos = React.useMemo(() => {