Replace MatrixClient.isRoomEncrypted
by MatrixClient.CryptoApi.isEncryptionEnabledInRoom
in RolesRoomSettingsTab.tsx
This commit is contained in:
parent
de765bb51b
commit
a0d0fa787b
1 changed files with 18 additions and 3 deletions
|
@ -127,12 +127,27 @@ interface IProps {
|
||||||
room: Room;
|
room: Room;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class RolesRoomSettingsTab extends React.Component<IProps> {
|
interface RolesRoomSettingsTabState {
|
||||||
|
isRoomEncrypted: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class RolesRoomSettingsTab extends React.Component<IProps, RolesRoomSettingsTabState> {
|
||||||
public static contextType = MatrixClientContext;
|
public static contextType = MatrixClientContext;
|
||||||
public declare context: React.ContextType<typeof MatrixClientContext>;
|
public declare context: React.ContextType<typeof MatrixClientContext>;
|
||||||
|
|
||||||
public componentDidMount(): void {
|
public constructor(props: IProps) {
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
isRoomEncrypted: false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public async componentDidMount(): Promise<void> {
|
||||||
this.context.on(RoomStateEvent.Update, this.onRoomStateUpdate);
|
this.context.on(RoomStateEvent.Update, this.onRoomStateUpdate);
|
||||||
|
this.setState({
|
||||||
|
isRoomEncrypted:
|
||||||
|
(await this.context.getCrypto()?.isEncryptionEnabledInRoom(this.props.room.roomId)) || false,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public componentWillUnmount(): void {
|
public componentWillUnmount(): void {
|
||||||
|
@ -416,7 +431,7 @@ export default class RolesRoomSettingsTab extends React.Component<IProps> {
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
|
|
||||||
// hide the power level selector for enabling E2EE if it the room is already encrypted
|
// hide the power level selector for enabling E2EE if it the room is already encrypted
|
||||||
if (client.isRoomEncrypted(this.props.room.roomId)) {
|
if (this.state.isRoomEncrypted) {
|
||||||
delete eventsLevels[EventType.RoomEncryption];
|
delete eventsLevels[EventType.RoomEncryption];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue