diff --git a/lib/hooks/relationship-hooks.js b/lib/hooks/relationship-hooks.js --- a/lib/hooks/relationship-hooks.js +++ b/lib/hooks/relationship-hooks.js @@ -87,7 +87,7 @@ ); const createNewThickThread = useNewThickThread(); - const filterUsersSupportingThickThreads = useUsersSupportThickThreads(); + const mapUsersSupportingThickThreads = useUsersSupportThickThreads(); const updateRelationshipsAndSendRobotext = React.useCallback( async (action: RelationshipAction, userIDs: $ReadOnlyArray) => { @@ -98,10 +98,13 @@ return {}; } const usersSupportingThickThreads = - await filterUsersSupportingThickThreads(userIDs); + await mapUsersSupportingThickThreads(userIDs); const planForUsers = new Map(); for (const userID of userIDs) { - if (!usersSupportingThickThreads.has(userID)) { + if (usersSupportingThickThreads.get(userID) === undefined) { + throw new Error('Cannot fetch user identity'); + } + if (!usersSupportingThickThreads.get(userID)) { planForUsers.set(userID, { plan: 'send_to_thin_thread' }); continue; } @@ -220,7 +223,7 @@ [ viewerID, updateRelationships, - filterUsersSupportingThickThreads, + mapUsersSupportingThickThreads, pendingToRealizedThreadIDs, sendRobotextToThickThread, userInfos, 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 @@ -106,7 +106,7 @@ filterAndSetUserResults( identitySearchUsers.map(search => ({ ...search, - supportThickThreads: userIDsSupportingThickThreads.has(search.id), + supportThickThreads: !!userIDsSupportingThickThreads.get(search.id), })), ); })(); diff --git a/lib/hooks/user-identities-hooks.js b/lib/hooks/user-identities-hooks.js --- a/lib/hooks/user-identities-hooks.js +++ b/lib/hooks/user-identities-hooks.js @@ -7,18 +7,18 @@ function useUsersSupportThickThreads(): ( userIDs: $ReadOnlyArray, -) => Promise<$ReadOnlySet> { +) => Promise<$ReadOnlyMap> { const findUserIdentities = useFindUserIdentities(); const auxUserInfos = useSelector(state => state.auxUserStore.auxUserInfos); return React.useCallback( async (userIDs: $ReadOnlyArray) => { - const usersSupportingThickThreads = new Set(); + const usersSupportingThickThreads = new Map(); const usersNeedingFetch = []; for (const userID of userIDs) { if (auxUserInfos[userID]?.deviceList) { - usersSupportingThickThreads.add(userID); + usersSupportingThickThreads.set(userID, true); } else { usersNeedingFetch.push(userID); } @@ -27,7 +27,11 @@ const { identities } = await findUserIdentities(usersNeedingFetch); for (const userID of usersNeedingFetch) { if (identities[userID]) { - usersSupportingThickThreads.add(userID); + usersSupportingThickThreads.set(userID, true); + } else if (identities[userID] === undefined) { + usersSupportingThickThreads.set(userID, undefined); + } else { + usersSupportingThickThreads.set(userID, false); } } } diff --git a/lib/shared/thread-utils.js b/lib/shared/thread-utils.js --- a/lib/shared/thread-utils.js +++ b/lib/shared/thread-utils.js @@ -1790,7 +1790,7 @@ return; } const result = await usersSupportThickThreads([userInfo.id]); - setSupportThickThreads(result.has(userInfo.id)); + setSupportThickThreads(!!result.get(userInfo.id)); })(); }, [userInfo, usersSupportThickThreads]); diff --git a/native/chat/message-list-container.react.js b/native/chat/message-list-container.react.js --- a/native/chat/message-list-container.react.js +++ b/native/chat/message-list-container.react.js @@ -299,7 +299,7 @@ ); setAllUsersSupportThickThreads( userInfoInputArray.every(userInfo => - usersSupportingThickThreads.has(userInfo.id), + usersSupportingThickThreads.get(userInfo.id), ), ); })(); diff --git a/web/chat/chat-thread-composer.react.js b/web/chat/chat-thread-composer.react.js --- a/web/chat/chat-thread-composer.react.js +++ b/web/chat/chat-thread-composer.react.js @@ -115,7 +115,7 @@ allUsersSupportThickThreads: user.id === viewerID ? true - : usersSupportingThickThreads.has(user.id), + : !!usersSupportingThickThreads.get(user.id), }); dispatch({ type: updateNavInfoActionType, diff --git a/web/utils/thread-utils.js b/web/utils/thread-utils.js --- a/web/utils/thread-utils.js +++ b/web/utils/thread-utils.js @@ -88,7 +88,7 @@ ); setAllUsersSupportThickThreads( selectedUserInfos.every(userInfo => - usersSupportingThickThreads.has(userInfo.id), + usersSupportingThickThreads.get(userInfo.id), ), ); })();