Cleanup E2ePadlock code (#7144)

This commit is contained in:
Šimon Brandner 2021-11-17 10:36:10 +01:00 committed by GitHub
parent f27eb04133
commit 8f13f3882f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 12 deletions

View file

@ -424,8 +424,6 @@ $left-gutter: 64px;
}
&::before {
background-color: #ffffff;
mask-image: url('$(res)/img/e2e/normal.svg');
mask-repeat: no-repeat;
mask-position: center;
mask-size: 80%;

View file

@ -1509,25 +1509,25 @@ export function haveTileForEvent(e: MatrixEvent, showHiddenEvents?: boolean) {
function E2ePadlockUndecryptable(props) {
return (
<E2ePadlock title={_t("This message cannot be decrypted")} icon="warning" {...props} />
<E2ePadlock title={_t("This message cannot be decrypted")} icon={E2ePadlockIcon.Warning} {...props} />
);
}
function E2ePadlockUnverified(props) {
return (
<E2ePadlock title={_t("Encrypted by an unverified session")} icon="warning" {...props} />
<E2ePadlock title={_t("Encrypted by an unverified session")} icon={E2ePadlockIcon.Warning} {...props} />
);
}
function E2ePadlockUnencrypted(props) {
return (
<E2ePadlock title={_t("Unencrypted")} icon="warning" {...props} />
<E2ePadlock title={_t("Unencrypted")} icon={E2ePadlockIcon.Warning} {...props} />
);
}
function E2ePadlockUnknown(props) {
return (
<E2ePadlock title={_t("Encrypted by a deleted session")} icon="normal" {...props} />
<E2ePadlock title={_t("Encrypted by a deleted session")} icon={E2ePadlockIcon.Normal} {...props} />
);
}
@ -1535,14 +1535,19 @@ function E2ePadlockUnauthenticated(props) {
return (
<E2ePadlock
title={_t("The authenticity of this encrypted message can't be guaranteed on this device.")}
icon="unauthenticated"
icon={E2ePadlockIcon.Normal}
{...props}
/>
);
}
enum E2ePadlockIcon {
Normal = "normal",
Warning = "warning",
}
interface IE2ePadlockProps {
icon: string;
icon: E2ePadlockIcon;
title: string;
}
@ -1551,7 +1556,7 @@ interface IE2ePadlockState {
}
class E2ePadlock extends React.Component<IE2ePadlockProps, IE2ePadlockState> {
constructor(props) {
constructor(props: IE2ePadlockProps) {
super(props);
this.state = {
@ -1559,15 +1564,15 @@ class E2ePadlock extends React.Component<IE2ePadlockProps, IE2ePadlockState> {
};
}
onHoverStart = () => {
private onHoverStart = (): void => {
this.setState({ hover: true });
};
onHoverEnd = () => {
private onHoverEnd = (): void => {
this.setState({ hover: false });
};
render() {
public render(): JSX.Element {
let tooltip = null;
if (this.state.hover) {
tooltip = <Tooltip className="mx_EventTile_e2eIcon_tooltip" label={this.props.title} />;