Add E2E status in room header (#11493)
* Add E2E status in room header * Clearer logic for dmRoomList Co-authored-by: Andy Balaam <andy.balaam@matrix.org> * Add test for E2E shield * Remove dead code --------- Co-authored-by: Andy Balaam <andy.balaam@matrix.org>
This commit is contained in:
parent
6b3243b27b
commit
46037d2357
6 changed files with 127 additions and 17 deletions
|
@ -37,7 +37,6 @@ export const useAccountData = <T extends {}>(cli: MatrixClient, eventType: strin
|
|||
return value || ({} as T);
|
||||
};
|
||||
|
||||
// Hook to simplify listening to Matrix room account data
|
||||
// Currently not used, commenting out otherwise the dead code CI is unhappy.
|
||||
// But this code is valid and probably will be needed.
|
||||
|
||||
|
|
34
src/hooks/useEncryptionStatus.ts
Normal file
34
src/hooks/useEncryptionStatus.ts
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
Copyright 2023 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { MatrixClient, Room } from "matrix-js-sdk/src/matrix";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import { E2EStatus, shieldStatusForRoom } from "../utils/ShieldUtils";
|
||||
|
||||
export function useEncryptionStatus(client: MatrixClient, room: Room): E2EStatus | null {
|
||||
const [e2eStatus, setE2eStatus] = useState<E2EStatus | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (client.isCryptoEnabled()) {
|
||||
shieldStatusForRoom(client, room).then((e2eStatus) => {
|
||||
setE2eStatus(e2eStatus);
|
||||
});
|
||||
}
|
||||
}, [client, room]);
|
||||
|
||||
return e2eStatus;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue