mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-15 04:34:59 +08:00
Use asyncSomeParallel
instead of asyncSome
This commit is contained in:
parent
662fbd99e3
commit
c0cca69836
@ -46,6 +46,7 @@ import SettingsStore, { CallbackFn } from "./settings/SettingsStore";
|
||||
import { UIFeature } from "./settings/UIFeature";
|
||||
import { isBulkUnverifiedDeviceReminderSnoozed } from "./utils/device/snoozeBulkUnverifiedDeviceReminder";
|
||||
import { getUserDeviceIds } from "./utils/crypto/deviceInfo";
|
||||
import { asyncSomeParallel } from "./utils/arrays.ts";
|
||||
|
||||
const KEY_BACKUP_POLL_INTERVAL = 5 * 60 * 1000;
|
||||
|
||||
@ -249,15 +250,7 @@ export default class DeviceListener {
|
||||
const cryptoApi = cli?.getCrypto();
|
||||
if (!cli || !cryptoApi) return false;
|
||||
|
||||
return await Promise.any(
|
||||
cli
|
||||
.getRooms()
|
||||
.map(({ roomId }) =>
|
||||
cryptoApi
|
||||
.isEncryptionEnabledInRoom(roomId)
|
||||
.then((encrypted) => (encrypted ? Promise.resolve(true) : Promise.reject(false))),
|
||||
),
|
||||
);
|
||||
return await asyncSomeParallel(cli.getRooms(), ({ roomId }) => cryptoApi.isEncryptionEnabledInRoom(roomId));
|
||||
}
|
||||
|
||||
private recheck(): void {
|
||||
|
@ -9,6 +9,7 @@ Please see LICENSE files in the repository root for full details.
|
||||
import { MatrixClient } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import { shouldForceDisableEncryption } from "./shouldForceDisableEncryption";
|
||||
import { asyncSomeParallel } from "../arrays.ts";
|
||||
|
||||
/**
|
||||
* If encryption is force disabled AND the user is not in any encrypted rooms
|
||||
@ -23,14 +24,6 @@ export const shouldSkipSetupEncryption = async (client: MatrixClient): Promise<b
|
||||
|
||||
return (
|
||||
isEncryptionForceDisabled &&
|
||||
!(await Promise.any(
|
||||
client
|
||||
.getRooms()
|
||||
.map(({ roomId }) =>
|
||||
crypto
|
||||
.isEncryptionEnabledInRoom(roomId)
|
||||
.then((encrypted) => (encrypted ? Promise.resolve(true) : Promise.reject(false))),
|
||||
),
|
||||
))
|
||||
!(await asyncSomeParallel(client.getRooms(), ({ roomId }) => crypto.isEncryptionEnabledInRoom(roomId)))
|
||||
);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user