Skip to content

Commit

Permalink
[lib] rename userSupportsThickThreads -> userHasDeviceList
Browse files Browse the repository at this point in the history
Summary:
[ENG-9394](https://linear.app/comm/issue/ENG-9394/create-a-thick-thread-when-possible-while-searching-for-a-personal)

Previous name was incorrect, user supports thick thread when is registered to Identity.

Depends on D13487

Test Plan: Flow

Reviewers: ashoat, tomek

Reviewed By: ashoat

Differential Revision: https://phab.comm.dev/D13488
  • Loading branch information
xsanm committed Sep 30, 2024
1 parent f1a29a5 commit 2b2293c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 24 deletions.
17 changes: 4 additions & 13 deletions lib/hooks/relationship-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { pendingToRealizedThreadIDsSelector } from '../selectors/thread-selector
import { dmOperationSpecificationTypes } from '../shared/dm-ops/dm-op-utils.js';
import { useProcessAndSendDMOperation } from '../shared/dm-ops/process-dm-ops.js';
import {
userSupportsThickThreads,
userHasDeviceList,
getPendingThreadID,
} from '../shared/thread-utils.js';
import type { RelationshipOperation } from '../types/messages/update-relationship.js';
Expand Down Expand Up @@ -123,10 +123,7 @@ function useUpdateRelationships(): (
}
const planForUsers = new Map<string, RobotextPlanForUser>();
for (const userID of userIDs) {
const supportsThickThreads = userSupportsThickThreads(
userID,
auxUserInfos,
);
const supportsThickThreads = userHasDeviceList(userID, auxUserInfos);
if (!supportsThickThreads) {
planForUsers.set(userID, { plan: 'send_to_thin_thread' });
continue;
Expand Down Expand Up @@ -266,10 +263,7 @@ function useUpdateRelationships(): (
}
const { action, userIDs, waitingForUserIDs, resolve, reject } = step;
for (const userID of waitingForUserIDs) {
const supportsThickThreads = userSupportsThickThreads(
userID,
auxUserInfos,
);
const supportsThickThreads = userHasDeviceList(userID, auxUserInfos);
if (!supportsThickThreads) {
// It's safe to wait until every single user ID in waitingForUserIDs
// passes this check because we make the same check when populating
Expand Down Expand Up @@ -313,10 +307,7 @@ function useUpdateRelationships(): (

const missingDeviceListsUserIDs: Array<string> = [];
for (const userID of userIDs) {
const supportsThickThreads = userSupportsThickThreads(
userID,
auxUserInfos,
);
const supportsThickThreads = userHasDeviceList(userID, auxUserInfos);
if (!supportsThickThreads) {
missingDeviceListsUserIDs.push(userID);
}
Expand Down
7 changes: 2 additions & 5 deletions lib/shared/dm-ops/dm-op-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import type { ClientUpdateInfo } from '../../types/update-types.js';
import { getContentSigningKey } from '../../utils/crypto-utils.js';
import { useSelector } from '../../utils/redux-utils.js';
import { messageSpecs } from '../messages/message-specs.js';
import { userSupportsThickThreads } from '../thread-utils.js';
import { userHasDeviceList } from '../thread-utils.js';
import { updateSpecs } from '../updates/update-specs.js';

function generateMessagesToPeers(
Expand Down Expand Up @@ -137,10 +137,7 @@ function useCreateMessagesToPeersFromDMOp(): (
(userIDs: $ReadOnlyArray<string>) => {
const missingDeviceListsUserIDs: Array<string> = [];
for (const userID of userIDs) {
const supportsThickThreads = userSupportsThickThreads(
userID,
auxUserInfos,
);
const supportsThickThreads = userHasDeviceList(userID, auxUserInfos);
if (!supportsThickThreads) {
missingDeviceListsUserIDs.push(userID);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/shared/search-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import SearchIndex from './search-index.js';
import {
getContainingThreadID,
userIsMember,
userSupportsThickThreads,
userHasDeviceList,
} from './thread-utils.js';
import {
searchMessagesActionTypes,
Expand Down Expand Up @@ -165,7 +165,7 @@ function usePotentialMemberItems({
return !!(
threadType &&
threadTypeIsThick(threadType) &&
!userSupportsThickThreads(userID, auxUserInfos)
!userHasDeviceList(userID, auxUserInfos)
);
},
[auxUserInfos, excludeUserIDs, threadType],
Expand Down
4 changes: 2 additions & 2 deletions lib/shared/thread-actions-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
threadIsPending,
threadOtherMembers,
pendingThreadType,
userSupportsThickThreads,
userHasDeviceList,
} from './thread-utils.js';
import {
newThreadActionTypes,
Expand Down Expand Up @@ -138,7 +138,7 @@ async function createRealThreadFromPendingThread({
'otherMemberIDs should not be empty for threads',
);
const allUsersSupportThickThreads = otherMemberIDs.every(memberID =>
userSupportsThickThreads(memberID, auxUserInfos),
userHasDeviceList(memberID, auxUserInfos),
);
if (threadTypeIsThick(threadInfo.type) && allUsersSupportThickThreads) {
const type = assertThickThreadType(
Expand Down
4 changes: 2 additions & 2 deletions lib/shared/thread-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1798,7 +1798,7 @@ function createThreadTimestamps(
};
}

function userSupportsThickThreads(
function userHasDeviceList(
userID: string,
auxUserInfos: AuxUserInfos,
): boolean {
Expand Down Expand Up @@ -1874,5 +1874,5 @@ export {
extractMentionedMembers,
isMemberActive,
createThreadTimestamps,
userSupportsThickThreads,
userHasDeviceList,
};

0 comments on commit 2b2293c

Please sign in to comment.