Second batch: Replace MatrixClient.isRoomEncrypted
by MatrixClient.CryptoApi.isEncryptionEnabledInRoom
(#28466)
* Add `asyncFilter` * Replace `MatrixClient.isRoomEncrypted` by `MatrixClient.CryptoApi.isEncryptionEnabledInRoom` in `MemberListStore.tsx` * Replace `MatrixClient.isRoomEncrypted` by `MatrixClient.CryptoApi.isEncryptionEnabledInRoom` in `EventIndex.tsx` * Replace `MatrixClient.isRoomEncrypted` by `MatrixClient.CryptoApi.isEncryptionEnabledInRoom` in `SendMessageComposer.tsx` * Replace `MatrixClient.isRoomEncrypted` by `MatrixClient.CryptoApi.isEncryptionEnabledInRoom` in `ScalarMessaging.ts` * Replace `MatrixClient.isRoomEncrypted` by `MatrixClient.CryptoApi.isEncryptionEnabledInRoom` in `RolesRoomSettingsTab.tsx` * Add reject doc to `asyncFilter` * Reverse `MemberListStore.loadMembers` condition * Remove async for `ScalarMessaging.ts` * Display permission section only after `isEncrypted` is computed * Display composer only after `isEncrypted` is computed * Revert "Display composer only after `isEncrypted` is computed" This reverts commit4d4e037391
. * Revert "Replace `MatrixClient.isRoomEncrypted` by `MatrixClient.CryptoApi.isEncryptionEnabledInRoom` in `SendMessageComposer.tsx`" This reverts commit6bf06da02c
.
This commit is contained in:
parent
ca33d9165a
commit
5cdcf44b6f
8 changed files with 93 additions and 49 deletions
|
@ -350,6 +350,17 @@ export async function asyncSomeParallel<T>(
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Async version of Array.filter.
|
||||
* If one of the promises rejects, the whole operation will reject.
|
||||
* @param values
|
||||
* @param predicate
|
||||
*/
|
||||
export async function asyncFilter<T>(values: Array<T>, predicate: (value: T) => Promise<boolean>): Promise<Array<T>> {
|
||||
const results = await Promise.all(values.map(predicate));
|
||||
return values.filter((_, i) => results[i]);
|
||||
}
|
||||
|
||||
export function filterBoolean<T>(values: Array<T | null | undefined>): T[] {
|
||||
return values.filter(Boolean) as T[];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue