Replace `MatrixClient.isRoomEncrypted` by `MatrixClient.CryptoApi.isEncryptionEnabledInRoom` in FilePanel
parent
83777a6c57
commit
42fcb9ce85
|
@ -44,6 +44,7 @@ interface IProps {
|
||||||
interface IState {
|
interface IState {
|
||||||
timelineSet: EventTimelineSet | null;
|
timelineSet: EventTimelineSet | null;
|
||||||
narrow: boolean;
|
narrow: boolean;
|
||||||
|
isRoomEncrypted: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -62,6 +63,7 @@ class FilePanel extends React.Component<IProps, IState> {
|
||||||
public state: IState = {
|
public state: IState = {
|
||||||
timelineSet: null,
|
timelineSet: null,
|
||||||
narrow: false,
|
narrow: false,
|
||||||
|
isRoomEncrypted: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
private onRoomTimeline = (
|
private onRoomTimeline = (
|
||||||
|
@ -113,7 +115,12 @@ class FilePanel extends React.Component<IProps, IState> {
|
||||||
|
|
||||||
await this.updateTimelineSet(this.props.roomId);
|
await this.updateTimelineSet(this.props.roomId);
|
||||||
|
|
||||||
if (!client.isRoomEncrypted(this.props.roomId)) return;
|
const isRoomEncrypted = Boolean(await client.getCrypto()?.isEncryptionEnabledInRoom(this.props.roomId));
|
||||||
|
this.setState({
|
||||||
|
isRoomEncrypted,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!isRoomEncrypted) return;
|
||||||
|
|
||||||
// The timelineSets filter makes sure that encrypted events that contain
|
// The timelineSets filter makes sure that encrypted events that contain
|
||||||
// URLs never get added to the timeline, even if they are live events.
|
// URLs never get added to the timeline, even if they are live events.
|
||||||
|
@ -131,9 +138,7 @@ class FilePanel extends React.Component<IProps, IState> {
|
||||||
|
|
||||||
public componentWillUnmount(): void {
|
public componentWillUnmount(): void {
|
||||||
const client = MatrixClientPeg.get();
|
const client = MatrixClientPeg.get();
|
||||||
if (client === null) return;
|
if (client === null || !this.state.isRoomEncrypted) return;
|
||||||
|
|
||||||
if (!client.isRoomEncrypted(this.props.roomId)) return;
|
|
||||||
|
|
||||||
if (EventIndexPeg.get() !== null) {
|
if (EventIndexPeg.get() !== null) {
|
||||||
client.removeListener(RoomEvent.Timeline, this.onRoomTimeline);
|
client.removeListener(RoomEvent.Timeline, this.onRoomTimeline);
|
||||||
|
@ -173,7 +178,7 @@ class FilePanel extends React.Component<IProps, IState> {
|
||||||
// the event index to fulfill the pagination request. Asking the server
|
// the event index to fulfill the pagination request. Asking the server
|
||||||
// to paginate won't ever work since the server can't correctly filter
|
// to paginate won't ever work since the server can't correctly filter
|
||||||
// out events containing URLs
|
// out events containing URLs
|
||||||
if (room && client.isRoomEncrypted(roomId) && eventIndex !== null) {
|
if (room && this.state.isRoomEncrypted && eventIndex !== null) {
|
||||||
return eventIndex.paginateTimelineWindow(room, timelineWindow, direction, limit);
|
return eventIndex.paginateTimelineWindow(room, timelineWindow, direction, limit);
|
||||||
} else {
|
} else {
|
||||||
return timelineWindow.paginate(direction, limit);
|
return timelineWindow.paginate(direction, limit);
|
||||||
|
@ -206,7 +211,7 @@ class FilePanel extends React.Component<IProps, IState> {
|
||||||
// event index to populate the timelineSet for us. This call
|
// event index to populate the timelineSet for us. This call
|
||||||
// will add 10 events to the live timeline of the set. More can
|
// will add 10 events to the live timeline of the set. More can
|
||||||
// be requested using pagination.
|
// be requested using pagination.
|
||||||
if (client.isRoomEncrypted(roomId) && eventIndex !== null) {
|
if (this.state.isRoomEncrypted && eventIndex !== null) {
|
||||||
const timeline = timelineSet.getLiveTimeline();
|
const timeline = timelineSet.getLiveTimeline();
|
||||||
await eventIndex.populateFileTimeline(timelineSet, timeline, room, 10);
|
await eventIndex.populateFileTimeline(timelineSet, timeline, room, 10);
|
||||||
}
|
}
|
||||||
|
@ -265,7 +270,7 @@ class FilePanel extends React.Component<IProps, IState> {
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
const isRoomEncrypted = this.noRoom ? false : MatrixClientPeg.safeGet().isRoomEncrypted(this.props.roomId);
|
const isRoomEncrypted = this.noRoom ? false : this.state.isRoomEncrypted;
|
||||||
|
|
||||||
if (this.state.timelineSet) {
|
if (this.state.timelineSet) {
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in New Issue