Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into t3chguy/fix/18677
This commit is contained in:
commit
22c5902ae4
5 changed files with 33 additions and 32 deletions
|
@ -16,26 +16,38 @@ limitations under the License.
|
||||||
|
|
||||||
import React, { forwardRef, useContext } from 'react';
|
import React, { forwardRef, useContext } from 'react';
|
||||||
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
||||||
|
import { IRoomEncryption } from "matrix-js-sdk/src/crypto/RoomList";
|
||||||
|
|
||||||
import { _t } from '../../../languageHandler';
|
import { _t } from '../../../languageHandler';
|
||||||
import { MatrixClientPeg } from '../../../MatrixClientPeg';
|
import { MatrixClientPeg } from '../../../MatrixClientPeg';
|
||||||
import EventTileBubble from "./EventTileBubble";
|
import EventTileBubble from "./EventTileBubble";
|
||||||
import MatrixClientContext from "../../../contexts/MatrixClientContext";
|
import MatrixClientContext from "../../../contexts/MatrixClientContext";
|
||||||
import DMRoomMap from "../../../utils/DMRoomMap";
|
import DMRoomMap from "../../../utils/DMRoomMap";
|
||||||
|
import { objectHasDiff } from "../../../utils/objects";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
mxEvent: MatrixEvent;
|
mxEvent: MatrixEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ALGORITHM = "m.megolm.v1.aes-sha2";
|
||||||
|
|
||||||
const EncryptionEvent = forwardRef<HTMLDivElement, IProps>(({ mxEvent }, ref) => {
|
const EncryptionEvent = forwardRef<HTMLDivElement, IProps>(({ mxEvent }, ref) => {
|
||||||
const cli = useContext(MatrixClientContext);
|
const cli = useContext(MatrixClientContext);
|
||||||
const roomId = mxEvent.getRoomId();
|
const roomId = mxEvent.getRoomId();
|
||||||
const isRoomEncrypted = MatrixClientPeg.get().isRoomEncrypted(roomId);
|
const isRoomEncrypted = MatrixClientPeg.get().isRoomEncrypted(roomId);
|
||||||
|
|
||||||
if (mxEvent.getContent().algorithm === 'm.megolm.v1.aes-sha2' && isRoomEncrypted) {
|
const prevContent = mxEvent.getPrevContent() as IRoomEncryption;
|
||||||
|
const content = mxEvent.getContent<IRoomEncryption>();
|
||||||
|
|
||||||
|
// if no change happened then skip rendering this, a shallow check is enough as all known fields are top-level.
|
||||||
|
if (!objectHasDiff(prevContent, content)) return null; // nop
|
||||||
|
|
||||||
|
if (content.algorithm === ALGORITHM && isRoomEncrypted) {
|
||||||
let subtitle: string;
|
let subtitle: string;
|
||||||
const dmPartner = DMRoomMap.shared().getUserIdForRoomId(roomId);
|
const dmPartner = DMRoomMap.shared().getUserIdForRoomId(roomId);
|
||||||
if (dmPartner) {
|
if (prevContent.algorithm === ALGORITHM) {
|
||||||
|
subtitle = _t("Some encryption parameters have been changed.");
|
||||||
|
} else if (dmPartner) {
|
||||||
const displayName = cli?.getRoom(roomId)?.getMember(dmPartner)?.rawDisplayName || dmPartner;
|
const displayName = cli?.getRoom(roomId)?.getMember(dmPartner)?.rawDisplayName || dmPartner;
|
||||||
subtitle = _t("Messages here are end-to-end encrypted. " +
|
subtitle = _t("Messages here are end-to-end encrypted. " +
|
||||||
"Verify %(displayName)s in their profile - tap on their avatar.", { displayName });
|
"Verify %(displayName)s in their profile - tap on their avatar.", { displayName });
|
||||||
|
@ -49,7 +61,9 @@ const EncryptionEvent = forwardRef<HTMLDivElement, IProps>(({ mxEvent }, ref) =>
|
||||||
title={_t("Encryption enabled")}
|
title={_t("Encryption enabled")}
|
||||||
subtitle={subtitle}
|
subtitle={subtitle}
|
||||||
/>;
|
/>;
|
||||||
} else if (isRoomEncrypted) {
|
}
|
||||||
|
|
||||||
|
if (isRoomEncrypted) {
|
||||||
return <EventTileBubble
|
return <EventTileBubble
|
||||||
className="mx_cryptoEvent mx_cryptoEvent_icon"
|
className="mx_cryptoEvent mx_cryptoEvent_icon"
|
||||||
title={_t("Encryption enabled")}
|
title={_t("Encryption enabled")}
|
||||||
|
|
|
@ -57,7 +57,7 @@ const EncryptionPanel: React.FC<IProps> = (props: IProps) => {
|
||||||
// state to show a spinner immediately after clicking "start verification",
|
// state to show a spinner immediately after clicking "start verification",
|
||||||
// before we have a request
|
// before we have a request
|
||||||
const [isRequesting, setRequesting] = useState(false);
|
const [isRequesting, setRequesting] = useState(false);
|
||||||
const [phase, setPhase] = useState(request && request.phase);
|
const [phase, setPhase] = useState(request?.phase);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setRequest(verificationRequest);
|
setRequest(verificationRequest);
|
||||||
if (verificationRequest) {
|
if (verificationRequest) {
|
||||||
|
|
|
@ -29,43 +29,27 @@ import VerificationQRCode from "../elements/crypto/VerificationQRCode";
|
||||||
import { _t } from "../../../languageHandler";
|
import { _t } from "../../../languageHandler";
|
||||||
import SdkConfig from "../../../SdkConfig";
|
import SdkConfig from "../../../SdkConfig";
|
||||||
import E2EIcon from "../rooms/E2EIcon";
|
import E2EIcon from "../rooms/E2EIcon";
|
||||||
import {
|
import { Phase } from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest";
|
||||||
PHASE_READY,
|
|
||||||
PHASE_DONE,
|
|
||||||
PHASE_STARTED,
|
|
||||||
PHASE_CANCELLED,
|
|
||||||
} from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest";
|
|
||||||
import Spinner from "../elements/Spinner";
|
import Spinner from "../elements/Spinner";
|
||||||
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
||||||
import AccessibleButton from "../elements/AccessibleButton";
|
import AccessibleButton from "../elements/AccessibleButton";
|
||||||
import VerificationShowSas from "../verification/VerificationShowSas";
|
import VerificationShowSas from "../verification/VerificationShowSas";
|
||||||
|
|
||||||
// XXX: Should be defined in matrix-js-sdk
|
|
||||||
enum VerificationPhase {
|
|
||||||
PHASE_UNSENT,
|
|
||||||
PHASE_REQUESTED,
|
|
||||||
PHASE_READY,
|
|
||||||
PHASE_DONE,
|
|
||||||
PHASE_STARTED,
|
|
||||||
PHASE_CANCELLED,
|
|
||||||
}
|
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
layout: string;
|
layout: string;
|
||||||
request: VerificationRequest;
|
request: VerificationRequest;
|
||||||
member: RoomMember | User;
|
member: RoomMember | User;
|
||||||
phase: VerificationPhase;
|
phase: Phase;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
isRoomEncrypted: boolean;
|
isRoomEncrypted: boolean;
|
||||||
inDialog: boolean;
|
inDialog: boolean;
|
||||||
key: number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IState {
|
interface IState {
|
||||||
sasEvent?: SAS;
|
sasEvent?: SAS["sasEvent"];
|
||||||
emojiButtonClicked?: boolean;
|
emojiButtonClicked?: boolean;
|
||||||
reciprocateButtonClicked?: boolean;
|
reciprocateButtonClicked?: boolean;
|
||||||
reciprocateQREvent?: ReciprocateQRCode;
|
reciprocateQREvent?: ReciprocateQRCode["reciprocateQREvent"];
|
||||||
}
|
}
|
||||||
|
|
||||||
@replaceableComponent("views.right_panel.VerificationPanel")
|
@replaceableComponent("views.right_panel.VerificationPanel")
|
||||||
|
@ -321,9 +305,9 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
|
||||||
const displayName = (member as User).displayName || (member as RoomMember).name || member.userId;
|
const displayName = (member as User).displayName || (member as RoomMember).name || member.userId;
|
||||||
|
|
||||||
switch (phase) {
|
switch (phase) {
|
||||||
case PHASE_READY:
|
case Phase.Ready:
|
||||||
return this.renderQRPhase();
|
return this.renderQRPhase();
|
||||||
case PHASE_STARTED:
|
case Phase.Started:
|
||||||
switch (request.chosenMethod) {
|
switch (request.chosenMethod) {
|
||||||
case verificationMethods.RECIPROCATE_QR_CODE:
|
case verificationMethods.RECIPROCATE_QR_CODE:
|
||||||
return this.renderQRReciprocatePhase();
|
return this.renderQRReciprocatePhase();
|
||||||
|
@ -346,9 +330,9 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
case PHASE_DONE:
|
case Phase.Done:
|
||||||
return this.renderVerifiedPhase();
|
return this.renderVerifiedPhase();
|
||||||
case PHASE_CANCELLED:
|
case Phase.Cancelled:
|
||||||
return this.renderCancelledPhase();
|
return this.renderCancelledPhase();
|
||||||
}
|
}
|
||||||
console.error("VerificationPanel unhandled phase:", phase);
|
console.error("VerificationPanel unhandled phase:", phase);
|
||||||
|
@ -375,7 +359,8 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
|
||||||
|
|
||||||
private updateVerifierState = () => {
|
private updateVerifierState = () => {
|
||||||
const { request } = this.props;
|
const { request } = this.props;
|
||||||
const { sasEvent, reciprocateQREvent } = request.verifier;
|
const sasEvent = (request.verifier as SAS).sasEvent;
|
||||||
|
const reciprocateQREvent = (request.verifier as ReciprocateQRCode).reciprocateQREvent;
|
||||||
request.verifier.off('show_sas', this.updateVerifierState);
|
request.verifier.off('show_sas', this.updateVerifierState);
|
||||||
request.verifier.off('show_reciprocate_qr', this.updateVerifierState);
|
request.verifier.off('show_reciprocate_qr', this.updateVerifierState);
|
||||||
this.setState({ sasEvent, reciprocateQREvent });
|
this.setState({ sasEvent, reciprocateQREvent });
|
||||||
|
@ -402,7 +387,8 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
|
||||||
const { request } = this.props;
|
const { request } = this.props;
|
||||||
request.on("change", this.onRequestChange);
|
request.on("change", this.onRequestChange);
|
||||||
if (request.verifier) {
|
if (request.verifier) {
|
||||||
const { sasEvent, reciprocateQREvent } = request.verifier;
|
const sasEvent = (request.verifier as SAS).sasEvent;
|
||||||
|
const reciprocateQREvent = (request.verifier as ReciprocateQRCode).reciprocateQREvent;
|
||||||
this.setState({ sasEvent, reciprocateQREvent });
|
this.setState({ sasEvent, reciprocateQREvent });
|
||||||
}
|
}
|
||||||
this.onRequestChange();
|
this.onRequestChange();
|
||||||
|
|
|
@ -15,7 +15,7 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { SAS } from "matrix-js-sdk/src/crypto/verification/SAS";
|
import { IGeneratedSas } from "matrix-js-sdk/src/crypto/verification/SAS";
|
||||||
import { DeviceInfo } from "matrix-js-sdk/src//crypto/deviceinfo";
|
import { DeviceInfo } from "matrix-js-sdk/src//crypto/deviceinfo";
|
||||||
import { _t, _td } from '../../../languageHandler';
|
import { _t, _td } from '../../../languageHandler';
|
||||||
import { PendingActionSpinner } from "../right_panel/EncryptionInfo";
|
import { PendingActionSpinner } from "../right_panel/EncryptionInfo";
|
||||||
|
@ -30,7 +30,7 @@ interface IProps {
|
||||||
device?: DeviceInfo;
|
device?: DeviceInfo;
|
||||||
onDone: () => void;
|
onDone: () => void;
|
||||||
onCancel: () => void;
|
onCancel: () => void;
|
||||||
sas: SAS.sas;
|
sas: IGeneratedSas;
|
||||||
isSelf?: boolean;
|
isSelf?: boolean;
|
||||||
inDialog?: boolean; // whether this component is being shown in a dialog and to use DialogButtons
|
inDialog?: boolean; // whether this component is being shown in a dialog and to use DialogButtons
|
||||||
}
|
}
|
||||||
|
|
|
@ -1922,6 +1922,7 @@
|
||||||
"Decrypting": "Decrypting",
|
"Decrypting": "Decrypting",
|
||||||
"Download": "Download",
|
"Download": "Download",
|
||||||
"View Source": "View Source",
|
"View Source": "View Source",
|
||||||
|
"Some encryption parameters have been changed.": "Some encryption parameters have been changed.",
|
||||||
"Messages here are end-to-end encrypted. Verify %(displayName)s in their profile - tap on their avatar.": "Messages here are end-to-end encrypted. Verify %(displayName)s in their profile - tap on their avatar.",
|
"Messages here are end-to-end encrypted. Verify %(displayName)s in their profile - tap on their avatar.": "Messages here are end-to-end encrypted. Verify %(displayName)s in their profile - tap on their avatar.",
|
||||||
"Messages in this room are end-to-end encrypted. When people join, you can verify them in their profile, just tap on their avatar.": "Messages in this room are end-to-end encrypted. When people join, you can verify them in their profile, just tap on their avatar.",
|
"Messages in this room are end-to-end encrypted. When people join, you can verify them in their profile, just tap on their avatar.": "Messages in this room are end-to-end encrypted. When people join, you can verify them in their profile, just tap on their avatar.",
|
||||||
"Encryption enabled": "Encryption enabled",
|
"Encryption enabled": "Encryption enabled",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue