use useIsEncrypted hook in UserInfo
This commit is contained in:
parent
3a8499259e
commit
280690cf3c
1 changed files with 2 additions and 13 deletions
|
@ -45,6 +45,7 @@ import EncryptionPanel from "./EncryptionPanel";
|
||||||
import { useAsyncMemo } from '../../../hooks/useAsyncMemo';
|
import { useAsyncMemo } from '../../../hooks/useAsyncMemo';
|
||||||
import { verifyUser, legacyVerifyUser, verifyDevice } from '../../../verification';
|
import { verifyUser, legacyVerifyUser, verifyDevice } from '../../../verification';
|
||||||
import {Action} from "../../../dispatcher/actions";
|
import {Action} from "../../../dispatcher/actions";
|
||||||
|
import {useIsEncrypted} from "../../../hooks/useIsEncrypted";
|
||||||
|
|
||||||
const _disambiguateDevices = (devices) => {
|
const _disambiguateDevices = (devices) => {
|
||||||
const names = Object.create(null);
|
const names = Object.create(null);
|
||||||
|
@ -124,18 +125,6 @@ async function openDMForUser(matrixClient, userId) {
|
||||||
createRoom(createRoomOptions);
|
createRoom(createRoomOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
function useIsEncrypted(cli, room) {
|
|
||||||
const [isEncrypted, setIsEncrypted] = useState(room ? cli.isRoomEncrypted(room.roomId) : undefined);
|
|
||||||
|
|
||||||
const update = useCallback((event) => {
|
|
||||||
if (event.getType() === "m.room.encryption") {
|
|
||||||
setIsEncrypted(cli.isRoomEncrypted(room.roomId));
|
|
||||||
}
|
|
||||||
}, [cli, room]);
|
|
||||||
useEventEmitter(room ? room.currentState : undefined, "RoomState.events", update);
|
|
||||||
return isEncrypted;
|
|
||||||
}
|
|
||||||
|
|
||||||
function useHasCrossSigningKeys(cli, member, canVerify, setUpdating) {
|
function useHasCrossSigningKeys(cli, member, canVerify, setUpdating) {
|
||||||
return useAsyncMemo(async () => {
|
return useAsyncMemo(async () => {
|
||||||
if (!canVerify) {
|
if (!canVerify) {
|
||||||
|
@ -1485,7 +1474,7 @@ const UserInfoHeader = ({onClose, member, e2eStatus}) => {
|
||||||
const UserInfo = ({user, groupId, roomId, onClose, phase=RightPanelPhases.RoomMemberInfo, ...props}) => {
|
const UserInfo = ({user, groupId, roomId, onClose, phase=RightPanelPhases.RoomMemberInfo, ...props}) => {
|
||||||
const cli = useContext(MatrixClientContext);
|
const cli = useContext(MatrixClientContext);
|
||||||
|
|
||||||
// Load room if we are given a room id and memoize it
|
// Load room if we are given a room id and memoize it - this can be undefined for User Info/Group Member Info
|
||||||
const room = useMemo(() => roomId ? cli.getRoom(roomId) : null, [cli, roomId]);
|
const room = useMemo(() => roomId ? cli.getRoom(roomId) : null, [cli, roomId]);
|
||||||
// fetch latest room member if we have a room, so we don't show historical information, falling back to user
|
// fetch latest room member if we have a room, so we don't show historical information, falling back to user
|
||||||
const member = useMemo(() => room ? (room.getMember(user.userId) || user) : user, [room, user]);
|
const member = useMemo(() => room ? (room.getMember(user.userId) || user) : user, [room, user]);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue