Page MenuHomePhabricator

D13537.id44718.diff
No OneTemporary

D13537.id44718.diff

diff --git a/lib/hooks/thread-search-hooks.js b/lib/hooks/thread-search-hooks.js
--- a/lib/hooks/thread-search-hooks.js
+++ b/lib/hooks/thread-search-hooks.js
@@ -11,6 +11,7 @@
useForwardLookupSearchText,
useSearchUsers,
} from '../shared/search-utils.js';
+import { useOldestPrivateThreadInfo } from '../shared/thread-utils.js';
import type { GlobalAccountUserInfo } from '../types/user-types.js';
import { useSelector } from '../utils/redux-utils.js';
import { usingCommServicesAccessToken } from '../utils/services-utils.js';
@@ -25,21 +26,26 @@
+usersSearchResults: $ReadOnlyArray<UserSearchResult>,
};
+const searchUsersOptions = { includeViewer: true };
+
function useThreadListSearch(
searchText: string,
viewerID: ?string,
): ThreadListSearchResult {
const usersWithPersonalThread = useSelector(usersWithPersonalThreadSelector);
const forwardLookupSearchText = useForwardLookupSearchText(searchText);
+ const oldestPrivateThreadInfo = useOldestPrivateThreadInfo();
const filterAndSetUserResults = React.useCallback(
(userInfos: $ReadOnlyArray<UserSearchResult>) => {
const usersResults = userInfos.filter(
- info => !usersWithPersonalThread.has(info.id) && info.id !== viewerID,
+ info =>
+ !usersWithPersonalThread.has(info.id) &&
+ (info.id !== viewerID || !oldestPrivateThreadInfo),
);
setUsersSearchResults(usersResults);
},
- [usersWithPersonalThread, viewerID],
+ [usersWithPersonalThread, viewerID, oldestPrivateThreadInfo],
);
const legacyCallSearchUsers = useLegacyAshoatKeyserverCall(searchUserCall);
@@ -84,7 +90,10 @@
]);
const usersSupportThickThreads = useUsersSupportThickThreads();
- const identitySearchUsers = useSearchUsers(forwardLookupSearchText);
+ const identitySearchUsers = useSearchUsers(
+ forwardLookupSearchText,
+ searchUsersOptions,
+ );
React.useEffect(() => {
void (async () => {
if (!usingCommServicesAccessToken) {
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
@@ -416,9 +416,14 @@
return usernameToSearch;
}
+type UseSearchUsersOptions = {
+ +includeViewer?: ?boolean,
+};
function useSearchUsers(
usernameInputText: string,
+ options?: ?UseSearchUsersOptions,
): $ReadOnlyArray<GlobalAccountUserInfo> {
+ const includeViewer = !!options?.includeViewer;
const currentUserID = useSelector(
state => state.currentUserInfo && state.currentUserInfo.id,
);
@@ -429,9 +434,13 @@
>([]);
const setSearchResultsFromServer = React.useCallback(
(userInfos: $ReadOnlyArray<GlobalAccountUserInfo>) => {
- setSearchResults(userInfos.filter(({ id }) => id !== currentUserID));
+ if (includeViewer) {
+ setSearchResults(userInfos);
+ } else {
+ setSearchResults(userInfos.filter(({ id }) => id !== currentUserID));
+ }
},
- [currentUserID],
+ [currentUserID, includeViewer],
);
const callLegacyAshoatKeyserverSearchUsers =

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 20, 8:55 AM (21 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2543862
Default Alt Text
D13537.id44718.diff (3 KB)

Event Timeline