Page MenuHomePhabricator

D13729.id45256.diff
No OneTemporary

D13729.id45256.diff

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
@@ -3,7 +3,10 @@
import * as React from 'react';
import { useFindUserIdentities } from '../actions/find-user-identities-actions.js';
-import { userHasDeviceList } from '../shared/thread-utils.js';
+import {
+ userHasDeviceList,
+ deviceListCanBeRequestedForUser,
+} from '../shared/thread-utils.js';
import { useSelector } from '../utils/redux-utils.js';
function useUsersSupportThickThreads(): (
@@ -20,7 +23,7 @@
for (const userID of userIDs) {
if (userHasDeviceList(userID, auxUserInfos)) {
usersSupportingThickThreads.add(userID);
- } else {
+ } else if (deviceListCanBeRequestedForUser(userID, auxUserInfos)) {
usersNeedingFetch.push(userID);
}
}
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<string> = [];
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
@@ -1832,6 +1832,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,
@@ -1901,4 +1914,5 @@
createThreadTimestamps,
userHasDeviceList,
deviceListIsNonEmpty,
+ deviceListCanBeRequestedForUser,
};

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 18, 7:42 PM (21 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2535767
Default Alt Text
D13729.id45256.diff (2 KB)

Event Timeline