diff --git a/lib/shared/dm-ops/dm-op-utils.js b/lib/shared/dm-ops/dm-op-utils.js --- a/lib/shared/dm-ops/dm-op-utils.js +++ b/lib/shared/dm-ops/dm-op-utils.js @@ -47,7 +47,10 @@ import { getContentSigningKey } from '../../utils/crypto-utils.js'; import { useSelector, useDispatch } from '../../utils/redux-utils.js'; import { messageSpecs } from '../messages/message-specs.js'; -import { userHasDeviceList } from '../thread-utils.js'; +import { + userHasDeviceList, + deviceListCanBeRequestedForUser, +} from '../thread-utils.js'; function generateMessagesToPeers( message: DMOperation, @@ -135,7 +138,11 @@ const missingDeviceListsUserIDs: Array = []; for (const userID of userIDs) { const supportsThickThreads = userHasDeviceList(userID, auxUserInfos); - if (!supportsThickThreads) { + const deviceListCanBeRequested = deviceListCanBeRequestedForUser( + userID, + auxUserInfos, + ); + if (!supportsThickThreads && deviceListCanBeRequested) { missingDeviceListsUserIDs.push(userID); } } 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 @@ -1878,6 +1878,19 @@ return !!deviceList && deviceList.devices.length > 0; } +const deviceListRequestTimeout = 20 * 1000; // twenty seconds + +function deviceListCanBeRequestedForUser( + userID: string, + auxUserInfos: AuxUserInfos, +): boolean { + return ( + !auxUserInfos[userID]?.accountMissingStatus || + auxUserInfos[userID].accountMissingStatus.lastChecked < + Date.now() - deviceListRequestTimeout + ); +} + export { threadHasPermission, useCommunityRootMembersToRole, @@ -1947,4 +1960,5 @@ createThreadTimestamps, userHasDeviceList, deviceListIsNonEmpty, + deviceListCanBeRequestedForUser, };